C# Класс 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.

Наследование: MyMediaLite.RatingPrediction.IncrementalRatingPredictor, IIterativeModel, IFoldInRatingPredictor
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
global_bias double
item_factors Matrix
user_factors Matrix

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
LearnFactors ( IList rating_indices, bool update_user, bool update_item ) : void

Описание методов

AddItem() защищенный Метод

protected AddItem ( int item_id ) : void
item_id int
Результат void

AddRating() публичный Метод

public AddRating ( int user_id, int item_id, double rating ) : void
user_id int
item_id int
rating double
Результат void

AddUser() защищенный Метод

protected AddUser ( int user_id ) : void
user_id int
Результат void

ComputeFit() публичный Метод

public ComputeFit ( ) : double
Результат double

ComputeLoss() публичный Метод

Compute the regularized loss
public ComputeLoss ( ) : double
Результат double

InitModel() защищенный Метод

Initialize the model data structure
protected InitModel ( ) : void
Результат void

Iterate() публичный Метод

public Iterate ( ) : void
Результат void

Iterate() защищенный Метод

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
Результат void

LoadModel() публичный Метод

public LoadModel ( string filename ) : void
filename string
Результат void

MatrixFactorization() публичный Метод

Default constructor
public MatrixFactorization ( ) : System
Результат System

Predict() публичный Метод

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
Результат double

Predict() защищенный Метод

protected Predict ( int user_id, int item_id, bool bound ) : double
user_id int
item_id int
bound bool
Результат double

RemoveItem() публичный Метод

public RemoveItem ( int item_id ) : void
item_id int
Результат void

RemoveRating() публичный Метод

public RemoveRating ( int user_id, int item_id ) : void
user_id int
item_id int
Результат void

RemoveUser() публичный Метод

public RemoveUser ( int user_id ) : void
user_id int
Результат void

RetrainItem() публичный Метод

Updates the latent factors of an item
public RetrainItem ( int item_id ) : void
item_id int the item ID
Результат void

RetrainUser() публичный Метод

Updates the latent factors on a user
public RetrainUser ( int user_id ) : void
user_id int the user ID
Результат void

SaveModel() публичный Метод

public SaveModel ( string filename ) : void
filename string
Результат void

ToString() публичный Метод

public ToString ( ) : string
Результат string

Train() публичный Метод

public Train ( ) : void
Результат void

UpdateRating() публичный Метод

public UpdateRating ( int user_id, int item_id, double rating ) : void
user_id int
item_id int
rating double
Результат void

Описание свойств

global_bias защищенное свойство

The bias (global average)
protected double global_bias
Результат double

item_factors защищенное свойство

Matrix containing the latent item factors
protected Matrix item_factors
Результат Matrix

user_factors защищенное свойство

Matrix containing the latent user factors
protected Matrix user_factors
Результат Matrix