前提・実現したいこと
PCA で 主成分100 で訓練する。
発生している問題・エラーメッセージ
lang
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-36-c09bd3c28de9> in <module>() ----> 1 pca = PCA(n_components=100, whiten=True, random_state=0).fit(X_train) 2 X_train_pca = pca.transform(X_train) 3 X_test_pca = pca.transform(X_test) C:\Anaconda3\lib\site-packages\sklearn\decomposition\pca.py in fit(self, X, y) 327 Returns the instance itself. 328 """ --> 329 self._fit(X) 330 return self 331 C:\Anaconda3\lib\site-packages\sklearn\decomposition\pca.py in _fit(self, X) 390 # Call different fits for either full or truncated SVD 391 if svd_solver == 'full': --> 392 return self._fit_full(X, n_components) 393 elif svd_solver in ['arpack', 'randomized']: 394 return self._fit_truncated(X, n_components, svd_solver) C:\Anaconda3\lib\site-packages\sklearn\decomposition\pca.py in _fit_full(self, X, n_components) 408 raise ValueError("n_components=%r must be between 0 and " 409 "n_features=%r with svd_solver='full'" --> 410 % (n_components, n_features)) 411 412 # Center data ValueError: 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でやりたいです。検討がつきませんでした。
まだ回答がついていません
会員登録して回答してみよう