Session Ready
Exercise

Evaluate KNN performance

We just saw a few things with our KNN scores. For one, the training scores started high and decreased with increasing n, which is typical. The test set performance reached a peak at 5 though, and we will use that as our setting in the final KNN model.

As we have done a few times now, we will check our performance visually. This helps us see how well the model is predicting on different regions of actual values. We will get predictions from our knn model using the .predict() method on our scaled features. Then we'll use matplotlib's plt.scatter() to create a scatter plot of actual versus predicted values.

Instructions
100 XP
  • Set n_neighbors in the KNeighborsRegressor to the best-performing value of 5 (found in the previous exercise).
  • Obtain predictions using the knn model from the scaled_train_features and scaled_test_features.
  • Create a scatter plot of the test_targets versus the test_predictions and label it test.