Class 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 rate
      protected double lambda
      Regularization
      protected int numFactors
      Number of latent factors
      protected int numIters
      Number of iterations
      protected double threshold
      Threshold to binarize rating matrix.
      protected double[][] U
      Users' latent factors
      protected double[][] V
      Items's latent factors
    • Constructor Summary

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

      • 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 instance
        params - Model's hyper-parameters values
      • CLiMF

        public CLiMF​(DataModel datamodel,
                     int numFactors,
                     int numIters)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        numIters - Number of iterations
      • CLiMF

        public CLiMF​(DataModel datamodel,
                     int numFactors,
                     int numIters,
                     long seed)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        numIters - Number of iterations
        seed - Seed for random numbers generation
      • CLiMF

        public CLiMF​(DataModel datamodel,
                     int numFactors,
                     int numIters,
                     double threshold,
                     long seed)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        numIters - Number of iterations
        threshold - 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 instance
        numFactors - Number of latent factors
        numIters - Number of iterations
        threshold - 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 instance
        numFactors - Number of latent factors
        gamma - Learning rate
        lambda - Regularization
        numIters - Number of iterations
        threshold - 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 instance
        numFactors - Number of latent factors
        gamma - Learning rate
        lambda - Regularization
        numIters - Number of iterations
        threshold - 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 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
      • 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