org.mymedialite.ratingprediction
Class RatingPredictor

java.lang.Object
  extended by org.mymedialite.ratingprediction.RatingPredictor
All Implemented Interfaces:
java.lang.Cloneable, IRecommender, IRatingPredictor
Direct Known Subclasses:
BiPolarSlopeOne, CoClustering, FactorWiseMatrixFactorization, IncrementalRatingPredictor, Random, SlopeOne, TimeAwareRatingPredictor

public abstract class RatingPredictor
extends java.lang.Object
implements IRatingPredictor

Abstract class for rating predictors that keep the rating data in memory for training (and possibly prediction)


Field Summary
 int maxItemID
          Maximum item ID
 double maxRating
          The maximum rating value
 int maxUserID
          Maximum user ID
 double minRating
          The minimum rating value
protected  IRatings ratings
          The rating data
 
Constructor Summary
RatingPredictor()
           
 
Method Summary
 boolean canPredict(int user_id, int item_id)
          Check whether a useful prediction can be made for a given user-item combination.
 RatingPredictor clone()
           
 double getMaxRating()
          Get the max rating value.
 double getMinRating()
          Get the min rating value.
 IRatings getRatings()
           
abstract  void loadModel(java.lang.String filename)
          Get the model parameters from a file
abstract  double predict(int user_id, int item_id)
          Predict the rating or score for a given user-item combination.
abstract  void saveModel(java.lang.String filename)
          Save the model parameters to a file
 void setMaxRating(double max_rating)
          Set the max rating value.
 void setMinRating(double min_rating)
          Set the min rating value.
 void setRatings(IRatings ratings)
           
 java.lang.String toString()
          Return a string representation of the recommender
abstract  void train()
          Learn the model parameters of the recommender from the training data
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxUserID

public int maxUserID
Maximum user ID


maxItemID

public int maxItemID
Maximum item ID


maxRating

public double maxRating
The maximum rating value


minRating

public double minRating
The minimum rating value


ratings

protected IRatings ratings
The rating data

Constructor Detail

RatingPredictor

public RatingPredictor()
Method Detail

getMaxRating

public double getMaxRating()
Description copied from interface: IRatingPredictor
Get the max rating value.

Specified by:
getMaxRating in interface IRatingPredictor

setMaxRating

public void setMaxRating(double max_rating)
Description copied from interface: IRatingPredictor
Set the max rating value.

Specified by:
setMaxRating in interface IRatingPredictor

getMinRating

public double getMinRating()
Description copied from interface: IRatingPredictor
Get the min rating value.

Specified by:
getMinRating in interface IRatingPredictor

setMinRating

public void setMinRating(double min_rating)
Description copied from interface: IRatingPredictor
Set the min rating value.

Specified by:
setMinRating in interface IRatingPredictor

getRatings

public IRatings getRatings()

setRatings

public void setRatings(IRatings ratings)

clone

public RatingPredictor clone()
                      throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

predict

public abstract 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
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the predicted score/rating for the given user-item combination

train

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

Specified by:
train in interface IRecommender

saveModel

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

Specified by:
saveModel in interface IRecommender
Parameters:
filename - the file to write to
Throws:
java.io.IOException

loadModel

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

Specified by:
loadModel in interface IRecommender
Parameters:
filename - the file to read from
Throws:
java.io.IOException

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
Parameters:
user_id - the user ID
item_id - the item ID
Returns:
true if a useful prediction can be made, false otherwise

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 java.lang.Object
Returns:
the class name and all hyperparameters, separated by space characters.