Class UpdateableFactorization<U,I>
java.lang.Object
es.uam.eps.ir.relison.links.recommendation.updateable.mf.UpdateableFactorization<U,I>
- Type Parameters:
U- type of the usersI- type of the items
- All Implemented Interfaces:
es.uam.eps.ir.ranksys.core.index.ItemIndex<I>,es.uam.eps.ir.ranksys.core.index.UserIndex<U>,es.uam.eps.ir.ranksys.fast.index.FastItemIndex<I>,es.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>,FastUpdateableItemIndex<I>,FastUpdateableUserIndex<U>,UpdateableItemIndex<I>,UpdateableUserIndex<U>
public class UpdateableFactorization<U,I> extends java.lang.Object implements FastUpdateableItemIndex<I>, FastUpdateableUserIndex<U>
Updateable version of a matrix factorization.
-
Field Summary
Fields Modifier and Type Field Description protected FastUpdateableItemIndex<I>iIndexitem indexprotected cern.colt.matrix.impl.DenseDoubleMatrix2DitemMatrixitem matrixprotected intKdimensionality of the vector spaceprotected FastUpdateableUserIndex<U>uIndexuser indexprotected cern.colt.matrix.impl.DenseDoubleMatrix2DuserMatrixuser matrix -
Constructor Summary
Constructors Constructor Description UpdateableFactorization(FastUpdateableUserIndex<U> uIndex, FastUpdateableItemIndex<I> iIndex, int K, cern.colt.function.DoubleFunction initFunction)Constructor.UpdateableFactorization(FastUpdateableUserIndex<U> uIndex, FastUpdateableItemIndex<I> iIndex, cern.colt.matrix.impl.DenseDoubleMatrix2D userMatrix, cern.colt.matrix.impl.DenseDoubleMatrix2D itemMatrix, int K)Constructor for stored factorizations. -
Method Summary
Modifier and Type Method Description intaddItem(I i)Adds a new item.intaddUser(U u)Adds a user to the index.booleancontainsItem(I i)booleancontainsUser(U u)cern.colt.matrix.impl.DenseDoubleMatrix2DgetItemMatrix()Returns the whole item matrix.cern.colt.matrix.DoubleMatrix1DgetItemVector(I i)Returns the row of the item matrix corresponding to the given item.intgetK()Returns the dimension of the latent feature space.cern.colt.matrix.impl.DenseDoubleMatrix2DgetUserMatrix()Returns the whole user matrix.cern.colt.matrix.DoubleMatrix1DgetUserVector(U u)Returns the row of the user matrix corresponding to the given user.Iiidx2item(int iidx)intitem2iidx(I i)intnumItems()intnumUsers()Uuidx2user(int uidx)intuser2uidx(U u)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex
getAllIidx, iidx2item, iidx2item, item2iidx, item2iidxMethods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.fast.FastUpdateableItemIndex
getAllItemsMethods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.fast.FastUpdateableUserIndex
getAllUsersMethods inherited from interface es.uam.eps.ir.ranksys.fast.index.FastUserIndex
getAllUidx, uidx2user, uidx2user, user2uidx, user2uidxMethods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.UpdateableItemIndex
addItemsMethods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.UpdateableUserIndex
addUsers
-
Field Details
-
userMatrix
protected cern.colt.matrix.impl.DenseDoubleMatrix2D userMatrixuser matrix -
itemMatrix
protected cern.colt.matrix.impl.DenseDoubleMatrix2D itemMatrixitem matrix -
K
protected final int Kdimensionality of the vector space -
uIndex
user index -
iIndex
item index
-
-
Constructor Details
-
UpdateableFactorization
public UpdateableFactorization(FastUpdateableUserIndex<U> uIndex, FastUpdateableItemIndex<I> iIndex, int K, cern.colt.function.DoubleFunction initFunction)Constructor.- Parameters:
uIndex- fast user indexiIndex- fast item indexK- dimension of the latent feature spaceinitFunction- function to initialize the cells of the matrices
-
UpdateableFactorization
public UpdateableFactorization(FastUpdateableUserIndex<U> uIndex, FastUpdateableItemIndex<I> iIndex, cern.colt.matrix.impl.DenseDoubleMatrix2D userMatrix, cern.colt.matrix.impl.DenseDoubleMatrix2D itemMatrix, int K)Constructor for stored factorizations.- Parameters:
uIndex- fast user indexiIndex- fast item indexuserMatrix- user matrixitemMatrix- item matrixK- dimension of the latent feature space
-
-
Method Details
-
numUsers
public int numUsers()- Specified by:
numUsersin interfacees.uam.eps.ir.ranksys.core.index.UserIndex<U>
-
user2uidx
- Specified by:
user2uidxin interfacees.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
-
uidx2user
- Specified by:
uidx2userin interfacees.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
-
numItems
public int numItems()- Specified by:
numItemsin interfacees.uam.eps.ir.ranksys.core.index.ItemIndex<U>
-
item2iidx
- Specified by:
item2iidxin interfacees.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>
-
iidx2item
- Specified by:
iidx2itemin interfacees.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>
-
containsUser
-
containsItem
-
getUserVector
Returns the row of the user matrix corresponding to the given user.- Parameters:
u- user- Returns:
- row of the user matrix
-
getItemVector
Returns the row of the item matrix corresponding to the given item.- Parameters:
i- item- Returns:
- row of the item matrix
-
getUserMatrix
public cern.colt.matrix.impl.DenseDoubleMatrix2D getUserMatrix()Returns the whole user matrix.- Returns:
- the whole user matrix
-
getItemMatrix
public cern.colt.matrix.impl.DenseDoubleMatrix2D getItemMatrix()Returns the whole item matrix.- Returns:
- the whole item matrix
-
getK
public int getK()Returns the dimension of the latent feature space.- Returns:
- the dimension of the latent feature space
-
addItem
Description copied from interface:UpdateableItemIndexAdds a new item.- Specified by:
addItemin interfaceUpdateableItemIndex<U>- Parameters:
i- the item.- Returns:
- the identifier of the new item
-
addUser
Description copied from interface:UpdateableUserIndexAdds a user to the index.- Specified by:
addUserin interfaceUpdateableUserIndex<U>- Parameters:
u- the user.- Returns:
- the identifier of the new user.
-