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>
iIndex
item indexprotected cern.colt.matrix.impl.DenseDoubleMatrix2D
itemMatrix
item matrixprotected int
K
dimensionality of the vector spaceprotected FastUpdateableUserIndex<U>
uIndex
user indexprotected cern.colt.matrix.impl.DenseDoubleMatrix2D
userMatrix
user 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 int
addItem(I i)
Adds a new item.int
addUser(U u)
Adds a user to the index.boolean
containsItem(I i)
boolean
containsUser(U u)
cern.colt.matrix.impl.DenseDoubleMatrix2D
getItemMatrix()
Returns the whole item matrix.cern.colt.matrix.DoubleMatrix1D
getItemVector(I i)
Returns the row of the item matrix corresponding to the given item.int
getK()
Returns the dimension of the latent feature space.cern.colt.matrix.impl.DenseDoubleMatrix2D
getUserMatrix()
Returns the whole user matrix.cern.colt.matrix.DoubleMatrix1D
getUserVector(U u)
Returns the row of the user matrix corresponding to the given user.I
iidx2item(int iidx)
int
item2iidx(I i)
int
numItems()
int
numUsers()
U
uidx2user(int uidx)
int
user2uidx(U u)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex
getAllIidx, iidx2item, iidx2item, item2iidx, item2iidx
Methods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.fast.FastUpdateableItemIndex
getAllItems
Methods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.fast.FastUpdateableUserIndex
getAllUsers
Methods inherited from interface es.uam.eps.ir.ranksys.fast.index.FastUserIndex
getAllUidx, uidx2user, uidx2user, user2uidx, user2uidx
Methods inherited from interface es.uam.eps.ir.relison.links.data.updateable.index.UpdateableItemIndex
addItems
Methods 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:
numUsers
in interfacees.uam.eps.ir.ranksys.core.index.UserIndex<U>
-
user2uidx
- Specified by:
user2uidx
in interfacees.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
-
uidx2user
- Specified by:
uidx2user
in interfacees.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
-
numItems
public int numItems()- Specified by:
numItems
in interfacees.uam.eps.ir.ranksys.core.index.ItemIndex<U>
-
item2iidx
- Specified by:
item2iidx
in interfacees.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>
-
iidx2item
- Specified by:
iidx2item
in 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:UpdateableItemIndex
Adds a new item.- Specified by:
addItem
in interfaceUpdateableItemIndex<U>
- Parameters:
i
- the item.- Returns:
- the identifier of the new item
-
addUser
Description copied from interface:UpdateableUserIndex
Adds a user to the index.- Specified by:
addUser
in interfaceUpdateableUserIndex<U>
- Parameters:
u
- the user.- Returns:
- the identifier of the new user.
-