Class ALSUpdateableFactorizer<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>
Type Parameters:
U - type of the users
I - type of the items
Direct Known Subclasses:
HKVUpdateableFactorizer

public abstract class ALSUpdateableFactorizer<U,​I>
extends UpdateableFactorizer<U,​I>
Updateable alternate least squares factorizer. Abstract class for matrix factorization algorithms.
  • Field Details

    • numIter

      private final int numIter
      Number of iterations.
    • LOG

      private static final java.util.logging.Logger LOG
      The log.
  • Constructor Details

    • ALSUpdateableFactorizer

      public ALSUpdateableFactorizer​(int numIter)
      Constructor.
      Parameters:
      numIter - number of iterations.
  • Method Details

    • error

      public double error​(UpdateableFactorization<U,​I> factorization, FastUpdateablePreferenceData<U,​I> data)
      Global loss of the factorization.
      Specified by:
      error in class UpdateableFactorizer<U,​I>
      Parameters:
      factorization - matrix factorization
      data - preference data
      Returns:
      the global loss
    • factorize

      public UpdateableFactorization<U,​I> factorize​(int K, FastUpdateablePreferenceData<U,​I> data)
      Creates and calculates a factorization.
      Specified by:
      factorize in class UpdateableFactorizer<U,​I>
      Parameters:
      K - size of the latent feature space.
      data - preference data
      Returns:
      a matrix factorization
    • factorize

      public void factorize​(UpdateableFactorization<U,​I> factorization, FastUpdateablePreferenceData<U,​I> data)
      Calculates the factorization by using a previously generate matrix factorization.
      Specified by:
      factorize in class UpdateableFactorizer<U,​I>
      Parameters:
      factorization - matrix factorization
      data - preference data
    • update

      public void update​(UpdateableFactorization<U,​I> factorization, FastUpdateablePreferenceData<U,​I> data, U u, I i, double weight)
      Updates a factorization, when a new rating is received.
      Specified by:
      update in class UpdateableFactorizer<U,​I>
      Parameters:
      factorization - the factorization.
      u - updated user
      i - updated item
      weight - the weight
      data - the updated data.
    • updateDelete

      public void updateDelete​(UpdateableFactorization<U,​I> factorization, FastUpdateablePreferenceData<U,​I> data, U u, I i)
      Updates a factorization, when a new rating is removed.
      Specified by:
      updateDelete in class UpdateableFactorizer<U,​I>
      Parameters:
      factorization - the factorization.
      u - updated user
      i - updated item
      data - the updated data.
    • error

      protected abstract double error​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
      Squared loss of two matrices.
      Parameters:
      p - user matrix
      q - item matrix
      data - preference data
      Returns:
      squared loss
    • set_minP

      protected abstract void set_minP​(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,​I> data)
      User matrix least-squares step.
      Parameters:
      p - user matrix
      q - item matrix
      data - preference data
    • set_minQ

      protected abstract void set_minQ​(cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,​I> data)
      Item matrix least-squares step.
      Parameters:
      q - item matrix
      p - user matrix
      data - preference data
    • set_minP

      protected abstract 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.
      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 abstract 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.
      Parameters:
      i - the item
      q - item matrix
      p - user matrix
      data - preference data
      Returns:
      a vector containing the vector for item i