Q&A
前提・実現したいこと
PCA で 主成分100 で訓練する。
発生している問題・エラーメッセージ
lang
1--------------------------------------------------------------------------- 2ValueError Traceback (most recent call last) 3<ipython-input-36-c09bd3c28de9> in <module>() 4----> 1 pca = PCA(n_components=100, whiten=True, random_state=0).fit(X_train) 5 2 X_train_pca = pca.transform(X_train) 6 3 X_test_pca = pca.transform(X_test) 7 8C:\Anaconda3\lib\site-packages\sklearn\decomposition\pca.py in fit(self, X, y) 9 327 Returns the instance itself. 10 328 """ 11--> 329 self._fit(X) 12 330 return self 13 331 14 15C:\Anaconda3\lib\site-packages\sklearn\decomposition\pca.py in _fit(self, X) 16 390 # Call different fits for either full or truncated SVD 17 391 if svd_solver == 'full': 18--> 392 return self._fit_full(X, n_components) 19 393 elif svd_solver in ['arpack', 'randomized']: 20 394 return self._fit_truncated(X, n_components, svd_solver) 21 22C:\Anaconda3\lib\site-packages\sklearn\decomposition\pca.py in _fit_full(self, X, n_components) 23 408 raise ValueError("n_components=%r must be between 0 and " 24 409 "n_features=%r with svd_solver='full'" 25--> 410 % (n_components, n_features)) 26 411 27 412 # Center data 28 29ValueError: n_components=100 must be between 0 and n_features=30 with svd_solver='full'
該当のソースコード
pca = PCA(n_components=100, whiten=True, random_state=0).fit(X_train)
試したこと
エラー通りn_componentを0~30に下げれば実行できましたが、何としてでもn_components=100でやりたいです。検討がつきませんでした。
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2018/08/11 06:51