Class DirMF


  • public class DirMF
    extends Recommender
    Implements Lara-Cabrera, R., González, Á., Ortega, F., & González-Prieto, Á. (2022). Dirichlet Matrix Factorization: A Reliable Classification-Based Recommender System. Applied Sciences, 12(3), 1223.
    • Constructor Detail

      • DirMF

        public DirMF​(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.
        • learningRate: double value with the learning rate hyper-parameter.
        • regularization: double value with the regularization hyper-parameter.
        • ratings: discrete ratings values.
        • seed (optional): random seed for random numbers generation. If missing, random value is used.
        Parameters:
        datamodel - DataModel instance
        params - Model's hyper-parameters values
      • DirMF

        public DirMF​(DataModel datamodel,
                     int numFactors,
                     int numIters,
                     double learningRate,
                     double regularization,
                     double[] ratings)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        numIters - Number of iterations
        learningRate - Learning rate
        regularization - Regularization
        ratings - Discrete ratings values
      • DirMF

        public DirMF​(DataModel datamodel,
                     int numFactors,
                     int numIters,
                     double learningRate,
                     double regularization,
                     double[] ratings,
                     long seed)
        Model constructor
        Parameters:
        datamodel - DataModel instance
        numFactors - Number of latent factors
        numIters - Number of iterations
        learningRate - Learning rate
        regularization - Regularization
        ratings - Discrete ratings values
        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
      • getLearningRate

        public double getLearningRate()
        Get the learning rate parameter of the model
        Returns:
        Learning rate
      • getRegularization

        public double getRegularization()
        Get the regularization parameter of the model
        Returns:
        Regularization
      • getRatings

        public double[] getRatings()
        Get the discrete ratings values
        Returns:
        Discrete ratings values
      • 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
      • predictProba

        public double predictProba​(int userIndex,
                                   int itemIndex)
        Computes a prediction probability
        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 probability