org.mymedialite.data
Class PosOnlyFeedback<T extends IBooleanMatrix>

java.lang.Object
  extended by org.mymedialite.data.DataSet
      extended by org.mymedialite.data.PosOnlyFeedback<T>
All Implemented Interfaces:
IDataSet, IPosOnlyFeedback

public class PosOnlyFeedback<T extends IBooleanMatrix>
extends DataSet
implements IPosOnlyFeedback

Data structure for implicit, positive-only user feedback. This data structure supports incremental updates.


Field Summary
 IBooleanMatrix itemMatrix
          By-item access, items are stored in the rows, users in the columns
 IBooleanMatrix userMatrix
          By-user access, users are stored in the rows, items in the columns
 
Fields inherited from class org.mymedialite.data.DataSet
byItem, byUser, items, maxItemID, maxUserID, users
 
Constructor Summary
PosOnlyFeedback(java.lang.Class<T> c)
          Create a PosOnlyFeedback object.
 
Method Summary
 void add(int user_id, int item_id)
          Add a user-item event to the data structure
 IBooleanMatrix getItemMatrixCopy()
          Get a copy of the item matrix
 IBooleanMatrix getUserMatrixCopy()
          Get a copy of the user matrix
 IBooleanMatrix itemMatrix()
          By-item access, items are stored in the rows, users in the columns.
 void remove(int index)
          Remove the event with a given index
 void remove(int user_id, int item_id)
          Remove a user-item event from the data structure.
 void removeItem(int item_id)
          Remove all feedback about a given item
 void removeUser(int user_id)
          Remove all feedback by a given user.
 IPosOnlyFeedback transpose()
          Get the transpose of the dataset (users and items exchanged)
 IBooleanMatrix userMatrix()
          By-user access, users are stored in the rows, items in the columns.
 
Methods inherited from class org.mymedialite.data.DataSet
allItems, allUsers, buildItemIndices, buildRandomIndex, buildUserIndices, byItem, byUser, getIndex, getIndex, getItems, getUsers, items, maxItemID, maxUserID, randomIndex, size, tryGetIndex, tryGetIndex, users
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mymedialite.data.IDataSet
allItems, allUsers, buildItemIndices, buildRandomIndex, buildUserIndices, byItem, byUser, getIndex, getIndex, getItems, getUsers, items, maxItemID, maxUserID, randomIndex, size, tryGetIndex, tryGetIndex, users
 

Field Detail

userMatrix

public IBooleanMatrix userMatrix
By-user access, users are stored in the rows, items in the columns


itemMatrix

public IBooleanMatrix itemMatrix
By-item access, items are stored in the rows, users in the columns

Constructor Detail

PosOnlyFeedback

public PosOnlyFeedback(java.lang.Class<T> c)
                throws java.lang.InstantiationException,
                       java.lang.IllegalAccessException
Create a PosOnlyFeedback object.

Parameters:
c - the Class
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
Method Detail

userMatrix

public IBooleanMatrix userMatrix()
By-user access, users are stored in the rows, items in the columns.

Specified by:
userMatrix in interface IPosOnlyFeedback

itemMatrix

public IBooleanMatrix itemMatrix()
By-item access, items are stored in the rows, users in the columns.

Specified by:
itemMatrix in interface IPosOnlyFeedback

getUserMatrixCopy

public IBooleanMatrix getUserMatrixCopy()
Description copied from interface: IPosOnlyFeedback
Get a copy of the user matrix

Specified by:
getUserMatrixCopy in interface IPosOnlyFeedback
Returns:
a copy of the user matrix

getItemMatrixCopy

public IBooleanMatrix getItemMatrixCopy()
Description copied from interface: IPosOnlyFeedback
Get a copy of the item matrix

Specified by:
getItemMatrixCopy in interface IPosOnlyFeedback
Returns:
a copy of the item matrix

add

public void add(int user_id,
                int item_id)
Add a user-item event to the data structure

Specified by:
add in interface IPosOnlyFeedback
Parameters:
user_id - the user ID
item_id - the item ID

remove

public void remove(int user_id,
                   int item_id)
Remove a user-item event from the data structure.

Specified by:
remove in interface IPosOnlyFeedback
Parameters:
user_id - the user ID
item_id - >the item ID

remove

public void remove(int index)
Remove the event with a given index

Parameters:
index - the index of the event to be removed

removeUser

public void removeUser(int user_id)
Remove all feedback by a given user.

Specified by:
removeUser in interface IDataSet
Parameters:
user_id - the user ID

removeItem

public void removeItem(int item_id)
Remove all feedback about a given item

Specified by:
removeItem in interface IDataSet
Parameters:
item_id - the item ID

transpose

public IPosOnlyFeedback transpose()
Description copied from interface: IPosOnlyFeedback
Get the transpose of the dataset (users and items exchanged)

Specified by:
transpose in interface IPosOnlyFeedback
Returns:
the transpose of the dataset