Aan de slagGa gratis aan de slag

Getting KNN data in shape

Now that you understand the ins and outs of how K-nearest neighbors works, you can leverage scikit-learn's implementation of KNN while recognizing what it is doing underneath the hood.

In the next two exercises, you will step through how to prepare your data for scikit-learn's KNN model, and then use it to make inferences about what rating a user might give a movie they haven't seen.

For consistency, you will once again be working with User_1 and the rating they would give Apollo 13 (1995) if they saw it.

The users_to_ratings DataFrame has again been loaded for you. This contains each user with its own row and each rating they gave as the values.

Similarly, user_ratings_table has been loaded, which contains the raw rating values (pre-centering and filling with zeros).

Deze oefening maakt deel uit van de cursus

Building Recommendation Engines in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Drop the column you are trying to predict
users_to_ratings.____("Apollo 13 (1995)", axis=1, inplace=____)

# Get the data for the user you are predicting for
target_user_x = ____.____[[____]]
Code bewerken en uitvoeren