July 2018
Beginner to intermediate
146 pages
3h 39m
English
Let's first build one of the simplest collaborative filters possible. This simply takes in user_id and movie_id and outputs the mean rating for the movie by all the users who have rated it. No distinction is made between the users. In other words, the rating of each user is assigned equal weight.
It is possible that some movies are available only in the test set and not the training set (and consequentially, not in our ratings matrix). In such cases, we will just default to a rating of 3.0, like the baseline model:
#User Based Collaborative Filter using Mean Ratingsdef cf_user_mean(user_id, movie_id): #Check if movie_id exists in r_matrix if movie_id in r_matrix: #Compute the mean of all the ratings given to the movie mean_rating = ...
Read now
Unlock full access