Training a model with PCA
Now that you have run PCA on the wine
dataset, you'll finally train a KNN model using the transformed data.
This exercise is part of the course
Preprocessing for Machine Learning in Python
Exercise instructions
- Fit the
knn
model to the PCA-transformed features,pca_X_train
, and training labels,y_train
. - Print the test set accuracy of the
knn
model usingpca_X_test
andy_test
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Fit knn to the training data
____
# Score knn on the test data and print it out
____