org.mymedialite.itemrec
Class Perfect

java.lang.Object
  extended by org.mymedialite.itemrec.ItemRecommender
      extended by org.mymedialite.itemrec.Perfect
All Implemented Interfaces:
java.lang.Cloneable, IRecommender

public class Perfect
extends ItemRecommender

Perfect Item Recommender which simply reflects the supplied test results. For use as experimental baseline or for debugging.


Field Summary
 
Fields inherited from class org.mymedialite.itemrec.ItemRecommender
feedback, maxItemID, maxUserID
 
Constructor Summary
Perfect(IPosOnlyFeedback testData)
           
 
Method Summary
 void loadModel(java.io.BufferedReader reader)
           
 void loadModel(java.lang.String filename)
          Get the model parameters from a file
 double predict(int userId, int itemId)
          Predict the rating or score for a given user-item combination.
 void saveModel(java.io.PrintWriter writer)
           
 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.itemrec.ItemRecommender
canPredict, clone, getFeedback, setFeedback, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Perfect

public Perfect(IPosOnlyFeedback testData)
Method Detail

predict

public double predict(int userId,
                      int itemId)
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 ItemRecommender
Parameters:
userId - the user ID
itemId - the item ID
Returns:
the predicted score/rating for the given user-item combination

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 ItemRecommender

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 ItemRecommender
Parameters:
filename - the file to read from
Throws:
java.io.IOException

loadModel

public void loadModel(java.io.BufferedReader reader)
               throws java.io.IOException
Specified by:
loadModel in class ItemRecommender
Throws:
java.io.IOException

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 ItemRecommender
Parameters:
filename - the file to write to
Throws:
java.io.IOException

saveModel

public void saveModel(java.io.PrintWriter writer)
               throws java.io.IOException
Specified by:
saveModel in class ItemRecommender
Throws:
java.io.IOException