BPRMF Class Reference

Matrix factorization model for item prediction optimized using BPR-Opt. More...

Inheritance diagram for BPRMF:
MF IIterativeModel ItemRecommender IIterativeModel IRecommender IItemRecommender IRecommender IRecommender

List of all members.

Public Member Functions

override void AddFeedback (int user_id, int item_id)
override void AddItem (int item_id)
override void AddUser (int user_id)
virtual bool CanPredict (int user_id, int item_id)
 Check whether a useful prediction can be made for a given user-item combination.
Object Clone ()
 create a shallow copy of the object
override double ComputeFit ()
 Compute the fit (AUC on training data).
override void Iterate ()
 Perform one iteration of stochastic gradient ascent over the training data.
override void LoadModel (string file)
 Get the model parameters from a file.
override double Predict (int user_id, int item_id)
 Predict the weight for a given user-item combination.
override void RemoveFeedback (int user_id, int item_id)
override void RemoveItem (int item_id)
override void RemoveUser (int user_id)
override void SaveModel (string file)
 Save the model parameters to a file.
override string ToString ()
 Return a string representation of the recommender.
override void Train ()
 Learn the model parameters of the recommender from the training data.

Protected Member Functions

void CheckSampling ()
override void InitModel ()
virtual void RetrainItem (int item_id)
 Retrain the latent factors of a given item.
virtual void RetrainUser (int user_id)
 Retrain the latent factors of a given user.
virtual void SampleItemPair (int u, out int i, out int j)
 Sample a pair of items, given a user.
virtual bool SampleOtherItem (int u, int i, out int j)
 Sample another item, given the first one and the user.
virtual void SampleTriple (out int u, out int i, out int j)
 Sample a triple for BPR learning.
virtual int SampleUser ()
 Sample a user that has viewed at least one and not all items.
virtual void UpdateFactors (int u, int i, int j, bool update_u, bool update_i, bool update_j)
 Update latent factors according to the stochastic gradient descent update rule.

Protected Attributes

bool fast_sampling = false
 Fast, but memory-intensive sampling.
int fast_sampling_memory_limit = 1024
 Fast sampling memory limit, in MiB.
IList< double > item_bias
 Item bias terms.
Matrix< double > item_factors
 Latent item factor matrix.
double learn_rate = 0.05
 Learning rate alpha.
int num_factors = 10
 Number of latent factors per user/item.
System.Random random
 Random number generator.
double reg_i = 0.0025
 Regularization parameter for positive item factors.
double reg_j = 0.00025
 Regularization parameter for negative item factors.
double reg_u = 0.0025
 Regularization parameter for user factors.
Matrix< double > user_factors
 Latent user factor matrix.
IList< IList< int > > user_neg_items
 support data structure for fast sampling
IList< IList< int > > user_pos_items
 support data structure for fast sampling

Properties

double BiasReg [get, set]
 Regularization parameter for the bias term.
int FastSamplingMemoryLimit [get, set]
 Fast sampling memory limit, in MiB.
virtual PosOnlyFeedback Feedback [get, set]
 the feedback data to be used for training
double InitMean [get, set]
 Mean of the normal distribution used to initialize the latent factors.
double InitStdev [get, set]
 Standard deviation of the normal distribution used to initialize the latent factors.
double LearnRate [get, set]
 Learning rate alpha.
int MaxItemID [get, set]
 Maximum item ID.
int MaxUserID [get, set]
 Maximum user ID.
int NumFactors [get, set]
 Number of latent factors per user/item.
int NumIter [get, set]
 Number of iterations over the training data.
double RegI [get, set]
 Regularization parameter for positive item factors.
double RegJ [get, set]
 Regularization parameter for negative item factors.
double RegU [get, set]
 Regularization parameter for user factors.

Detailed Description

Matrix factorization model for item prediction optimized using BPR-Opt.

Steffen Rendle, Christoph Freudenthaler, Zeno Gantner, Lars Schmidt-Thieme: BPR: Bayesian Personalized Ranking from Implicit Feedback. Proceedings of the 25th Conference on Uncertainty in Artificial Intelligence (UAI 2009), Montreal, Canada, 2009.


Member Function Documentation

virtual bool CanPredict ( int  user_id,
int  item_id 
) [virtual, inherited]

Check whether a useful prediction can be made for a given user-item combination.

Parameters:
user_id the user ID
item_id the item ID
Returns:
true if a useful prediction can be made, false otherwise

Implements IRecommender.

Object Clone (  )  [inherited]

create a shallow copy of the object

override double ComputeFit (  ) 

Compute the fit (AUC on training data).

Returns:
the fit

Implements IIterativeModel.

override void Iterate (  ) 

Perform one iteration of stochastic gradient ascent over the training data.

One iteration is samples number of positive entries in the training matrix times

Implements IIterativeModel.

override void LoadModel ( string  filename  )  [virtual]

Get the model parameters from a file.

Parameters:
filename the name of the file to read from

Reimplemented from MF.

override double Predict ( int  user_id,
int  item_id 
) [virtual]

Predict the weight for a given user-item combination.

If the user or the item are not known to the engine, zero is returned. To avoid this behavior for unknown entities, use CanPredict() to check before.

Parameters:
user_id the user ID
item_id the item ID
Returns:
the predicted weight

Reimplemented from MF.

virtual void RetrainItem ( int  item_id  )  [protected, virtual]

Retrain the latent factors of a given item.

Parameters:
item_id the item ID
virtual void RetrainUser ( int  user_id  )  [protected, virtual]

Retrain the latent factors of a given user.

Parameters:
user_id the user ID
virtual void SampleItemPair ( int  u,
out int  i,
out int  j 
) [protected, virtual]

Sample a pair of items, given a user.

Parameters:
u the user ID
i the ID of the first item
j the ID of the second item
virtual bool SampleOtherItem ( int  u,
int  i,
out int  j 
) [protected, virtual]

Sample another item, given the first one and the user.

Parameters:
u the user ID
i the ID of the given item
j the ID of the other item
Returns:
true if the given item was already seen by user u
virtual void SampleTriple ( out int  u,
out int  i,
out int  j 
) [protected, virtual]

Sample a triple for BPR learning.

Parameters:
u the user ID
i the ID of the first item
j the ID of the second item
virtual int SampleUser (  )  [protected, virtual]

Sample a user that has viewed at least one and not all items.

Returns:
the user ID
override void SaveModel ( string  filename  )  [virtual]

Save the model parameters to a file.

Parameters:
filename the name of the file to write to

Reimplemented from MF.

override string ToString (  ) 

Return a string representation of the recommender.

The ToString() method of recommenders should list the class name and all hyperparameters, separated by space characters.

Implements IRecommender.

virtual void UpdateFactors ( int  u,
int  i,
int  j,
bool  update_u,
bool  update_i,
bool  update_j 
) [protected, virtual]

Update latent factors according to the stochastic gradient descent update rule.

Parameters:
u the user ID
i the ID of the first item
j the ID of the second item
update_u if true, update the user latent factors
update_i if true, update the latent factors of the first item
update_j if true, update the latent factors of the second item

Member Data Documentation

bool fast_sampling = false [protected]

Fast, but memory-intensive sampling.

int fast_sampling_memory_limit = 1024 [protected]

Fast sampling memory limit, in MiB.

IList<double> item_bias [protected]

Item bias terms.

Matrix<double> item_factors [protected, inherited]

Latent item factor matrix.

double learn_rate = 0.05 [protected]

Learning rate alpha.

int num_factors = 10 [protected, inherited]

Number of latent factors per user/item.

System.Random random [protected]

Random number generator.

double reg_i = 0.0025 [protected]

Regularization parameter for positive item factors.

double reg_j = 0.00025 [protected]

Regularization parameter for negative item factors.

double reg_u = 0.0025 [protected]

Regularization parameter for user factors.

Matrix<double> user_factors [protected, inherited]

Latent user factor matrix.

IList<IList<int> > user_neg_items [protected]

support data structure for fast sampling

IList<IList<int> > user_pos_items [protected]

support data structure for fast sampling


Property Documentation

double BiasReg [get, set]

Regularization parameter for the bias term.

int FastSamplingMemoryLimit [get, set]

Fast sampling memory limit, in MiB.

virtual PosOnlyFeedback Feedback [get, set, inherited]

the feedback data to be used for training

double InitMean [get, set, inherited]

Mean of the normal distribution used to initialize the latent factors.

double InitStdev [get, set, inherited]

Standard deviation of the normal distribution used to initialize the latent factors.

double LearnRate [get, set]

Learning rate alpha.

int MaxItemID [get, set, inherited]

Maximum item ID.

int MaxUserID [get, set, inherited]

Maximum user ID.

int NumFactors [get, set, inherited]

Number of latent factors per user/item.

int NumIter [get, set, inherited]

Number of iterations over the training data.

Implements IIterativeModel.

double RegI [get, set]

Regularization parameter for positive item factors.

double RegJ [get, set]

Regularization parameter for negative item factors.

double RegU [get, set]

Regularization parameter for user factors.


The documentation for this class was generated from the following file:
Generated on Tue May 24 12:44:17 2011 for MyMediaLite by  doxygen 1.6.3