k-Nearest Neighbors: Predict
Now you have fit a KNN classifier, you can use it to predict the label of new data points. All available data was used for training, however, fortunately, there are new observations available. These have been preloaded for you as X_new
.
The model knn
, which you created and fit the data in the last exercise, has been preloaded for you. You will use your classifier to predict the labels of a set of new data points:
X_new = np.array([[30.0, 17.5],
[107.0, 24.1],
[213.0, 10.9]])
This exercise is part of the course
Supervised Learning with scikit-learn
Exercise instructions
- Create
y_pred
by predicting the target values of the unseen featuresX_new
using theknn
model. - Print the predicted labels for the set of predictions.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Predict the labels for the X_new
y_pred = ____
# Print the predictions
print("Predictions: {}".format(____))