C# 클래스 MyMediaLite.ItemRecommendation.BPRMF

Matrix factorization model for item prediction (ranking) optimized for BPR

BPR reduces ranking to pairwise classification. The different variants (settings) of this recommender roughly optimize the area under the ROC curve (AUC).

\f[ \max_\Theta \sum_{(u,i,j) \in D_S} \ln g(\hat{s}_{u,i,j}(\Theta)) - \lambda ||\Theta||^2 , \f] where \f$\hat{s}_{u,i,j}(\Theta) := \hat{s}_{u,i}(\Theta) - \hat{s}_{u,j}(\Theta)\f$ and \f$D_S = \{ (u, i, j) | i \in \mathcal{I}^+_u \wedge j \in \mathcal{I}^-_u \}\f$. \f$\Theta\f$ represents the parameters of the model and \f$\lambda\f$ is a regularization constant. \f$g\f$ is the logistic function.

In this implementation, we distinguish different regularization updates for users and positive and negative items, which means we do not have only one regularization constant. The optimization problem specified above thus is only an approximation.

Literature: Steffen Rendle, Christoph Freudenthaler, Zeno Gantner, Lars Schmidt-Thieme: BPR: Bayesian Personalized Ranking from Implicit Feedback. UAI 2009. http://www.ismll.uni-hildesheim.de/pub/pdfs/Rendle_et_al2009-Bayesian_Personalized_Ranking.pdf

Different sampling strategies are configurable by setting the UniformUserSampling and WithReplacement accordingly. To get the strategy from the original paper, set UniformUserSampling=false and WithReplacement=false. WithReplacement=true (default) gives you usually a slightly faster convergence, and UniformUserSampling=true (default) (approximately) optimizes the average AUC over all users.

This recommender supports incremental updates.

상속: MF, IFoldInItemRecommender
파일 보기 프로젝트 열기: zenogantner/MML-KDD 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
fast_sampling bool
fast_sampling_memory_limit int
item_bias IList
learn_rate double
random System.Random
reg_i double
reg_j double
reg_u double
user_neg_items IList>
user_pos_items IList>

공개 메소드들

메소드 설명
AddFeedback ( int user_id, int item_id ) : void
ComputeFit ( ) : double

Compute the fit (AUC on training data)

ComputeLoss ( ) : double

Compute approximate loss

Iterate ( ) : void

Perform one iteration of stochastic gradient ascent over the training data

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

LoadModel ( string file ) : void
Predict ( int user_id, int item_id ) : double
RemoveFeedback ( int user_id, int item_id ) : void
RemoveItem ( int item_id ) : void
RemoveUser ( int user_id ) : void
SaveModel ( string file ) : void
ToString ( ) : string
Train ( ) : void

보호된 메소드들

메소드 설명
AddItem ( int item_id ) : void
AddUser ( int user_id ) : void
CheckSampling ( ) : void
InitModel ( ) : void
RetrainItem ( int item_id ) : void

Retrain the latent factors of a given item

RetrainUser ( int user_id ) : void

Retrain the latent factors of a given user

SampleItemPair ( int u, int &i, int &j ) : void

Sample a pair of items, given a user

SampleOtherItem ( int u, int i, int &j ) : bool

Sample another item, given the first one and the user

SampleTriple ( int &u, int &i, int &j ) : void

Sample a triple for BPR learning

SampleUser ( ) : int

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

UpdateFactors ( int u, int i, int j, bool update_u, bool update_i, bool update_j ) : void

Update latent factors according to the stochastic gradient descent update rule

비공개 메소드들

메소드 설명
CreateFastSamplingData ( int u ) : void

메소드 상세

AddFeedback() 공개 메소드

public AddFeedback ( int user_id, int item_id ) : void
user_id int
item_id int
리턴 void

AddItem() 보호된 메소드

protected AddItem ( int item_id ) : void
item_id int
리턴 void

AddUser() 보호된 메소드

protected AddUser ( int user_id ) : void
user_id int
리턴 void

CheckSampling() 보호된 메소드

protected CheckSampling ( ) : void
리턴 void

ComputeFit() 공개 메소드

Compute the fit (AUC on training data)
public ComputeFit ( ) : double
리턴 double

ComputeLoss() 공개 메소드

Compute approximate loss
public ComputeLoss ( ) : double
리턴 double

InitModel() 보호된 메소드

protected InitModel ( ) : void
리턴 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
public Iterate ( ) : void
리턴 void

LoadModel() 공개 메소드

public LoadModel ( string file ) : void
file string
리턴 void

Predict() 공개 메소드

public Predict ( int user_id, int item_id ) : double
user_id int
item_id int
리턴 double

RemoveFeedback() 공개 메소드

public RemoveFeedback ( int user_id, int item_id ) : void
user_id int
item_id int
리턴 void

RemoveItem() 공개 메소드

public RemoveItem ( int item_id ) : void
item_id int
리턴 void

RemoveUser() 공개 메소드

public RemoveUser ( int user_id ) : void
user_id int
리턴 void

RetrainItem() 보호된 메소드

Retrain the latent factors of a given item
protected RetrainItem ( int item_id ) : void
item_id int the item ID
리턴 void

RetrainUser() 보호된 메소드

Retrain the latent factors of a given user
protected RetrainUser ( int user_id ) : void
user_id int the user ID
리턴 void

SampleItemPair() 보호된 메소드

Sample a pair of items, given a user
protected SampleItemPair ( int u, int &i, int &j ) : void
u int the user ID
i int the ID of the first item
j int the ID of the second item
리턴 void

SampleOtherItem() 보호된 메소드

Sample another item, given the first one and the user
protected SampleOtherItem ( int u, int i, int &j ) : bool
u int the user ID
i int the ID of the given item
j int the ID of the other item
리턴 bool

SampleTriple() 보호된 메소드

Sample a triple for BPR learning
protected SampleTriple ( int &u, int &i, int &j ) : void
u int the user ID
i int the ID of the first item
j int the ID of the second item
리턴 void

SampleUser() 보호된 메소드

Sample a user that has viewed at least one and not all items
protected SampleUser ( ) : int
리턴 int

SaveModel() 공개 메소드

public SaveModel ( string file ) : void
file string
리턴 void

ToString() 공개 메소드

public ToString ( ) : string
리턴 string

Train() 공개 메소드

public Train ( ) : void
리턴 void

UpdateFactors() 보호된 메소드

Update latent factors according to the stochastic gradient descent update rule
protected UpdateFactors ( int u, int i, int j, bool update_u, bool update_i, bool update_j ) : void
u int the user ID
i int the ID of the first item
j int the ID of the second item
update_u bool if true, update the user latent factors
update_i bool if true, update the latent factors of the first item
update_j bool if true, update the latent factors of the second item
리턴 void

프로퍼티 상세

fast_sampling 보호되어 있는 프로퍼티

Fast, but memory-intensive sampling
protected bool fast_sampling
리턴 bool

fast_sampling_memory_limit 보호되어 있는 프로퍼티

Fast sampling memory limit, in MiB
protected int fast_sampling_memory_limit
리턴 int

item_bias 보호되어 있는 프로퍼티

Item bias terms
protected IList item_bias
리턴 IList

learn_rate 보호되어 있는 프로퍼티

Learning rate alpha
protected double learn_rate
리턴 double

random 보호되어 있는 프로퍼티

Random number generator
protected Random,System random
리턴 System.Random

reg_i 보호되어 있는 프로퍼티

Regularization parameter for positive item factors
protected double reg_i
리턴 double

reg_j 보호되어 있는 프로퍼티

Regularization parameter for negative item factors
protected double reg_j
리턴 double

reg_u 보호되어 있는 프로퍼티

Regularization parameter for user factors
protected double reg_u
리턴 double

user_neg_items 보호되어 있는 프로퍼티

support data structure for fast sampling
protected IList> user_neg_items
리턴 IList>

user_pos_items 보호되어 있는 프로퍼티

support data structure for fast sampling
protected IList> user_pos_items
리턴 IList>