org.mymedialite.ratingprediction
Class IncrementalRatingPredictor

java.lang.Object
  extended by org.mymedialite.ratingprediction.RatingPredictor
      extended by org.mymedialite.ratingprediction.IncrementalRatingPredictor
All Implemented Interfaces:
java.lang.Cloneable, IRecommender, IIncrementalRatingPredictor, IRatingPredictor
Direct Known Subclasses:
Constant, EntityAverage, GlobalAverage, KNN, MatrixFactorization, UserItemBaseline

public abstract class IncrementalRatingPredictor
extends RatingPredictor
implements IIncrementalRatingPredictor

Base class for rating predictors that support incremental training


Field Summary
protected  boolean updateItems
           
protected  boolean updateUsers
           
 
Fields inherited from class org.mymedialite.ratingprediction.RatingPredictor
maxItemID, maxRating, maxUserID, minRating, ratings
 
Constructor Summary
IncrementalRatingPredictor()
          Default constructor.
 
Method Summary
 void addItem(int itemId)
           
 void addRating(int userId, int itemId, double rating)
          Add a new rating and perform incremental training
 void addUser(int userId)
           
 boolean getUpdateItems()
          true if items shall be updated when doing incremental updates.
 boolean getUpdateUsers()
          true if users shall be updated when doing incremental updates.
 void removeItem(int itemId)
          Remove an item from the recommender model, and delete all ratings of this item It is up to the recommender implementor whether there should be model updates after this action, both options are valid.
 void removeRating(int userId, int itemId)
          Remove an existing rating and perform "incremental" training
 void removeUser(int userId)
          Remove a user from the recommender model, and delete all their ratings It is up to the recommender implementor whether there should be model updates after this action, both options are valid.
 void setUpdateItems(boolean updateItems)
          Set to true if items shall be updated when doing incremental updates.
 void setUpdateUsers(boolean updateUsers)
          Set to true if users shall be updated when doing incremental updates.
 void updateRating(int userId, int itemId, double rating)
          Update an existing rating and perform incremental training
 
Methods inherited from class org.mymedialite.ratingprediction.RatingPredictor
canPredict, clone, getMaxRating, getMinRating, getRatings, loadModel, predict, saveModel, setMaxRating, setMinRating, setRatings, toString, train
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mymedialite.ratingprediction.IRatingPredictor
getMaxRating, getMinRating, setMaxRating, setMinRating
 
Methods inherited from interface org.mymedialite.IRecommender
canPredict, loadModel, predict, saveModel, toString, train
 

Field Detail

updateUsers

protected boolean updateUsers

updateItems

protected boolean updateItems
Constructor Detail

IncrementalRatingPredictor

public IncrementalRatingPredictor()
Default constructor.

Method Detail

addRating

public void addRating(int userId,
                      int itemId,
                      double rating)
Description copied from interface: IIncrementalRatingPredictor
Add a new rating and perform incremental training

Specified by:
addRating in interface IIncrementalRatingPredictor
Parameters:
userId - the ID of the user who performed the rating
itemId - the ID of the rated item
rating - the rating value

updateRating

public void updateRating(int userId,
                         int itemId,
                         double rating)
                  throws java.lang.IllegalArgumentException
Description copied from interface: IIncrementalRatingPredictor
Update an existing rating and perform incremental training

Specified by:
updateRating in interface IIncrementalRatingPredictor
Parameters:
userId - the ID of the user who performed the rating
itemId - the ID of the rated item
rating - the rating value
Throws:
java.lang.IllegalArgumentException

removeRating

public void removeRating(int userId,
                         int itemId)
Description copied from interface: IIncrementalRatingPredictor
Remove an existing rating and perform "incremental" training

Specified by:
removeRating in interface IIncrementalRatingPredictor
Parameters:
userId - the ID of the user who performed the rating
itemId - the ID of the rated item

addUser

public void addUser(int userId)

addItem

public void addItem(int itemId)

removeUser

public void removeUser(int userId)
Description copied from interface: IIncrementalRatingPredictor
Remove a user from the recommender model, and delete all their ratings It is up to the recommender implementor whether there should be model updates after this action, both options are valid.

Specified by:
removeUser in interface IIncrementalRatingPredictor
Parameters:
userId - the ID of the user to be removed

removeItem

public void removeItem(int itemId)
Description copied from interface: IIncrementalRatingPredictor
Remove an item from the recommender model, and delete all ratings of this item It is up to the recommender implementor whether there should be model updates after this action, both options are valid.

Specified by:
removeItem in interface IIncrementalRatingPredictor
Parameters:
itemId - the ID of the user to be removed

getUpdateUsers

public boolean getUpdateUsers()
Description copied from interface: IIncrementalRatingPredictor
true if users shall be updated when doing incremental updates.

Specified by:
getUpdateUsers in interface IIncrementalRatingPredictor

setUpdateUsers

public void setUpdateUsers(boolean updateUsers)
Description copied from interface: IIncrementalRatingPredictor
Set to true if users shall be updated when doing incremental updates. Set to false if you do not want any updates to the user model parameters when doing incremental updates. Default should be true.

Specified by:
setUpdateUsers in interface IIncrementalRatingPredictor

getUpdateItems

public boolean getUpdateItems()
Description copied from interface: IIncrementalRatingPredictor
true if items shall be updated when doing incremental updates.

Specified by:
getUpdateItems in interface IIncrementalRatingPredictor

setUpdateItems

public void setUpdateItems(boolean updateItems)
Description copied from interface: IIncrementalRatingPredictor
Set to true if items shall be updated when doing incremental updates. Set to false if you do not want any updates to the item model parameters when doing incremental updates. Default should true.

Specified by:
setUpdateItems in interface IIncrementalRatingPredictor