|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.ratingprediction.RatingPredictor
org.mymedialite.ratingprediction.IncrementalRatingPredictor
org.mymedialite.ratingprediction.UserItemBaseline
public class UserItemBaseline
Baseline method for rating prediction Uses the average rating value, plus a regularized user and item bias for prediction. The method is described in section 2.1 of Yehuda Koren: Factor in the Neighbors: Scalable and Accurate Collaborative Filtering, Transactions on Knowledge Discovery from Data (TKDD), 2009. One difference is that we support several iterations of alternating optimization, instead of just one. This recommender supports incremental updates.
Field Summary | |
---|---|
protected double |
globalAverage
The global rating average |
protected double[] |
itemBiases
The item biases |
int |
numIter
The number of iterations |
double |
regI
Regularization parameter for the item biases |
double |
regU
Regularization parameter for the user biases |
protected double[] |
userBiases
The user biases |
Fields inherited from class org.mymedialite.ratingprediction.IncrementalRatingPredictor |
---|
updateItems, updateUsers |
Fields inherited from class org.mymedialite.ratingprediction.RatingPredictor |
---|
maxItemID, maxRating, maxUserID, minRating, ratings |
Constructor Summary | |
---|---|
UserItemBaseline()
Default constructor |
Method Summary | |
---|---|
void |
addItem(int itemID)
|
void |
addRating(int userID,
int itemID,
double rating)
Add a new rating and perform incremental training |
void |
addUser(int userID)
|
double |
computeLoss()
Compute the current loss of the model |
int |
getNumIter()
Get the number of iterations to run the training |
void |
iterate()
Run one iteration (= pass over the training data) |
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 |
removeRating(int userID,
int itemID)
Remove an existing rating and perform "incremental" training |
protected void |
retrainItem(int itemID)
|
protected void |
retrainUser(int userID)
|
void |
saveModel(java.lang.String filename)
Save the model parameters to a file |
void |
setNumIter(int numIter)
Set the number of iterations to run the training |
java.lang.String |
toString()
Return a string representation of the recommender |
void |
train()
Learn the model parameters of the recommender from the training data |
void |
updateRating(int userID,
int itemID,
double rating)
Update an existing rating and perform incremental training |
Methods inherited from class org.mymedialite.ratingprediction.IncrementalRatingPredictor |
---|
getUpdateItems, getUpdateUsers, removeItem, removeUser, setUpdateItems, setUpdateUsers |
Methods inherited from class org.mymedialite.ratingprediction.RatingPredictor |
---|
canPredict, clone, getMaxRating, getMinRating, getRatings, setMaxRating, setMinRating, setRatings |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.mymedialite.ratingprediction.IRatingPredictor |
---|
getMaxRating, getMinRating, setMaxRating, setMinRating |
Methods inherited from interface org.mymedialite.IRecommender |
---|
canPredict |
Field Detail |
---|
public double regU
public double regI
public int numIter
protected double globalAverage
protected double[] userBiases
protected double[] itemBiases
Constructor Detail |
---|
public UserItemBaseline()
Method Detail |
---|
public int getNumIter()
IIterativeModel
getNumIter
in interface IIterativeModel
public void setNumIter(int numIter)
IIterativeModel
setNumIter
in interface IIterativeModel
numIter
- The number of iterationspublic void iterate()
IIterativeModel
iterate
in interface IIterativeModel
public double predict(int userID, int itemID)
IRecommender
predict
in interface IRecommender
predict
in class RatingPredictor
userID
- the user IDitemID
- the item ID
public void train()
IRecommender
train
in interface IRecommender
train
in class RatingPredictor
protected void retrainUser(int userID)
protected void retrainItem(int itemID)
public void addRating(int userID, int itemID, double rating)
IIncrementalRatingPredictor
addRating
in interface IIncrementalRatingPredictor
addRating
in class IncrementalRatingPredictor
userID
- the ID of the user who performed the ratingitemID
- the ID of the rated itemrating
- the rating valuepublic void updateRating(int userID, int itemID, double rating)
IIncrementalRatingPredictor
updateRating
in interface IIncrementalRatingPredictor
updateRating
in class IncrementalRatingPredictor
userID
- the ID of the user who performed the ratingitemID
- the ID of the rated itemrating
- the rating valuepublic void removeRating(int userID, int itemID)
IIncrementalRatingPredictor
removeRating
in interface IIncrementalRatingPredictor
removeRating
in class IncrementalRatingPredictor
userID
- the ID of the user who performed the ratingitemID
- the ID of the rated itempublic void addUser(int userID)
addUser
in class IncrementalRatingPredictor
public void addItem(int itemID)
addItem
in class IncrementalRatingPredictor
public void saveModel(java.lang.String filename) throws java.io.IOException
IRecommender
saveModel
in interface IRecommender
saveModel
in class RatingPredictor
filename
- the file to write to
java.io.IOException
public void loadModel(java.lang.String filename) throws java.io.IOException
IRecommender
loadModel
in interface IRecommender
loadModel
in class RatingPredictor
filename
- the file to read from
java.io.IOException
public double computeLoss()
IIterativeModel
computeLoss
in interface IIterativeModel
public java.lang.String toString()
IRecommender
toString
in interface IRecommender
toString
in class RatingPredictor
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |