Class BRISMFPredictor

  • All Implemented Interfaces:
    Updatable

    public class BRISMFPredictor
    extends Object
    implements Updatable
    Implementation of the algorithm described in Scalable Collaborative Filtering Approaches for Large Recommender Systems (Gábor Takács, István Pilászy, Bottyán Németh, and Domonkos Tikk). A feature vector is learned for every user and item, so that the prediction of a rating is roughly the dot product of the corresponding user and item vector. Stochastic gradient descent is used to train the model, minimizing its prediction error. Both Tikhonov regularization and early stopping are used to reduce overfitting. The algorithm allows batch training (from scratch, using all ratings available at the moment) as well as incremental, by retraining only the affected user and item vectors when a new rating is inserted.

    Parameters:

    • features - the number of features to be trained for each user and item
    • learning rate - the learning rate used in the regularization
    • ratio - the regularization ratio to be used in the Tikhonov regularization
    • iterations - the number of iterations to be used when retraining user and item features (online training).
    • Field Detail

      • nFeatures

        protected int nFeatures
      • lRate

        protected double lRate
      • rFactor

        protected double rFactor
      • nIterations

        protected int nIterations
    • Constructor Detail

      • BRISMFPredictor

        public BRISMFPredictor​(int nFeatures,
                               RecommenderData data,
                               boolean train)
      • BRISMFPredictor

        public BRISMFPredictor​(int nFeatures,
                               RecommenderData data,
                               double lRate,
                               double rFactor,
                               boolean train)
    • Method Detail

      • setLRate

        public void setLRate​(double lRate)
      • setRFactor

        public void setRFactor​(double rFactor)
      • setNIterations

        public void setNIterations​(int nIterations)
      • predictRating

        public double predictRating​(int userID,
                                    int itemID)
      • predictRating

        public double predictRating​(float[] userFeats,
                                    float[] itemFeats)
      • trainItemFeats

        public float[] trainItemFeats​(int itemID,
                                      List<Integer> usr,
                                      List<Double> rat,
                                      int nIts)
      • trainUser

        public void trainUser​(int userID,
                              int nIts)
      • trainItem

        public void trainItem​(int itemID)
      • trainItem

        public void trainItem​(int itemID,
                              int nIts)
      • trainUser

        public void trainUser​(int userID)
      • train

        public void train()
      • getUserFeatures

        public float[] getUserFeatures​(int userID)
      • getItemFeatures

        public float[] getItemFeatures​(int itemID)
      • getNumFeatures

        public int getNumFeatures()
      • updateSetRating

        public void updateSetRating​(int userID,
                                    int itemID,
                                    double rating)
        Specified by:
        updateSetRating in interface Updatable
      • updateRemoveRating

        public void updateRemoveRating​(int userID,
                                       int itemID)
        Specified by:
        updateRemoveRating in interface Updatable