Class DirMF
- java.lang.Object
-
- es.upm.etsisi.cf4j.recommender.Recommender
-
- es.upm.etsisi.cf4j.recommender.matrixFactorization.DirMF
-
public class DirMF extends Recommender
Implements Lara-Cabrera, R., González, Á., Ortega, F., & González-Prieto, Á. (2022). Dirichlet Matrix Factorization: A Reliable Classification-Based Recommender System. Applied Sciences, 12(3), 1223.
-
-
Field Summary
-
Fields inherited from class es.upm.etsisi.cf4j.recommender.Recommender
datamodel
-
-
Constructor Summary
Constructors Constructor Description DirMF(DataModel datamodel, int numFactors, int numIters, double learningRate, double regularization, double[] ratings)Model constructorDirMF(DataModel datamodel, int numFactors, int numIters, double learningRate, double regularization, double[] ratings, long seed)Model constructorDirMF(DataModel datamodel, Map<String,Object> params)Model constructor from a Map containing the model's hyper-parameters values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfit()Estimates model parameters given the hyper-parametersdoublegetLearningRate()Get the learning rate parameter of the modelintgetNumFactors()Get the number of factors of the modelintgetNumIters()Get the number of iterationsdouble[]getRatings()Get the discrete ratings valuesdoublegetRegularization()Get the regularization parameter of the modeldoublepredict(int userIndex, int itemIndex)Computes a rating predictiondoublepredictProba(int userIndex, int itemIndex)Computes a prediction probabilityStringtoString()-
Methods inherited from class es.upm.etsisi.cf4j.recommender.Recommender
getDataModel, predict
-
-
-
-
Constructor Detail
-
DirMF
public DirMF(DataModel datamodel, Map<String,Object> params)
Model constructor from a Map containing the model's hyper-parameters values. Map object must contains the following keys:- numFactors: int value with the number of latent factors.
- numIters:: int value with the number of iterations.
- learningRate: double value with the learning rate hyper-parameter.
- regularization: double value with the regularization hyper-parameter.
- ratings: discrete ratings values.
- seed (optional): random seed for random numbers generation. If missing, random value is used.
- Parameters:
datamodel- DataModel instanceparams- Model's hyper-parameters values
-
DirMF
public DirMF(DataModel datamodel, int numFactors, int numIters, double learningRate, double regularization, double[] ratings)
Model constructor- Parameters:
datamodel- DataModel instancenumFactors- Number of latent factorsnumIters- Number of iterationslearningRate- Learning rateregularization- Regularizationratings- Discrete ratings values
-
DirMF
public DirMF(DataModel datamodel, int numFactors, int numIters, double learningRate, double regularization, double[] ratings, long seed)
Model constructor- Parameters:
datamodel- DataModel instancenumFactors- Number of latent factorsnumIters- Number of iterationslearningRate- Learning rateregularization- Regularizationratings- Discrete ratings valuesseed- Seed for random numbers generation
-
-
Method Detail
-
getNumFactors
public int getNumFactors()
Get the number of factors of the model- Returns:
- Number of factors
-
getNumIters
public int getNumIters()
Get the number of iterations- Returns:
- Number of iterations
-
getLearningRate
public double getLearningRate()
Get the learning rate parameter of the model- Returns:
- Learning rate
-
getRegularization
public double getRegularization()
Get the regularization parameter of the model- Returns:
- Regularization
-
getRatings
public double[] getRatings()
Get the discrete ratings values- Returns:
- Discrete ratings values
-
fit
public void fit()
Description copied from class:RecommenderEstimates model parameters given the hyper-parameters- Specified by:
fitin classRecommender
-
predict
public double predict(int userIndex, int itemIndex)Description copied from class:RecommenderComputes a rating prediction- Specified by:
predictin classRecommender- Parameters:
userIndex- Index of the user in the array of Users of the DataModel instanceitemIndex- Index of the item in the array of Items of the DataModel instance- Returns:
- Prediction
-
predictProba
public double predictProba(int userIndex, int itemIndex)Computes a prediction probability- Parameters:
userIndex- Index of the user in the array of Users of the DataModel instanceitemIndex- Index of the item in the array of Items of the DataModel instance- Returns:
- Prediction probability
-
-