org.mymedialite.itemrec
Class MostPopular

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

public class MostPopular
extends IncrementalItemRecommender

Most-popular item recommender Items are weighted by how often they have been seen in the past. This method is not personalized. This recommender supports incremental updates.


Field Summary
protected  java.util.List<java.lang.Integer> view_count
          View count
 
Fields inherited from class org.mymedialite.itemrec.ItemRecommender
feedback, maxItemID, maxUserID
 
Constructor Summary
MostPopular()
           
 
Method Summary
 void addFeedback(int user_id, int item_id)
          add a new positive feedback event
protected  void addItem(int item_id)
           
 void loadModel(java.io.BufferedReader reader)
           
 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 removeFeedback(int user_id, int item_id)
          remove all positive feedback events with that user-item combination
 void removeItem(int item_id)
          remove all feedback for one item
 void saveModel(java.io.PrintWriter writer)
           
 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.itemrec.IncrementalItemRecommender
addUser, removeUser
 
Methods inherited from class org.mymedialite.itemrec.ItemRecommender
canPredict, clone, getFeedback, setFeedback
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mymedialite.IRecommender
canPredict
 

Field Detail

view_count

protected java.util.List<java.lang.Integer> view_count
View count

Constructor Detail

MostPopular

public MostPopular()
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 ItemRecommender

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

addItem

protected void addItem(int item_id)
Overrides:
addItem in class IncrementalItemRecommender

removeItem

public void removeItem(int item_id)
Description copied from interface: IIncrementalItemRecommender
remove all feedback for one item

Specified by:
removeItem in interface IIncrementalItemRecommender
Overrides:
removeItem in class IncrementalItemRecommender
Parameters:
item_id - the item ID

addFeedback

public void addFeedback(int user_id,
                        int item_id)
Description copied from interface: IIncrementalItemRecommender
add a new positive feedback event

Specified by:
addFeedback in interface IIncrementalItemRecommender
Overrides:
addFeedback in class IncrementalItemRecommender
Parameters:
user_id - the user ID
item_id - the item ID

removeFeedback

public void removeFeedback(int user_id,
                           int item_id)
Description copied from interface: IIncrementalItemRecommender
remove all positive feedback events with that user-item combination

Specified by:
removeFeedback in interface IIncrementalItemRecommender
Overrides:
removeFeedback in class IncrementalItemRecommender
Parameters:
user_id - the user ID
item_id - the item ID

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)
Specified by:
saveModel 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

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