org.mymedialite.ensemble
Class Ensemble

java.lang.Object
  extended by org.mymedialite.ensemble.Ensemble
All Implemented Interfaces:
java.lang.Cloneable, IRecommender
Direct Known Subclasses:
WeightedEnsemble

public abstract class Ensemble
extends java.lang.Object
implements IRecommender

Abstract class for combining several prediction methods.


Field Summary
 java.util.List<IRecommender> recommenders
          List of recommenders.
 
Constructor Summary
Ensemble()
           
 
Method Summary
 boolean canPredict(int user_id, int item_id)
          Check whether a useful prediction can be made for a given user-item combination.
 java.lang.Object clone()
          Create a shallow copy of the object.
 double getMaxRatingValue()
          The max rating value.
 double getMinRatingValue()
          The min rating value.
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 setMaxRatingValue(double value)
           
 void setMinRatingValue(double value)
           
 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, toString, wait, wait, wait
 
Methods inherited from interface org.mymedialite.IRecommender
toString
 

Field Detail

recommenders

public java.util.List<IRecommender> recommenders
List of recommenders.

Constructor Detail

Ensemble

public Ensemble()
Method Detail

clone

public java.lang.Object clone()
Create a shallow copy of the object.

Overrides:
clone in class java.lang.Object

getMaxRatingValue

public double getMaxRatingValue()
The max rating value.

Returns:
The max rating value

setMaxRatingValue

public void setMaxRatingValue(double value)

getMinRatingValue

public double getMinRatingValue()
The min rating value.

Returns:
The min rating value

setMinRatingValue

public void setMinRatingValue(double value)

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

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

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

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