August 2015
Beginner to intermediate
294 pages
5h 20m
English
User-based collaborative filtering finds the similarities between users, and then using these similarities between users, a recommendation is made.
Item-based collaborative filtering finds the similarities between items. This is then used to find new recommendations for a user.
To begin with item-based collaborative filtering, we'll first have to invert our dataset by putting the movies in the first layer, followed by the users in the second layer:
>>> def transform_prefs(prefs): result={} for person in prefs: for item in prefs[person]: result.setdefault(item,{}) # Flip item and person result[item][person]=prefs[person][item] return result {'Avenger: Age of Ultron': {'Jill': 7.0,'Julia': 10.0, 'Max': ...
Read now
Unlock full access