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 usersI
- 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
-
Field Details
-
ALG
private static final cern.colt.matrix.linalg.Algebra ALGAn algebra. -
lambdaP
private final double lambdaPRegularization factor for the user vectors. -
lambdaQ
private final double lambdaQRegularization factor for the item vectors. -
confidence
private final java.util.function.DoubleUnaryOperator confidenceConfidence 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 factorconfidence
- confidence functionnumIter
- 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 matrixlambdaQ
- regularization factor for item matrixconfidence
- confidence functionnumIter
- 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 classALSUpdateableFactorizer<U,I>
- Parameters:
p
- user matrixq
- item matrixdata
- 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 classALSUpdateableFactorizer<U,I>
- Parameters:
p
- user matrixq
- item matrixdata
- 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 classALSUpdateableFactorizer<U,I>
- Parameters:
q
- item matrixp
- user matrixdata
- 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 classALSUpdateableFactorizer<U,I>
- Parameters:
u
- the userp
- user matrixq
- item matrixdata
- 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 classALSUpdateableFactorizer<U,I>
- Parameters:
i
- the itemq
- item matrixp
- user matrixdata
- preference data- Returns:
- a vector containing the vector for item i
-