org.mymedialite.data
Interface IDataSet

All Known Subinterfaces:
IPosOnlyFeedback, IRatings, ITimedDataSet, ITimedRatings
All Known Implementing Classes:
CombinedRatings, DataSet, PosOnlyFeedback, Ratings, RatingsProxy, StaticByteRatings, StaticFloatRatings, StaticRatings, TimedRatings, TimedRatingsProxy

public interface IDataSet

Interface for different kinds of collaborative filtering data sets. Implementing classes/inheriting interfaces are e.g. for rating data and for positive-only implicit feedback. The main feature of a dataset is that it has some kind of order (not explicitly stated) - random, chronological, user-wise, or item-wise - and that it contains tuples of users and items (not necessarily unique tuples). Implementing classes and inheriting interfaces can add additional data to each user-item tuple, e.g. the date/time of an event, location, context, etc., as well as additional index structures to access the dataset in a certain fashion.


Method Summary
 IntList allItems()
           
 IntList allUsers()
           
 void buildItemIndices()
          Build the item indices.
 void buildRandomIndex()
          Build the random index.
 void buildUserIndices()
          Build the user indices.
 java.util.List<IntList> byItem()
          indices by item.
 java.util.List<IntList> byUser()
          indices by user.
 int getIndex(int user_id, int item_id)
          Get index for a given user and item.
 int getIndex(int user_id, int item_id, IntCollection indexes)
          Get index for given user and item.
 IntSet getItems(IntList indices)
          Get all items that are referenced by a given list of indices.
 IntSet getUsers(IntList indices)
          Get all users that are referenced by a given list of indices.
 IntList items()
           
 int maxItemID()
           
 int maxUserID()
           
 IntList randomIndex()
          get a randomly ordered list of all indices.
 void removeItem(int item_id)
          Remove all events related to a given item.
 void removeUser(int user_id)
          Remove all events related to a given user.
 int size()
           
 java.lang.Integer tryGetIndex(int user_id, int item_id)
          Try to get the index for given user and item.
 java.lang.Integer tryGetIndex(int user_id, int item_id, IntCollection indexes)
          Try to get the index for given user and item.
 IntList users()
           
 

Method Detail

size

int size()
Returns:
the number of interaction events in the dataset.

users

IntList users()
Returns:
the user entries.

items

IntList items()
Returns:
the item entries.

maxUserID

int maxUserID()
Returns:
the maximum user ID in the dataset.

maxItemID

int maxItemID()
Returns:
the maximum item ID in the dataset.

allUsers

IntList allUsers()
Returns:
all user IDs in the dataset.

allItems

IntList allItems()
Returns:
all item IDs in the dataset.

byUser

java.util.List<IntList> byUser()
indices by user. Should be implemented as a lazy data structure


byItem

java.util.List<IntList> byItem()
indices by item. Should be implemented as a lazy data structure


randomIndex

IntList randomIndex()
get a randomly ordered list of all indices. Should be implemented as a lazy data structure


buildUserIndices

void buildUserIndices()
Build the user indices.


buildItemIndices

void buildItemIndices()
Build the item indices.


buildRandomIndex

void buildRandomIndex()
Build the random index.


removeUser

void removeUser(int user_id)
Remove all events related to a given user.

Parameters:
user_id - the user ID

removeItem

void removeItem(int item_id)
Remove all events related to a given item.

Parameters:
item_id - the item ID

getUsers

IntSet getUsers(IntList indices)
Get all users that are referenced by a given list of indices.

Parameters:
indices - the indices to take into account
Returns:
all users referenced by the list of indices

getItems

IntSet getItems(IntList indices)
Get all items that are referenced by a given list of indices.

Parameters:
indices - the indices to take into account
Returns:
all items referenced by the list of indices

getIndex

int getIndex(int user_id,
             int item_id)
Get index for a given user and item.

Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the index of the first event encountered that matches the user ID and item ID

getIndex

int getIndex(int user_id,
             int item_id,
             IntCollection indexes)
Get index for given user and item.

Parameters:
user_id - the user ID
item_id - the item ID
indexes - the indexes to look at
Returns:
the index of the first event encountered that matches the user ID and item ID

tryGetIndex

java.lang.Integer tryGetIndex(int user_id,
                              int item_id)
Try to get the index for given user and item.

Parameters:
user_id - the user ID
item_id - the item ID
Returns:
the index of the first event encountered that matches the user ID and item ID or null, if not found

tryGetIndex

java.lang.Integer tryGetIndex(int user_id,
                              int item_id,
                              IntCollection indexes)
Try to get the index for given user and item.

Parameters:
user_id - the user ID
item_id - the item ID
indexes - the indexes to look at
Returns:
the index of the first event encountered that matches the user ID and item ID or null, if not found