org.mymedialite.ensemble
Class WeightedEnsemble

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

public class WeightedEnsemble
extends Ensemble

Combining several predictors with a weighted ensemble. This recommender does NOT support incremental updates.


Field Summary
protected  double weight_sum
          Sum of the component weights.
 java.util.List<java.lang.Double> weights
          List of component weights.
 
Fields inherited from class org.mymedialite.ensemble.Ensemble
recommenders
 
Constructor Summary
WeightedEnsemble()
           
 
Method Summary
 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
 void train()
          Learn the model parameters of the recommender from the training data
 
Methods inherited from class org.mymedialite.ensemble.Ensemble
canPredict, clone, getMaxRatingValue, getMinRatingValue, setMaxRatingValue, setMinRatingValue
 
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

weights

public java.util.List<java.lang.Double> weights
List of component weights.


weight_sum

protected double weight_sum
Sum of the component weights.

Constructor Detail

WeightedEnsemble

public WeightedEnsemble()
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
Overrides:
train in class Ensemble

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 Ensemble
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)
               throws java.io.IOException
Description copied from interface: IRecommender
Save the model parameters to a file

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

loadModel

public 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
Specified by:
loadModel in class Ensemble
Parameters:
filename - the file to read from
Throws:
java.io.IOException