When you are processing the test data, you used fit_transform(X_test)
which actually recomputes another PCA transformation on the test data. You should be using transform(X_test)
, so that the test data undergoes the same transformation as the training data.
The portion of code will look something like (thanks ogrisel for the whiten
tip):
estimator = PCA(n_components=350, whiten=True)
X_train_pca = estimator.fit_transform(X_train)
X_test_pca = estimator.transform(X_test)
Try and see if it helps?