Get startedGet started for free

KNN predictions

With the data in the correct shape from the last exercise, you can now use it to infer how user_001 feels about Apollo 13 (1995)

As a reminder, the data you prepared in the last exercise (and have been loaded into this one) are:

  • target_user_x - Centered ratings that user_001 has given to the movies they have seen.
  • other_users_x - Centered ratings for all other users and the movies they have rated excluding the movie Apollo 13.
  • other_users_y - Raw ratings that all other users have given the movie Apollo 13.

You will use other_users_x and other_users_y to fit a KNeighborsRegressor from scikit-learn and use it to predict what user_001 might have rated Apollo 13 (1995).

This exercise is part of the course

Building Recommendation Engines in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the regressor
from sklearn.neighbors import ____

# Instantiate the user KNN model
user_knn = KNeighborsRegressor(____=____, ____=____)
Edit and Run Code