Class CLiMF
- java.lang.Object
-
- es.upm.etsisi.cf4j.recommender.Recommender
-
- es.upm.etsisi.cf4j.recommender.matrixFactorization.CLiMF
-
public class CLiMF extends Recommender
Implements Shi, Y., Karatzoglou, A., Baltrunas, L., Larson, M., Oliver, N., & Hanjalic, A. (2012, September). CLiMF: learning to maximize reciprocal rank with collaborative less-is-more filtering. In Proceedings of the sixth ACM conference on Recommender systems (pp. 139-146).
-
-
Field Summary
Fields Modifier and Type Field Description protected static double
DEFAULT_GAMMA
protected static double
DEFAULT_LAMBDA
protected double
gamma
Learning rateprotected double
lambda
Regularizationprotected int
numFactors
Number of latent factorsprotected int
numIters
Number of iterationsprotected double
threshold
Threshold to binarize rating matrix.protected double[][]
U
Users' latent factorsprotected double[][]
V
Items's latent factors-
Fields inherited from class es.upm.etsisi.cf4j.recommender.Recommender
datamodel
-
-
Constructor Summary
Constructors Constructor Description CLiMF(DataModel datamodel, int numFactors, double gamma, double lambda, int numIters, double threshold)
Model constructorCLiMF(DataModel datamodel, int numFactors, double gamma, double lambda, int numIters, double threshold, long seed)
Model constructorCLiMF(DataModel datamodel, int numFactors, int numIters)
Model constructorCLiMF(DataModel datamodel, int numFactors, int numIters, double threshold)
Model constructorCLiMF(DataModel datamodel, int numFactors, int numIters, double threshold, long seed)
Model constructorCLiMF(DataModel datamodel, int numFactors, int numIters, long seed)
Model constructorCLiMF(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 void
fit()
Estimates model parameters given the hyper-parametersdouble
getGamma()
Get the learning rate parameter of the modeldouble
getLambda()
Get the regularization parameter of the modelint
getNumFactors()
Get the number of factors of the modelint
getNumIters()
Get the number of iterationsdouble
predict(int userIndex, int itemIndex)
Computes a rating predictionString
toString()
-
Methods inherited from class es.upm.etsisi.cf4j.recommender.Recommender
getDataModel, predict
-
-
-
-
Field Detail
-
DEFAULT_GAMMA
protected static final double DEFAULT_GAMMA
- See Also:
- Constant Field Values
-
DEFAULT_LAMBDA
protected static final double DEFAULT_LAMBDA
- See Also:
- Constant Field Values
-
numFactors
protected int numFactors
Number of latent factors
-
gamma
protected double gamma
Learning rate
-
lambda
protected double lambda
Regularization
-
numIters
protected int numIters
Number of iterations
-
threshold
protected double threshold
Threshold to binarize rating matrix. Any rating greater or equal than this threshold will be used during the training process.
-
U
protected double[][] U
Users' latent factors
-
V
protected double[][] V
Items's latent factors
-
-
Constructor Detail
-
CLiMF
public CLiMF(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.
- threshold: double value representing the rating value that binaries the matrix.
- gamma (optional): double value with the learning rate hyper-parameter. If missing, it is set to 1E-5.
- lambda (optional): double value with the regularization hyper-parameter. If missing, it is set to 1E-4.
- seed (optional): random seed for random numbers generation. If missing, random value is used.
- Parameters:
datamodel
- DataModel instanceparams
- Model's hyper-parameters values
-
CLiMF
public CLiMF(DataModel datamodel, int numFactors, int numIters)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsnumIters
- Number of iterations
-
CLiMF
public CLiMF(DataModel datamodel, int numFactors, int numIters, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsnumIters
- Number of iterationsseed
- Seed for random numbers generation
-
CLiMF
public CLiMF(DataModel datamodel, int numFactors, int numIters, double threshold, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsnumIters
- Number of iterationsthreshold
- Threshold to binarize rating matrix. Any rating greater or equal than this threshold will be used during the training process.seed
- Seed for random numbers generation
-
CLiMF
public CLiMF(DataModel datamodel, int numFactors, int numIters, double threshold)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsnumIters
- Number of iterationsthreshold
- Threshold to binarize rating matrix. Any rating greater or equal than this threshold will be used during the training process.
-
CLiMF
public CLiMF(DataModel datamodel, int numFactors, double gamma, double lambda, int numIters, double threshold)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsgamma
- Learning ratelambda
- RegularizationnumIters
- Number of iterationsthreshold
- Threshold to binarize rating matrix. Any rating greater or equal than this threshold will be used during the training process.
-
CLiMF
public CLiMF(DataModel datamodel, int numFactors, double gamma, double lambda, int numIters, double threshold, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsgamma
- Learning ratelambda
- RegularizationnumIters
- Number of iterationsthreshold
- Threshold to binarize rating matrix. Any rating greater or equal than this threshold will be used during the training process.seed
- Seed for random numbers generation
-
-
Method Detail
-
fit
public void fit()
Description copied from class:Recommender
Estimates model parameters given the hyper-parameters- Specified by:
fit
in classRecommender
-
predict
public double predict(int userIndex, int itemIndex)
Description copied from class:Recommender
Computes a rating prediction- Specified by:
predict
in 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
-
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
-
getLambda
public double getLambda()
Get the regularization parameter of the model- Returns:
- Lambda
-
getGamma
public double getGamma()
Get the learning rate parameter of the model- Returns:
- Gamma
-
-