Learn

Nice work! Your classifier is now able to predict whether a movie will be good or bad. So far, we’ve only tested this on a completely random point [.4, .2, .9]. In this exercise we’re going to pick a real movie, normalize it, and run it through our classifier to see what it predicts!

In the instructions below, we are going to be testing our classifier using the 2017 movie Call Me By Your Name. Feel free to pick your favorite movie instead!

Instructions

1.

To begin, we want to make sure the movie that we want to classify isn’t already in our database. This is important because we don’t want one of the nearest neighbors to be itself!

You can do this by using the in keyword.

Begin by printing if the title of your movie is in movie_dataset. This should print False.

2.

Once you confirm your movie is not in your database, we need to make a datapoint for your movie. Create a variable named my_movie and set it equal to a list of three numbers. They should be:

  • The movie’s budget (dollars)
  • The movie’s runtime (minutes)
  • The year the movie was released

Make sure to put the information in that order.

If you want to use Call Me By Your Name, the budget was 3,500,000 dollars, the runtime was 132 minutes, and the movie was released in 2017.

3.

Next, we want to normalize this datapoint. We’ve included the function normalize_point which takes a datapoint as a parameter and returns the point normalized. Create a variable called normalized_my_movie and set it equal to the normalized value of my_movie. Print the result!

4.

Finally, call classify with the following parameters:

  • normalized_my_movie
  • movie_dataset
  • movie_labels
  • 5

Print the result? Did your classifier think your movie was good or bad?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?