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 usersI- 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 Summary
-
Constructor Summary
Constructors Constructor Description ALSUpdateableFactorizer(int numIter)Constructor. -
Method Summary
Modifier and Type Method Description protected abstract doubleerror(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,I> data)Squared loss of two matrices.doubleerror(UpdateableFactorization<U,I> factorization, FastUpdateablePreferenceData<U,I> data)Global loss of the factorization.UpdateableFactorization<U,I>factorize(int K, FastUpdateablePreferenceData<U,I> data)Creates and calculates a factorization.voidfactorize(UpdateableFactorization<U,I> factorization, FastUpdateablePreferenceData<U,I> data)Calculates the factorization by using a previously generate matrix factorization.protected abstract voidset_minP(cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,I> data)User matrix least-squares step.protected abstract cern.colt.matrix.DoubleMatrix1Dset_minP(U u, cern.colt.matrix.impl.DenseDoubleMatrix2D p, cern.colt.matrix.impl.DenseDoubleMatrix2D q, FastUpdateablePreferenceData<U,I> data)User matrix least-squares step.protected abstract voidset_minQ(cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,I> data)Item matrix least-squares step.protected abstract cern.colt.matrix.DoubleMatrix1Dset_minQ(I i, cern.colt.matrix.impl.DenseDoubleMatrix2D q, cern.colt.matrix.impl.DenseDoubleMatrix2D p, FastUpdateablePreferenceData<U,I> data)Item matrix least-squares step.voidupdate(UpdateableFactorization<U,I> factorization, FastUpdateablePreferenceData<U,I> data, U u, I i, double weight)Updates a factorization, when a new rating is received.voidupdateDelete(UpdateableFactorization<U,I> factorization, FastUpdateablePreferenceData<U,I> data, U u, I i)Updates a factorization, when a new rating is removed.
-
Field Details
-
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:
errorin classUpdateableFactorizer<U,I>- Parameters:
factorization- matrix factorizationdata- preference data- Returns:
- the global loss
-
factorize
Creates and calculates a factorization.- Specified by:
factorizein classUpdateableFactorizer<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:
factorizein classUpdateableFactorizer<U,I>- Parameters:
factorization- matrix factorizationdata- 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:
updatein classUpdateableFactorizer<U,I>- Parameters:
factorization- the factorization.u- updated useri- updated itemweight- the weightdata- 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:
updateDeletein classUpdateableFactorizer<U,I>- Parameters:
factorization- the factorization.u- updated useri- updated itemdata- 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 matrixq- item matrixdata- 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 matrixq- item matrixdata- 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 matrixp- user matrixdata- 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 userp- user matrixq- item matrixdata- 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 itemq- item matrixp- user matrixdata- preference data- Returns:
- a vector containing the vector for item i
-