In this assignment, some non-personalized recommenders are implemented. In particular, they are: raw and damped item mean recommenders, simple and advanced association rule recommenders.
The input data contains the following files:
ratings.csv
contains user ratings of moviesmovies.csv
contains movie titlesmovielens.yml
is a LensKit data manifest that describes the other input files
The first two recommenders recommend items with the highest average rating.
With LensKit's scorer-model-builder architecture, the recommendation logic is required to be written only once. Two different mechanisms for computing item mean ratings can be used with the same logic.
For mean-based recommendation the classes are :
-
MeanItemBasedItemRecommender
(the item recommender) computes top-N recommendations based on mean ratings. -
ItemMeanModel
is a model class that stores precomputed item means. -
ItemMeanModelProvider
computes item mean ratings from rating data and constructs the model. It computes raw means with no damping. -
DampedItemMeanModelProvider
is an alternate builder for item mean models that computes damped means instead of raw means. It takes the damping term as a parameter.
The ItemMeanModelProvider
class computes the mean rating for each item.
The MeanItemBasedItemRecommender
class computes recommendations based on item mean
ratings. Recommendation is done as per the following steps:
- Obtain the mean rating for each item
- Order the items in decreasing order
- Return the N highest-rated items
The DampedItemMeanModelProvider
class is used to compute the damped mean rating for each item.
This formula uses a damping factor , which is the number of 'fake' ratings at the global
mean to assume for each item. In the Java code, this is available as the field
damping
.
The damped mean formula, is:
where is the global mean rating.
The association rule implementation consists of the following code:
AssociationItemBasedItemRecommender
recommends items using association rules. Unlike the mean recommenders, this recommender uses a reference item to compute the recommendations.AssociationModel
stores the association rule scores between pairs of items. You will not need to modify this class.BasicAssociationModelProvider
computes an association rule model using the basic association rule formula.
LiftAssociationModelProvider
computes an association rule model using the lift formula.
Like with the mean-based recommender, the product association scores are pre-computed and stored in a model before recommendation. The scores between all pairs of items are computed, so that the model can be used to score any item. When computing a single recommendation from the command line, this does not provide much benefit, but is useful in the general case so that the model can be used to very quickly compute many recommendations.
The BasicAssociationModelProvider
class computes the association rule scores using the following
formula:
In this case, is the reference item and
is the item to be scored.
The probabilities are estimated by counting: is the fraction of users in the system
who purchased item
;
is the fraction that purchased both
and
.
The recommendation logic in AssociationItemBasedItemRecommender
is used to recommend items
related to a given reference item. As with the mean recommender, it computes the top N
recommendations and return them.
The LiftAssociationModelProvider
recommender uses the lift metric that computes how
much more likely someone is to rate a movie when they have rated
than they would have if we do not know anything about whether they have rated
:
The following Gradle targets will do this:
runMean
runs the raw mean recommenderrunDampedMean
runs the damped mean recommenderrunBasicAssoc
runs the basic association rule recommenderrunLiftAssoc
runs the advanced (lift-based) association rule recommender
These can be run using the IntelliJ Gradle runner (open the Gradle panel, browse the tree to find a task, and double-click it), or from the command line:
./gradlew runMean
The association rule recommenders can also take the reference item ID on the command line as a
referenceItem
parameter. For example:
./gradlew runLiftAssoc -PreferenceItem=1