...

/

Building the Recommendation Engine

Building the Recommendation Engine

Learn how to build a recommendation engine using the correlation between the datasets.

Using correlation to rate movies

Say we have movie A and movie B. We’ve given a rating of 4.0 to movie A and the correlation between A and B is 1.0. Since 1.0 is the highest value, the movies are perfectly correlated, and the person who likes A should also like the B.

So our estimated score for B would be:

4.01.0=4.04.0 * 1.0 = 4.0

What if the correlation between movie A and movie B was -0.5? Our anticipated rating would be -2.0, which is very low. This means that those who enjoyed movie A probably wouldn’t like movie B.

To refresh, the steps are:

  1. Look at the scores of the movies we’ve rated.

  2. Check the rate movie’s correlation to the movies we haven’t rated.

  3. Find our anticipated score.

  4. Repeat steps 1–3 for all the three movies that we’ve rated.

Before we start on that, we’ve cleaned up corr_dict.py for users.

Press + to interact
{
"27 Dresses": {"Poirot": -0.30434782608695654, "Terminator 2": -0.13998740998253317,\
"It happened one night": 0.5791405068790082, "Sherlock Holmes": -0.2758386421836852\
6, "Terminator": -0.16796775328675631},
"It happened one night": {"Terminator 2": 0.25275763912268084, "27 Dresses": 0.57914\
05068790082, "Terminator": 0.42437890059987993, "Sherlock Holmes": 0.0, "Poirot": 0.\
2895702534395041},
"Terminator 2": {"Poirot": 0.87845527687491742, "27 Dresses": -0.13998740998253317, \
"It happened one night": 0.25275763912268084, "Sherlock Holmes": 0.73889576951817515\
, "Terminator": 0.92184471452179317},
"Terminator": {"Terminator 2": 0.92184471452179317, "27 Dresses": -0.167967753286756\
31, "It happened one night": 0.42437890059987993, "Sherlock Holmes": 0.7702079842374\
0755, "Poirot": 0.72664794872022465},
"Poirot": {"Terminator 2": 0.87845527687491742, "27 Dresses": -0.30434782608695654, \
"It happened one night": 0.2895702534395041, "Sherlock Holmes": 0.6698938453032357, \
"Terminator": 0.72664794872022465},
"Sherlock Holmes": {"Poirot": 0.6698938453032357, "Terminator 2": 0.7388957695181751\
5, "27 Dresses": -0.27583864218368526, "It happened one night": 0.0, "Terminator": 0\
.77020798423740755}
}

Let’s start with 27 dresses and try to calculate its anticipated score:

My Movie [A] My rating for movie [B] Correlation of [B] with 27 dresses [C]
...