C# Class MyMediaLite.RatingPrediction.MatrixFactorization

Simple matrix factorization class, learning is performed by stochastic gradient descent (SGD)

Factorizing the observed rating values using a factor matrix for users and one for items.

NaN values in the model occur if values become too large or too small to be represented by the type float. If you encounter such problems, there are three ways to fix them: (1) (preferred) Use BiasedMatrixFactorization, which is more stable. (2) Change the range of rating values (1 to 5 works generally well with the default settings). (3) Decrease the learn_rate.

This recommender supports incremental updates.

Inheritance: MyMediaLite.RatingPrediction.IncrementalRatingPredictor, IIterativeModel, IFoldInRatingPredictor
Afficher le fichier Open project: zenogantner/MML-KDD Class Usage Examples

Protected Properties

Свойство Type Description
global_bias double
item_factors Matrix
user_factors Matrix

Méthodes publiques

Méthode Description
AddRating ( int user_id, int item_id, double rating ) : void
ComputeFit ( ) : double
ComputeLoss ( ) : double

Compute the regularized loss

Iterate ( ) : void
LoadModel ( string filename ) : void
MatrixFactorization ( ) : System

Default constructor

Predict ( int user_id, int item_id ) : double

Predict the rating of a given user for a given item

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

RemoveItem ( int item_id ) : void
RemoveRating ( int user_id, int item_id ) : void
RemoveUser ( int user_id ) : void
RetrainItem ( int item_id ) : void

Updates the latent factors of an item

RetrainUser ( int user_id ) : void

Updates the latent factors on a user

SaveModel ( string filename ) : void
ToString ( ) : string
Train ( ) : void
UpdateRating ( int user_id, int item_id, double rating ) : void

Méthodes protégées

Méthode Description
AddItem ( int item_id ) : void
AddUser ( int user_id ) : void
InitModel ( ) : void

Initialize the model data structure

Iterate ( IList rating_indices, bool update_user, bool update_item ) : void

Iterate once over rating data and adjust corresponding factors (stochastic gradient descent)

Predict ( int user_id, int item_id, bool bound ) : double

Private Methods

Méthode Description
LearnFactors ( IList rating_indices, bool update_user, bool update_item ) : void

Method Details

AddItem() protected méthode

protected AddItem ( int item_id ) : void
item_id int
Résultat void

AddRating() public méthode

public AddRating ( int user_id, int item_id, double rating ) : void
user_id int
item_id int
rating double
Résultat void

AddUser() protected méthode

protected AddUser ( int user_id ) : void
user_id int
Résultat void

ComputeFit() public méthode

public ComputeFit ( ) : double
Résultat double

ComputeLoss() public méthode

Compute the regularized loss
public ComputeLoss ( ) : double
Résultat double

InitModel() protected méthode

Initialize the model data structure
protected InitModel ( ) : void
Résultat void

Iterate() public méthode

public Iterate ( ) : void
Résultat void

Iterate() protected méthode

Iterate once over rating data and adjust corresponding factors (stochastic gradient descent)
protected Iterate ( IList rating_indices, bool update_user, bool update_item ) : void
rating_indices IList a list of indices pointing to the ratings to iterate over
update_user bool true if user factors to be updated
update_item bool true if item factors to be updated
Résultat void

LoadModel() public méthode

public LoadModel ( string filename ) : void
filename string
Résultat void

MatrixFactorization() public méthode

Default constructor
public MatrixFactorization ( ) : System
Résultat System

Predict() public méthode

Predict the rating of a given user for a given item
If the user or the item are not known to the recommender, the global average is returned. To avoid this behavior for unknown entities, use CanPredict() to check before.
public Predict ( int user_id, int item_id ) : double
user_id int the user ID
item_id int the item ID
Résultat double

Predict() protected méthode

protected Predict ( int user_id, int item_id, bool bound ) : double
user_id int
item_id int
bound bool
Résultat double

RemoveItem() public méthode

public RemoveItem ( int item_id ) : void
item_id int
Résultat void

RemoveRating() public méthode

public RemoveRating ( int user_id, int item_id ) : void
user_id int
item_id int
Résultat void

RemoveUser() public méthode

public RemoveUser ( int user_id ) : void
user_id int
Résultat void

RetrainItem() public méthode

Updates the latent factors of an item
public RetrainItem ( int item_id ) : void
item_id int the item ID
Résultat void

RetrainUser() public méthode

Updates the latent factors on a user
public RetrainUser ( int user_id ) : void
user_id int the user ID
Résultat void

SaveModel() public méthode

public SaveModel ( string filename ) : void
filename string
Résultat void

ToString() public méthode

public ToString ( ) : string
Résultat string

Train() public méthode

public Train ( ) : void
Résultat void

UpdateRating() public méthode

public UpdateRating ( int user_id, int item_id, double rating ) : void
user_id int
item_id int
rating double
Résultat void

Property Details

global_bias protected_oe property

The bias (global average)
protected double global_bias
Résultat double

item_factors protected_oe property

Matrix containing the latent item factors
protected Matrix item_factors
Résultat Matrix

user_factors protected_oe property

Matrix containing the latent user factors
protected Matrix user_factors
Résultat Matrix