we fit the pca object to the training data and extract the first principal components then we transform the training and test datain[ ]pca pca(n_components= whiten=truerandom_state= fit(x_trainx_train_pca pca transform(x_trainx_test_pca pca transform(x_testprint("x_train_pca shape{}format(x_train_pca shape)out[ ]x_train_pca shape( the new data has featuresthe first principal components nowwe can use the new representation to classify our images using one-nearest-neighbors classifierin[ ]knn kneighborsclassifier(n_neighbors= knn fit(x_train_pcay_trainprint("test set accuracy{ }format(knn score(x_test_pcay_test))out[ ]test set accuracy our accuracy improved quite significantlyfrom to %confirming our intuition that the principal components might provide better representation of the data dimensionality reductionfeature extractionand manifold learning