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 users
I - 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 index
    protected cern.colt.matrix.impl.DenseDoubleMatrix2D itemMatrix
    item matrix
    protected int K
    dimensionality of the vector space
    protected FastUpdateableUserIndex<U> uIndex
    user index
    protected 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

  • Constructor Details

    • UpdateableFactorization

      public UpdateableFactorization​(FastUpdateableUserIndex<U> uIndex, FastUpdateableItemIndex<I> iIndex, int K, cern.colt.function.DoubleFunction initFunction)
      Constructor.
      Parameters:
      uIndex - fast user index
      iIndex - fast item index
      K - dimension of the latent feature space
      initFunction - 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 index
      iIndex - fast item index
      userMatrix - user matrix
      itemMatrix - item matrix
      K - dimension of the latent feature space
  • Method Details

    • numUsers

      public int numUsers()
      Specified by:
      numUsers in interface es.uam.eps.ir.ranksys.core.index.UserIndex<U>
    • user2uidx

      public int user2uidx​(U u)
      Specified by:
      user2uidx in interface es.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
    • uidx2user

      public U uidx2user​(int uidx)
      Specified by:
      uidx2user in interface es.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
    • numItems

      public int numItems()
      Specified by:
      numItems in interface es.uam.eps.ir.ranksys.core.index.ItemIndex<U>
    • item2iidx

      public int item2iidx​(I i)
      Specified by:
      item2iidx in interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>
    • iidx2item

      public I iidx2item​(int iidx)
      Specified by:
      iidx2item in interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>
    • containsUser

      public boolean containsUser​(U u)
      Specified by:
      containsUser in interface es.uam.eps.ir.ranksys.fast.index.FastUserIndex<U>
      Specified by:
      containsUser in interface es.uam.eps.ir.ranksys.core.index.UserIndex<U>
    • containsItem

      public boolean containsItem​(I i)
      Specified by:
      containsItem in interface es.uam.eps.ir.ranksys.fast.index.FastItemIndex<U>
      Specified by:
      containsItem in interface es.uam.eps.ir.ranksys.core.index.ItemIndex<U>
    • getUserVector

      public cern.colt.matrix.DoubleMatrix1D getUserVector​(U u)
      Returns the row of the user matrix corresponding to the given user.
      Parameters:
      u - user
      Returns:
      row of the user matrix
    • getItemVector

      public cern.colt.matrix.DoubleMatrix1D getItemVector​(I i)
      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

      public int addItem​(I i)
      Description copied from interface: UpdateableItemIndex
      Adds a new item.
      Specified by:
      addItem in interface UpdateableItemIndex<U>
      Parameters:
      i - the item.
      Returns:
      the identifier of the new item
    • addUser

      public int addUser​(U u)
      Description copied from interface: UpdateableUserIndex
      Adds a user to the index.
      Specified by:
      addUser in interface UpdateableUserIndex<U>
      Parameters:
      u - the user.
      Returns:
      the identifier of the new user.