Search⌘ K
AI Features

Finding Correlation Between the Movie Ratings

Explore how to calculate correlations between different movie ratings using Python. Learn to process rating data stored as dictionaries, handle missing reviews, apply safe evaluation with literal_eval, and use NumPy to compute correlation coefficients. This lesson shows how to generate correlation dictionaries for movies that support recommendation engine development.

We'll cover the following...

We’ve generated some random data for a few movie ratings. Let’s have a look at it.

Python 3.8
{'Terminator': {'Tom': 4.0,
'Jack': 1.5,
'Lisa': 3.0,
'Sally': 2.0},
'Terminator 2': {'Tom': 5.0,
'Jack' : 1.0,
'Lisa': 3.5,
'Sally': 2.0},
'It happened one night': {'Tom': 3.5,
'Jack': 3.5,
'Tiger': 4.0,
'Lisa': 5.0,
'Michele': 3.0,
'Sally': 4.0,},
'27 Dresses': {'Tom': 3.0,
'Jack': 3.5,
'Tiger': 3.0,
'Lisa': 5.0,
'Michele': 4.0,
'Sally': 4.0},
'Poirot': {'Tom': 4.0,
'Jack': 3.0,
'Tiger': 5.0,
'Lisa': 4.0,
'Michele': 3.5,
'Sally': 3.0,
},
'Sherlock Holmes': {'Tom': 4.0,
'Jack': 3.0,
'Tiger': 3.5,
'Lisa': 3.5,
'Sally': 2.0,
}}

The movie ...