Class URP
- java.lang.Object
-
- es.upm.etsisi.cf4j.recommender.Recommender
-
- es.upm.etsisi.cf4j.recommender.matrixFactorization.URP
-
public class URP extends Recommender
Implements Marlin, B. M. (2004). Modeling user rating profiles for collaborative filtering. In Advances in neural information processing systems (pp. 627-634).
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]
alpha
Alpha parameterprotected double[][][]
beta
Beta parameterprotected static double
DEFAULT_H
protected static double
EPSILON
protected double[][]
gamma
Gamma parameterprotected double
H
Heuristic factor to control number of iterations during E-Stepprotected int
numFactors
Number of latent factorsprotected int
numIters
Number of iterationsprotected Map<Integer,double[][]>
phi
Phi parameterprotected double[]
ratings
Plausible ratings (must be sorted in ascending order)-
Fields inherited from class es.upm.etsisi.cf4j.recommender.Recommender
datamodel
-
-
Constructor Summary
Constructors Constructor Description URP(DataModel datamodel, int numFactors, double[] ratings, int numIters)
Model constructorURP(DataModel datamodel, int numFactors, double[] ratings, int numIters, double H)
Model constructorURP(DataModel datamodel, int numFactors, double[] ratings, int numIters, double H, long seed)
Model constructorURP(DataModel datamodel, int numFactors, double[] ratings, int numIters, long seed)
Model constructorURP(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
getH()
Get the H valueint
getNumFactors()
Get the number of factors of the modelint
getNumIters()
Get the number of iterationsdouble[]
getPredictionProbabilityDistribution(int userIndex, int itemIndex)
Returns the probability distribution of a prediction.double[]
getRatings()
Get the plausible ratingsdouble
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_H
protected static final double DEFAULT_H
- See Also:
- Constant Field Values
-
EPSILON
protected static final double EPSILON
- See Also:
- Constant Field Values
-
numIters
protected final int numIters
Number of iterations
-
numFactors
protected final int numFactors
Number of latent factors
-
H
protected final double H
Heuristic factor to control number of iterations during E-Step
-
ratings
protected final double[] ratings
Plausible ratings (must be sorted in ascending order)
-
gamma
protected final double[][] gamma
Gamma parameter
-
beta
protected final double[][][] beta
Beta parameter
-
alpha
protected final double[] alpha
Alpha parameter
-
-
Constructor Detail
-
URP
public URP(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.
- ratings: double array with the plausible ratings of the DataModel.
- numIters:: int value with the number of iterations.
- H (optional): double value that represents the heuristic factor to control the number of iterations during E-Step. The number of iterations is defined by H * number_of_user_ratings.
- seed (optional): random seed for random numbers generation. If missing, random value is used.
- Parameters:
datamodel
- DataModel instanceparams
- Model's hyper-parameters values
-
URP
public URP(DataModel datamodel, int numFactors, double[] ratings, int numIters)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsratings
- Plausible ratings (must be sorted in ascending order)numIters
- Number of iterations
-
URP
public URP(DataModel datamodel, int numFactors, double[] ratings, int numIters, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsratings
- Plausible ratings (must be sorted in ascending order)numIters
- Number of iterationsseed
- Seed for random numbers generation
-
URP
public URP(DataModel datamodel, int numFactors, double[] ratings, int numIters, double H)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsratings
- Plausible ratings (must be sorted in ascending order)numIters
- Number of iterationsH
- Heuristic factor to control number of iterations during E-Step. The number of iterations is defined by H * number_of_user_ratings
-
URP
public URP(DataModel datamodel, int numFactors, double[] ratings, int numIters, double H, long seed)
Model constructor- Parameters:
datamodel
- DataModel instancenumFactors
- Number of latent factorsratings
- Plausible ratings (must be sorted in ascending order)numIters
- Number of iterationsH
- Heuristic factor to control number of iterations during E-Step. The number of iterations is defined by H * number_of_user_ratingsseed
- 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
-
getRatings
public double[] getRatings()
Get the plausible ratings- Returns:
- Plausible ratings
-
getH
public double getH()
Get the H value- Returns:
- H value
-
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
-
getPredictionProbabilityDistribution
public double[] getPredictionProbabilityDistribution(int userIndex, int itemIndex)
Returns the probability distribution of a prediction. Each position of the returned array corresponds with the probability that the user (defined by userIndex) rates the item (defined by itemIndex) with the rating value that is in the same position in the array returned by getRatings()- Parameters:
userIndex
- UseritemIndex
- Item- Returns:
- Probability distribution of the prediction
-
-