node-recommendations
Node.js recommendations module
Installation
$ npm install node-recommendations
Use
Create a Recommendations instance
Which allow you to pass a name (and an options object), used for namespacing within Redis so that you may have several recommendation systems in the same db.
var recommendations = ;var options = correlation: 'distance' // distance and pearson are implemented redisClient: null // [optional] your redis client;var r = recommendations;
Add people and critics
With a name and an optional id (otherwise the id is generated).
var p = r; // add a new person to the datap; // add a critic score to Joep; // another...p;
Calculate the items similitudes
This calculation is needed to get recommendations for people. The operation is costly, so run it on another machine, or in dead hours.
r;
Get a person by his name
var person = r;
Get recommendations for a person
person;
Example
var recommendations = ;var critics = 'Lisa Rose': 'Lady in the Water': 25 'Snakes on a Plane': 35 'Just My Luck': 30 'Superman Returns': 35 'You, Me and Dupree': 25 'The Night Listener': 30 'Gene Seymour': 'Lady in the Water': 30 'Snakes on a Plane': 35 'Just My Luck': 15 'Superman Returns': 50 'The Night Listener': 30 'You, Me and Dupree': 35 'Michael Phillips': 'Lady in the Water': 25 'Snakes on a Plane': 30 'Superman Returns': 35 'The Night Listener': 40 'Claudia Puig': 'Snakes on a Plane': 35 'Just My Luck': 30 'The Night Listener': 45 'Superman Returns': 40 'You, Me and Dupree': 25 'Mick LaSalle': 'Lady in the Water': 30 'Snakes on a Plane': 40 'Just My Luck': 20 'Superman Returns': 30 'The Night Listener': 30 'You, Me and Dupree': 20 'Jack Matthews': 'Lady in the Water': 30 'Snakes on a Plane': 40 'The Night Listener': 30 'Superman Returns': 50 'You, Me and Dupree': 35 'Toby': 'Snakes on a Plane':45'You, Me and Dupree':10'Superman Returns':40;var r = recommendations;for var j in critics var name = j p = r; for var i in criticsname p;r;
To do
- Automatic calculation
Author
Philmod <philippe.modard@gmail.com>