org.mymedialite.ratingprediction
Class ItemAverage

java.lang.Object
  extended by org.mymedialite.ratingprediction.RatingPredictor
      extended by org.mymedialite.ratingprediction.IncrementalRatingPredictor
          extended by org.mymedialite.ratingprediction.EntityAverage
              extended by org.mymedialite.ratingprediction.ItemAverage
All Implemented Interfaces:
java.lang.Cloneable, IRecommender, IIncrementalRatingPredictor, IRatingPredictor

public class ItemAverage
extends EntityAverage

Uses the average rating value of an item for prediction. This engine does NOT support online updates.


Field Summary
 
Fields inherited from class org.mymedialite.ratingprediction.EntityAverage
entity_averages, global_average
 
Fields inherited from class org.mymedialite.ratingprediction.IncrementalRatingPredictor
updateItems, updateUsers
 
Fields inherited from class org.mymedialite.ratingprediction.RatingPredictor
maxItemID, maxRating, maxUserID, minRating, ratings
 
Constructor Summary
ItemAverage()
           
 
Method Summary
 void addItem(int item_id)
           
 void addRating(int user_id, int item_id, double rating)
          Add a new rating and perform incremental training
 boolean canPredict(int user_id, int item_id)
          Check whether a useful prediction can be made for a given user-item combination.
 double predict(int user_id, int item_id)
          Predict the rating or score for a given user-item combination.
 void removeItem(int item_id)
          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 user_id, int item_id)
          Remove an existing rating and perform "incremental" training
 java.lang.String toString()
          Return a string representation of the recommender
 void train()
          Learn the model parameters of the recommender from the training data
 void updateRating(int user_id, int item_id, double rating)
          Update an existing rating and perform incremental training
 
Methods inherited from class org.mymedialite.ratingprediction.EntityAverage
get, loadModel, retrain, saveModel, train
 
Methods inherited from class org.mymedialite.ratingprediction.IncrementalRatingPredictor
addUser, getUpdateItems, getUpdateUsers, removeUser, setUpdateItems, setUpdateUsers
 
Methods inherited from class org.mymedialite.ratingprediction.RatingPredictor
clone, getMaxRating, getMinRating, getRatings, setMaxRating, setMinRating, setRatings
 
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
 

Constructor Detail

ItemAverage

public ItemAverage()
Method Detail

train

public void train()
Description copied from interface: IRecommender
Learn the model parameters of the recommender from the training data

Specified by:
train in interface IRecommender
Specified by:
train in class RatingPredictor

canPredict

public boolean canPredict(int user_id,
                          int item_id)
Description copied from interface: IRecommender
Check whether a useful prediction can be made for a given user-item combination.

Specified by:
canPredict in interface IRecommender
Overrides:
canPredict in class RatingPredictor
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
true if a useful prediction can be made, false otherwise

predict

public double predict(int user_id,
                      int item_id)
Description copied from interface: IRecommender
Predict the rating or score for a given user-item combination.

Specified by:
predict in interface IRecommender
Specified by:
predict in class RatingPredictor
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the predicted score/rating for the given user-item combination

addRating

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

Specified by:
addRating in interface IIncrementalRatingPredictor
Overrides:
addRating in class IncrementalRatingPredictor
Parameters:
user_id - the ID of the user who performed the rating
item_id - the ID of the rated item
rating - the rating value

updateRating

public void updateRating(int user_id,
                         int item_id,
                         double rating)
Description copied from interface: IIncrementalRatingPredictor
Update an existing rating and perform incremental training

Specified by:
updateRating in interface IIncrementalRatingPredictor
Overrides:
updateRating in class IncrementalRatingPredictor
Parameters:
user_id - the ID of the user who performed the rating
item_id - the ID of the rated item
rating - the rating value

removeRating

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

Specified by:
removeRating in interface IIncrementalRatingPredictor
Overrides:
removeRating in class IncrementalRatingPredictor
Parameters:
user_id - the ID of the user who performed the rating
item_id - the ID of the rated item

addItem

public void addItem(int item_id)
Overrides:
addItem in class IncrementalRatingPredictor

removeItem

public void removeItem(int item_id)
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
Overrides:
removeItem in class IncrementalRatingPredictor
Parameters:
item_id - the ID of the user to be removed

toString

public java.lang.String toString()
Description copied from interface: IRecommender
Return a string representation of the recommender

Specified by:
toString in interface IRecommender
Overrides:
toString in class RatingPredictor
Returns:
the class name and all hyperparameters, separated by space characters.