Computing the correlation between users
In the previous recipe, we used one out of many possible distance measures to capture the distance between the movie reviews of users. This distance between two specific users is not changed even if there are five or five million other users.
In this recipe, we will compute the correlation between users in the preference space. Like distance metrics, there are many correlation metrics. The most popular of these are Pearson or Spearman correlations or cosine distance. Unlike distance metrics, the correlation will change depending on the number of users and movies.
Getting ready
We will be continuing the efforts of the previous recipes again, so make sure you understand each one.
How to do it...
The following function implements the computation of the pearson_correlation
function for two critics, which are criticA
and criticB
, and it is added to the MovieLens
class:
In [15]: def pearson_correlation(self, criticA, criticB, prefs='users'):
...: """
...: Returns...