|
|||||||||
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.MatrixFactorization
org.mymedialite.ratingprediction.BiasedMatrixFactorization
public class BiasedMatrixFactorization
Matrix factorization engine with explicit user and item bias. Per default optimizes for RMSE. Set OptimizeMAE to true if you want to optimize for MAE. Literature: Ruslan Salakhutdinov, Andriy Mnih: Probabilistic Matrix Factorization. NIPS 2007. http://www.mit.edu/~rsalakhu/papers/nips07_pmf.pdf Steffen Rendle, Lars Schmidt-Thieme: Online-Updating Regularized Kernel Matrix Factorization Models for Large-Scale Recommender Systems. RecSys 2008. http://www.ismll.uni-hildesheim.de/pub/pdfs/Rendle2008-Online_Updating_Regularized_Kernel_Matrix_Factorization_Models.pdf This recommender supports incremental updates.
Field Summary | |
---|---|
double |
biasReg
Regularization constant for the bias terms. |
boolean |
boldDriver
Use bold driver heuristics for learning rate adaption. |
protected double[] |
itemBias
The item biases |
protected double |
last_loss
Loss for the last iteration, used by bold driver heuristics |
boolean |
optimizeMAE
If set to true, optimize model for MAE instead of RMSE. |
double |
regI
Regularization constant for the item factors. |
double |
regU
Regularization constant for the user factors. |
protected double[] |
userBias
The user biases |
Fields inherited from class org.mymedialite.ratingprediction.MatrixFactorization |
---|
globalBias, initMean, initStDev, itemFactors, learnRate, numFactors, numIter, regularization, userFactors |
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 | |
---|---|
BiasedMatrixFactorization()
Default constructor |
Method Summary | |
---|---|
void |
addItem(int item_id)
|
void |
addUser(int user_id)
|
protected void |
initModel()
Initialize the model data structure. |
void |
iterate()
Run one iteration (= pass over the training data) |
protected void |
iterate(java.util.List<java.lang.Integer> rating_indices,
boolean update_user,
boolean update_item)
Iterate once over rating data and adjust corresponding factors (stochastic gradient descent). |
protected void |
iterateRMSE(java.util.List<java.lang.Integer> rating_indices,
boolean update_user,
boolean update_item)
|
void |
loadModel(java.lang.String filename)
Get the model parameters from a file |
double |
predict(int user_id,
int item_id)
Predict the rating of a given user for a given item. |
void |
removeItem(int item_id)
Remove an item from the recommender model, and delete all ratings of this item It is up to the recommender implementor whether there should be model updates after this action, both options are valid. |
void |
removeUser(int user_id)
Remove a user from the recommender model, and delete all their ratings It is up to the recommender implementor whether there should be model updates after this action, both options are valid. |
void |
retrainItem(int item_id)
Updates the latent factors of an item. |
void |
retrainUser(int user_id)
Updates the latent factors on a user. |
void |
saveModel(java.lang.String filename)
Save the model parameters to a file |
void |
setRegularization(double regularization)
Set the regularization parameters. |
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.ratingprediction.MatrixFactorization |
---|
addRating, computeLoss, getNumIter, predict, removeRating, setNumIter, updateRating |
Methods inherited from class org.mymedialite.ratingprediction.IncrementalRatingPredictor |
---|
getUpdateItems, getUpdateUsers, 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 biasReg
public double regU
public double regI
protected double[] userBias
protected double[] itemBias
public boolean optimizeMAE
public boolean boldDriver
protected double last_loss
Constructor Detail |
---|
public BiasedMatrixFactorization()
Method Detail |
---|
public void setRegularization(double regularization)
regularization
- protected void initModel()
MatrixFactorization
initModel
in class MatrixFactorization
public void train()
IRecommender
train
in interface IRecommender
train
in class MatrixFactorization
public void iterate()
IIterativeModel
iterate
in interface IIterativeModel
iterate
in class MatrixFactorization
protected void iterate(java.util.List<java.lang.Integer> rating_indices, boolean update_user, boolean update_item)
MatrixFactorization
iterate
in class MatrixFactorization
rating_indices
- a list of indices pointing to the ratings to iterate overupdate_user
- true if user factors to be updatedupdate_item
- true if item factors to be updatedprotected void iterateRMSE(java.util.List<java.lang.Integer> rating_indices, boolean update_user, boolean update_item)
public double predict(int user_id, int item_id)
MatrixFactorization
predict
in interface IRecommender
predict
in class MatrixFactorization
user_id
- the user IDitem_id
- the item ID
public void saveModel(java.lang.String filename) throws java.io.IOException
IRecommender
saveModel
in interface IRecommender
saveModel
in class MatrixFactorization
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 MatrixFactorization
filename
- the file to read from
java.io.IOException
public void addUser(int user_id)
addUser
in class MatrixFactorization
public void addItem(int item_id)
addItem
in class MatrixFactorization
public void retrainUser(int user_id)
retrainUser
in class MatrixFactorization
user_id
- the user IDpublic void retrainItem(int item_id)
retrainItem
in class MatrixFactorization
item_id
- the item IDpublic void removeUser(int user_id)
removeUser
in interface IIncrementalRatingPredictor
removeUser
in class MatrixFactorization
user_id
- the ID of the user to be removedpublic void removeItem(int item_id)
removeItem
in interface IIncrementalRatingPredictor
removeItem
in class MatrixFactorization
item_id
- the ID of the user to be removedpublic java.lang.String toString()
toString
in interface IRecommender
toString
in class MatrixFactorization
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |