Model
The base class for all collaborative filtering models. Not usable unles subclassed.
The Model class is accessible via the consensus module.
Methods
f __init__(self, judgeRatings=None, judges=None) ...
Initialize the model with a group of judges and their rating histories
judgeRatings is a dictionary mapping judges to their rating histories. Rating histories are represented as dictionaries mapping items to their rating by that judge. If a list judges is given as a list of judges, judgeRatings will be initialized with empty rating histories.
f similarity(self, j1, j2, neutralScore=0, items=None) ...
Calculate the similarity of judges j1 and j2.
If neutralScore is given, it is the midpoint of the rating scale being used.
If a list of items is given, the judges' ratings for only those items will be considered when determining similarity.
f getNeighbors(self, judge, limit=None, threshold=None, neutralScore=0, items=None) ...
Get a sorted list of neighbors for the given judge, where neighbors are defined as judges with preferences most similar to the given judge.
judge is the user for whom a list of neighbors will be calculated.
If limit is given, it will limit the length of the list of neighbors being returned. If threshold is given, it specifies the cutoff point for which neighbors will be included. This will be highly dependent on which model is chosen. A lower threshold will result in fewer neighbors being returned.
neutralScore and items are as defined in Model.similarity .
f getRecommendations(self, judge, limit=None, neutralScore=0, items=None) ...
Return a list of items and their scores (how relevant they are to the given judge), sorted from most recommended to least recommended.
limit , neutralScore , and items are all as defined in Model.getNeighbors .
See the source for more information.