Class BNMF
- java.lang.Object
-
- es.upm.etsisi.cf4j.recommender.Recommender
-
- es.upm.etsisi.cf4j.recommender.matrixFactorization.BNMF
-
public class BNMF extends Recommender
Implements Hernando, A., Bobadilla, J., & Ortega, F. (2016). A non negative matrix factorization for collaborative filtering recommender systems on a Bayesian probabilistic model. Knowledge-Based Systems, 97, 188-202.
-
-
Field Summary
Fields Modifier and Type Field Description protected double[][]
a
User factorsprotected double
alpha
This hyper-parameter is related to the possibility of obtaining overlapping groups of users sharing the same tastes.protected double[][]
b
Item factorsprotected double
beta
This hyper-parameter represents the amount of evidence that the algorithm requires to deduce that a group of users likes an item.protected static double
DEFAULT_R
protected double[][]
epsilonMinus
Epsilon- parametersprotected double[][]
epsilonPlus
Epsilon+ parametersprotected double[][]
gamma
Gamma parametersprotected int
numFactors
Number of factorsprotected int
numIters
Number of iterationsprotected double
r
Hyper-parameter of the binomial distribution.-
Fields inherited from class es.upm.etsisi.cf4j.recommender.Recommender
datamodel
-
-
Constructor Summary
Constructors Constructor Description BNMF(DataModel datamodel, int numFactors, int numIters, double alpha, double beta)
Model constructorBNMF(DataModel datamodel, int numFactors, int numIters, double alpha, double beta, double r, long seed)
Model constructorBNMF(DataModel datamodel, int numFactors, int numIters, double alpha, double beta, long seed)
Model constructorBNMF(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
getAlpha()
Get the alpha valuedouble
getBeta()
Get the beta valuedouble[]
getEpsilonMinus(int itemIndex)
Get the epsilon- vector of an itemdouble[]
getEpsilonPlus(int itemIndex)
Get the epsilon+ vector of an itemdouble[]
getGamma(int userIndex)
Get the gamma vector of an userdouble[]
getItemFactors(int itemIndex)
Get the latent factors vector of an item (bi)int
getNumFactors()
Get the number of factors of the modelint
getNumIters()
Get the number of iterationsdouble
getR()
Get the r valuedouble[]
getUserFactors(int userIndex)
Get the latent factors vector of a user (au)double
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_R
protected static final double DEFAULT_R
- See Also:
- Constant Field Values
-
a
protected double[][] a
User factors
-
b
protected double[][] b
Item factors
-
gamma
protected double[][] gamma
Gamma parameters
-
epsilonPlus
protected double[][] epsilonPlus
Epsilon+ parameters
-
epsilonMinus
protected double[][] epsilonMinus
Epsilon- parameters
-
alpha
protected final double alpha
This hyper-parameter is related to the possibility of obtaining overlapping groups of users sharing the same tastes.
-
beta
protected final double beta
This hyper-parameter represents the amount of evidence that the algorithm requires to deduce that a group of users likes an item.
-
r
protected final double r
Hyper-parameter of the binomial distribution.
-
numFactors
protected final int numFactors
Number of factors
-
numIters
protected final int numIters
Number of iterations
-
-
Constructor Detail
-
BNMF
public BNMF(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.
- alpha: double value with the alpha hyper-parameter. This value is related to the possibility of obtaining overlapping groups of users sharing the same tastes.
- beta: double value with the beta hyper-parameter. This value represents the amount of evidences that the algorithm requires to deduce that a group of users likes an item.
- seed (optional): random seed for generating random numbers. If missing, random value is used.
- Parameters:
datamodel
- DataModel instanceparams
- Model's hyper-parameters values
-
BNMF
public BNMF(DataModel datamodel, int numFactors, int numIters, double alpha, double beta)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of factorsnumIters
- Number of iterationsalpha
- This parameter is related to the possibility of obtaining overlapping groups of users sharing the same tastesbeta
- Amount of evidences that the algorithm requires to deduce that a group of users likes an item
-
BNMF
public BNMF(DataModel datamodel, int numFactors, int numIters, double alpha, double beta, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of factorsnumIters
- Number of iterationsalpha
- This parameter is related to the possibility of obtaining overlapping groups of users sharing the same tastesbeta
- Amount of evidences that the algorithm requires to deduce that a group of users likes an itemseed
- Seed for random numbers generation
-
BNMF
public BNMF(DataModel datamodel, int numFactors, int numIters, double alpha, double beta, double r, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of factorsnumIters
- Number of iterationsalpha
- This parameter is related to the possibility of obtaining overlapping groups of users sharing the same tastesbeta
- Amount of evidences that the algorithm requires to deduce that a group of users likes an itemr
- Parameter of the binomial distribution (fixed to 4)seed
- 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
-
getAlpha
public double getAlpha()
Get the alpha value- Returns:
- Alpha value
-
getBeta
public double getBeta()
Get the beta value- Returns:
- Beta value
-
getR
public double getR()
Get the r value- Returns:
- r value
-
getGamma
public double[] getGamma(int userIndex)
Get the gamma vector of an user- Parameters:
userIndex
- user index- Returns:
- User's gamma vector
-
getEpsilonPlus
public double[] getEpsilonPlus(int itemIndex)
Get the epsilon+ vector of an item- Parameters:
itemIndex
- item index- Returns:
- Item's epsilon+ vector
-
getEpsilonMinus
public double[] getEpsilonMinus(int itemIndex)
Get the epsilon- vector of an item- Parameters:
itemIndex
- item index- Returns:
- Item's epsilon- vector
-
getUserFactors
public double[] getUserFactors(int userIndex)
Get the latent factors vector of a user (au)- Parameters:
userIndex
- User- Returns:
- Latent factors vector
-
getItemFactors
public double[] getItemFactors(int itemIndex)
Get the latent factors vector of an item (bi)- Parameters:
itemIndex
- User- Returns:
- Latent factors vector
-
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
-
-