|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.itemrec.ItemRecommender
org.mymedialite.itemrec.BPRLinear
public class BPRLinear
Linear model optimized for BPR. Literature: Zeno Gantner, Lucas Drumond, Christoph Freudenthaler, Steffen Rendle, Lars Schmidt-Thieme: Learning Attribute-to-Feature Mappings for Cold-Start Recommendations. ICDM 2011. http://www.ismll.uni-hildesheim.de/pub/pdfs/Gantner_et_al2010Mapping.pdf This recommender does NOT support incremental updates.
Field Summary | |
---|---|
int |
fastSamplingMemoryLimit
Fast sampling memory limit, in MiB. |
double |
initMean
mean of the Gaussian distribution used to initialize the features. |
double |
initStdev
standard deviation of the normal distribution used to initialize the features. |
protected int |
iterationLength
One iteration = iterationLength * number of entries in the training matrix. |
double |
learnRate
Learning rate alpha. |
int |
numIter
Number of iterations over the training data. |
double |
regularization
Regularization parameter. |
Fields inherited from class org.mymedialite.itemrec.ItemRecommender |
---|
feedback, maxItemID, maxUserID |
Constructor Summary | |
---|---|
BPRLinear()
|
Method Summary | |
---|---|
double |
computeLoss()
Compute the current loss of the model |
SparseBooleanMatrix |
getItemAttributes()
Getter for binary item attributes |
int |
getNumIter()
Get the number of iterations to run the training |
void |
iterate()
Perform one iteration of stochastic gradient ascent over the training data. |
void |
loadModel(java.io.BufferedReader reader)
|
void |
loadModel(java.lang.String filename)
Get the model parameters from a file |
int |
numItemAttributes()
Getter for number of binary item attributes |
double |
predict(int user_id,
int item_id)
Predict the rating or score for a given user-item combination. |
protected void |
sampleItemPair(org.mymedialite.itemrec.BPRLinear.SampleTriple t)
Sample a pair of items, given a user. |
protected void |
sampleTriple(org.mymedialite.itemrec.BPRLinear.SampleTriple t)
Sample a triple for BPR learning. |
protected int |
sampleUser()
Sample a user that has viewed at least one and not all items. |
void |
saveModel(java.io.PrintWriter writer)
|
void |
saveModel(java.lang.String filename)
Save the model parameters to a file |
void |
setItemAttributes(SparseBooleanMatrix itemAttributes)
Setter for binary item attributes |
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 |
protected void |
updateFeatures(org.mymedialite.itemrec.BPRLinear.SampleTriple t)
Modified feature update method that exploits attribute sparsity. |
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 |
---|
protected int iterationLength
public int numIter
public int fastSamplingMemoryLimit
public double initMean
public double initStdev
public double learnRate
public double regularization
Constructor Detail |
---|
public BPRLinear()
Method Detail |
---|
public SparseBooleanMatrix getItemAttributes()
IItemAttributeAwareRecommender
getItemAttributes
in interface IItemAttributeAwareRecommender
public void setItemAttributes(SparseBooleanMatrix itemAttributes)
IItemAttributeAwareRecommender
setItemAttributes
in interface IItemAttributeAwareRecommender
public int numItemAttributes()
IItemAttributeAwareRecommender
numItemAttributes
in interface IItemAttributeAwareRecommender
public void setNumIter(int numIter)
IIterativeModel
setNumIter
in interface IIterativeModel
public int getNumIter()
IIterativeModel
getNumIter
in interface IIterativeModel
public void train()
IRecommender
train
in interface IRecommender
train
in class ItemRecommender
public void iterate()
iterate
in interface IIterativeModel
protected void sampleItemPair(org.mymedialite.itemrec.BPRLinear.SampleTriple t)
t
- a SampleTriple specifying a user IDprotected int sampleUser()
protected void sampleTriple(org.mymedialite.itemrec.BPRLinear.SampleTriple t)
t
- the SampleTriple to configureprotected void updateFeatures(org.mymedialite.itemrec.BPRLinear.SampleTriple t)
t
- a SampleTriple specifying the user ID and the first and second item IDspublic double predict(int user_id, int item_id)
IRecommender
predict
in interface IRecommender
predict
in class ItemRecommender
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 ItemRecommender
filename
- the file to write to
java.io.IOException
public void saveModel(java.io.PrintWriter writer)
saveModel
in class ItemRecommender
public void loadModel(java.lang.String filename) throws java.io.IOException
IRecommender
loadModel
in interface IRecommender
loadModel
in class ItemRecommender
filename
- the file to read from
java.io.IOException
public void loadModel(java.io.BufferedReader reader) throws java.io.IOException
loadModel
in class ItemRecommender
java.io.IOException
public double computeLoss()
IIterativeModel
computeLoss
in interface IIterativeModel
public java.lang.String toString()
IRecommender
toString
in interface IRecommender
toString
in class ItemRecommender
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |