Class HKVUpdateableFactorizer<U,​I>

java.lang.Object
es.uam.eps.ir.relison.links.recommendation.updateable.mf.UpdateableFactorizer<U,​I>
es.uam.eps.ir.relison.links.recommendation.updateable.mf.als.ALSUpdateableFactorizer<U,​I>
es.uam.eps.ir.relison.links.recommendation.updateable.mf.als.HKVUpdateableFactorizer<U,​I>
Type Parameters:
U - type of the users
I - type of the items

public class HKVUpdateableFactorizer<U,​I>
extends ALSUpdateableFactorizer<U,​I>
Implicit matrix factorization of Hu, Koren and Volinsky.

Reference: Y. Hu, Y. Koren, C. Volinsky. Collaborative filtering for implicit feedback datasets. 8th Annual IEEE International Conference on Data Mining (ICDM 2008), 263-272 (2008).

  • Field Summary

    Fields 
    Modifier and Type Field Description
    private static cern.colt.matrix.linalg.Algebra ALG
    An algebra.
    private java.util.function.DoubleUnaryOperator confidence
    Confidence function.
    private double lambdaP
    Regularization factor for the user vectors.
    private double lambdaQ
    Regularization factor for the item vectors.
  • Constructor Summary

    Constructors 
    Constructor Description
    HKVUpdateableFactorizer​(double lambdaP, double lambdaQ, java.util.function.DoubleUnaryOperator confidence, int numIter)
    Constructor.
    HKVUpdateableFactorizer​(double lambda, java.util.function.DoubleUnaryOperator confidence, int numIter)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    double error​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
    Squared loss of two matrices.
    private static <U,​ I,​ O> cern.colt.matrix.DoubleMatrix1D set_min​(int idx, cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, java.util.function.DoubleUnaryOperator confidence, double lambda, FastUpdateablePreferenceData<U,​I> data)  
    private static <U,​ I,​ O> void set_min​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, java.util.function.DoubleUnaryOperator confidence, double lambda, FastUpdateablePreferenceData<U,​I> data)  
    void set_minP​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
    User matrix least-squares step.
    protected cern.colt.matrix.DoubleMatrix1D set_minP​(U u, cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
    User matrix least-squares step.
    void set_minQ​(cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,​I> data)
    Item matrix least-squares step.
    protected cern.colt.matrix.DoubleMatrix1D set_minQ​(I i, cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,​I> data)
    Item matrix least-squares step.

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.updateable.mf.als.ALSUpdateableFactorizer

    error, factorize, factorize, update, updateDelete

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ALG

      private static final cern.colt.matrix.linalg.Algebra ALG
      An algebra.
    • lambdaP

      private final double lambdaP
      Regularization factor for the user vectors.
    • lambdaQ

      private final double lambdaQ
      Regularization factor for the item vectors.
    • confidence

      private final java.util.function.DoubleUnaryOperator confidence
      Confidence function.
  • Constructor Details

    • HKVUpdateableFactorizer

      public HKVUpdateableFactorizer​(double lambda, java.util.function.DoubleUnaryOperator confidence, int numIter)
      Constructor. Same regularization factor for user and item matrices.
      Parameters:
      lambda - regularization factor
      confidence - confidence function
      numIter - number of iterations
    • HKVUpdateableFactorizer

      public HKVUpdateableFactorizer​(double lambdaP, double lambdaQ, java.util.function.DoubleUnaryOperator confidence, int numIter)
      Constructor. Different regularization factors for user and item matrices.
      Parameters:
      lambdaP - regularization factor for user matrix
      lambdaQ - regularization factor for item matrix
      confidence - confidence function
      numIter - number of iterations
  • Method Details

    • error

      public double error​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
      Description copied from class: ALSUpdateableFactorizer
      Squared loss of two matrices.
      Specified by:
      error in class ALSUpdateableFactorizer<U,​I>
      Parameters:
      p - user matrix
      q - item matrix
      data - preference data
      Returns:
      squared loss
    • set_minP

      public void set_minP​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
      Description copied from class: ALSUpdateableFactorizer
      User matrix least-squares step.
      Specified by:
      set_minP in class ALSUpdateableFactorizer<U,​I>
      Parameters:
      p - user matrix
      q - item matrix
      data - preference data
    • set_minQ

      public void set_minQ​(cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,​I> data)
      Description copied from class: ALSUpdateableFactorizer
      Item matrix least-squares step.
      Specified by:
      set_minQ in class ALSUpdateableFactorizer<U,​I>
      Parameters:
      q - item matrix
      p - user matrix
      data - preference data
    • set_min

      private static <U,​ I,​ O> void set_min​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, java.util.function.DoubleUnaryOperator confidence, double lambda, FastUpdateablePreferenceData<U,​I> data)
    • set_min

      private static <U,​ I,​ O> cern.colt.matrix.DoubleMatrix1D set_min​(int idx, cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, java.util.function.DoubleUnaryOperator confidence, double lambda, FastUpdateablePreferenceData<U,​I> data)
    • set_minP

      protected cern.colt.matrix.DoubleMatrix1D set_minP​(U u, cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
      Description copied from class: ALSUpdateableFactorizer
      User matrix least-squares step.
      Specified by:
      set_minP in class ALSUpdateableFactorizer<U,​I>
      Parameters:
      u - the user
      p - user matrix
      q - item matrix
      data - preference data
      Returns:
      a vector containing the vector for user u
    • set_minQ

      protected cern.colt.matrix.DoubleMatrix1D set_minQ​(I i, cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,​I> data)
      Description copied from class: ALSUpdateableFactorizer
      Item matrix least-squares step.
      Specified by:
      set_minQ in class ALSUpdateableFactorizer<U,​I>
      Parameters:
      i - the item
      q - item matrix
      p - user matrix
      data - preference data
      Returns:
      a vector containing the vector for item i