Class NMF
- java.lang.Object
-
- es.upm.etsisi.cf4j.recommender.Recommender
-
- es.upm.etsisi.cf4j.recommender.matrixFactorization.NMF
-
public class NMF extends Recommender
Implements Lee, D. D., & Seung, H. S. (2001). Algorithms for non-negative matrix factorization. In Advances in neural information processing systems (pp. 556-562).
-
-
Field Summary
Fields Modifier and Type Field Description protected double[][]
h
Item factorsprotected int
numFactors
Number of factorsprotected int
numIters
Number of iterationsprotected double[][]
w
User factors-
Fields inherited from class es.upm.etsisi.cf4j.recommender.Recommender
datamodel
-
-
Constructor Summary
Constructors Constructor Description NMF(DataModel datamodel, int numFactors, int numIters)
Model constructorNMF(DataModel datamodel, int numFactors, int numIters, long seed)
Model constructorNMF(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-parametersint
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
-
-
-
-
Constructor Detail
-
NMF
public NMF(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.
- seed (optional): random seed for random numbers generation. If missing, random value is used.
- Parameters:
datamodel
- DataModel instanceparams
- Model's hyper-parameters values
-
NMF
public NMF(DataModel datamodel, int numFactors, int numIters)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of factorsnumIters
- Number of iterations
-
NMF
public NMF(DataModel datamodel, int numFactors, int numIters, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of factorsnumIters
- Number of iterationsseed
- 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
-
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
-
-