org.mymedialite.ratingprediction
Class Constant

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

public class Constant
extends IncrementalRatingPredictor

Uses a constant rating value for prediction. This recommender supports incremental updates. Updates are just ignored, because the prediction is always the same.


Field Summary
 double constantRating
          the constant rating.
 
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
Constant()
          Default constructor.
 
Method Summary
 boolean canPredict(int user_id, int item_id)
          Check whether a useful prediction can be made for a given user-item combination.
 void loadModel(java.lang.String filename)
          Get the model parameters from a file
 double predict(int user_id, int item_id)
          Predict the rating or score for a given user-item combination.
 void saveModel(java.lang.String filename)
          Save the model parameters to a file
 java.lang.String toString()
          Return a string representation of the recommender
 void train()
          Learn the model parameters of the recommender from the training data
 
Methods inherited from class org.mymedialite.ratingprediction.IncrementalRatingPredictor
addItem, addRating, addUser, getUpdateItems, getUpdateUsers, removeItem, removeRating, removeUser, setUpdateItems, setUpdateUsers, updateRating
 
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
 

Field Detail

constantRating

public double constantRating
the constant rating.

Constructor Detail

Constant

public Constant()
Default constructor.

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

saveModel

public void saveModel(java.lang.String filename)
Description copied from interface: IRecommender
Save the model parameters to a file

Specified by:
saveModel in interface IRecommender
Specified by:
saveModel in class RatingPredictor
Parameters:
filename - the file to write to

loadModel

public void loadModel(java.lang.String filename)
Description copied from interface: IRecommender
Get the model parameters from a file

Specified by:
loadModel in interface IRecommender
Specified by:
loadModel in class RatingPredictor
Parameters:
filename - the file to read from

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.