CommencerCommencer gratuitement

Similar and different movie ratings

Some types of movies might be liked by one group of people, but hated by another. This might reflect the type of movie far more than its quality. Take, for example, horror movies — many people absolutely love them, while others hate them.

By understanding which movies were reviewed in a similar way, we can often find very similar movies.

In this exercise, you will compare movies and see whether they have received similar reviewing patterns.

The DataFrame movie_ratings_centered has been loaded with a row per movie, and the centered ratings it received as the values.

Cet exercice fait partie du cours

Building Recommendation Engines in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

from sklearn.metrics.pairwise import cosine_similarity

# Assign the arrays to variables
sw_IV = movie_ratings_centered.loc['Star Wars: Episode IV - A New Hope (1977)', :].values.reshape(1, -1)
sw_V = ____.____['Star Wars: Episode V - The Empire Strikes Back (1980)', :].____.____(1, -1)

# Find the similarity between two Star Wars movies
similarity_A = cosine_similarity(____, ____)
print(similarity_A)
Modifier et exécuter le code