ÎncepețiÎncepe gratuit

Making recommendations with TF-IDF

In the last exercise you pre-calculated the similarity ratings between all movies in the dataset based on their plots transformed by TF-IDF. Now you will put these similarity ratings in a DataFrame for ease of use. Then you will use this new DataFrame to suggest a movie recommendation.

The cosine_similarity_array containing a matrix of the similarity values between all movies that you created in the last exercise has been loaded for you. The tfidf_summary_df DataFrame containing the movies and their TF-IDF features is also available.

Acest exercițiu face parte din cursul

Building Recommendation Engines in Python

Vezi cursul

Exercițiu interactiv practic

Încearcă acest exercițiu completând acest cod de exemplu.

# Wrap the preloaded array in a DataFrame
cosine_similarity_df = pd.____(____, index=tfidf_summary_df.index, columns=tfidf_summary_df.index)

# Find the values for the movie Rio
cosine_similarity_series = ____.____['Rio']

# Sort these values highest to lowest
ordered_similarities = cosine_similarity_series.____(____)

# Print the results
print(____)
Editează și rulează codul