Class 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 parameter
      protected double[][][] beta
      Beta parameter
      protected static double DEFAULT_H  
      protected static double EPSILON  
      protected double[][] gamma
      Gamma parameter
      protected double H
      Heuristic factor to control number of iterations during E-Step
      protected int numFactors
      Number of latent factors
      protected int numIters
      Number of iterations
      protected Map<Integer,​double[][]> phi
      Phi parameter
      protected double[] ratings
      Plausible ratings (must be sorted in ascending order)
    • Constructor Summary

      Constructors 
      Constructor Description
      URP​(DataModel datamodel, int numFactors, double[] ratings, int numIters)
      Model constructor
      URP​(DataModel datamodel, int numFactors, double[] ratings, int numIters, double H)
      Model constructor
      URP​(DataModel datamodel, int numFactors, double[] ratings, int numIters, double H, long seed)
      Model constructor
      URP​(DataModel datamodel, int numFactors, double[] ratings, int numIters, long seed)
      Model constructor
      URP​(DataModel datamodel, Map<String,​Object> params)
      Model constructor from a Map containing the model's hyper-parameters values.
    • Field Detail

      • 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
      • phi

        protected final Map<Integer,​double[][]> phi
        Phi 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 instance
        params - Model's hyper-parameters values
      • URP

        public URP​(DataModel datamodel,
                   int numFactors,
                   double[] ratings,
                   int numIters)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        ratings - 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 instance
        numFactors - Number of latent factors
        ratings - Plausible ratings (must be sorted in ascending order)
        numIters - Number of iterations
        seed - Seed for random numbers generation
      • URP

        public URP​(DataModel datamodel,
                   int numFactors,
                   double[] ratings,
                   int numIters,
                   double H)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        ratings - Plausible ratings (must be sorted in ascending order)
        numIters - Number of iterations
        H - 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 instance
        numFactors - Number of latent factors
        ratings - Plausible ratings (must be sorted in ascending order)
        numIters - Number of iterations
        H - Heuristic factor to control number of iterations during E-Step. The number of iterations is defined by H * number_of_user_ratings
        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
      • 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 class Recommender
      • predict

        public double predict​(int userIndex,
                              int itemIndex)
        Description copied from class: Recommender
        Computes a rating prediction
        Specified by:
        predict in class Recommender
        Parameters:
        userIndex - Index of the user in the array of Users of the DataModel instance
        itemIndex - 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 - User
        itemIndex - Item
        Returns:
        Probability distribution of the prediction