Data structure for storing ratings with time information. More...
Public Member Functions | |
void | Add (double item) |
virtual void | Add (int user_id, int item_id, byte rating) |
Add byte-valued rating to the collection. | |
virtual void | Add (int user_id, int item_id, float rating) |
Add float-valued rating to the collection. | |
virtual void | Add (int user_id, int item_id, double rating, DateTime time) |
add a rating event including time information | |
override void | Add (int user_id, int item_id, double rating) |
Add a new rating. | |
void | BuildByItemCounts () |
void | BuildByUserCounts () |
void | BuildItemIndices () |
Build the item indices. | |
void | BuildRandomIndex () |
Build the random index. | |
void | BuildUserIndices () |
Build the user indices. | |
void | Clear () |
bool | Contains (double item) |
void | CopyTo (double[] array, int index) |
virtual double | Get (int user_id, int item_id, ICollection< int > indexes) |
Directly access rating by user and item. | |
double | Get (int user_id, int item_id) |
Directly access rating by user and item. | |
int | GetIndex (int user_id, int item_id, ICollection< int > indexes) |
Get index for given user and item. | |
int | GetIndex (int user_id, int item_id) |
Get index for a given user and item. | |
ISet< int > | GetItems (IList< int > indices) |
Get all items that are referenced by a given list of indices. | |
ISet< int > | GetUsers (IList< int > indices) |
Get all users that are referenced by a given list of indices. | |
int | IndexOf (double item) |
void | Insert (int index, double item) |
bool | Remove (double item) |
virtual void | RemoveAt (int index) |
override void | RemoveItem (int item_id) |
Remove all events related to a given item. | |
override void | RemoveUser (int user_id) |
Remove all events related to a given user. | |
TimedRatings () | |
Default constructor. | |
virtual bool | TryGet (int user_id, int item_id, ICollection< int > indexes, out double rating) |
Try to retrieve a rating for a given user-item combination. | |
virtual bool | TryGet (int user_id, int item_id, out double rating) |
Try to retrieve a rating for a given user-item combination. | |
bool | TryGetIndex (int user_id, int item_id, ICollection< int > indexes, out int index) |
Try to get the index for given user and item. | |
bool | TryGetIndex (int user_id, int item_id, out int index) |
Try to get the index for given user and item. | |
Protected Attributes | |
IList< IList< int > > | by_item |
Rating indices organized by item. | |
IList< IList< int > > | by_user |
Rating indices organized by user. | |
IList< double > | Values |
Properties | |
IList< int > | AllItems [get] |
all item IDs in the dataset | |
IList< int > | AllUsers [get] |
all user IDs in the dataset | |
double | Average [get] |
average rating in the dataset | |
IList< IList< int > > | ByItem [get] |
indices by item | |
IList< IList< int > > | ByUser [get] |
indices by user | |
virtual int | Count [get] |
IList< int > | CountByItem [get] |
rating count by item | |
IList< int > | CountByUser [get] |
rating count by user | |
DateTime | EarliestTime [get, set] |
earliest time | |
bool | IsReadOnly [get] |
IList< int > | Items [get, set] |
the item entries | |
DateTime | LatestTime [get, set] |
latest time | |
int | MaxItemID [get, set] |
the maximum item ID in the dataset | |
double | MaxRating [get] |
the maximum rating in the dataset | |
double | MaxRating [get, set] |
int | MaxUserID [get, set] |
the maximum user ID in the dataset | |
double | MinRating [get] |
the minimum rating in the dataset | |
double | MinRating [get, set] |
IList< int > | RandomIndex [get] |
get a randomly ordered list of all indices | |
virtual double | this [int index] [get, set] |
Directly access rating by user and item. | |
IList< DateTime > | Times [get, set] |
the item entries | |
IList< int > | Users [get, set] |
the user entries |
Data structure for storing ratings with time information.
Small memory overhead for added flexibility.
This data structure supports incremental updates.
Loading the Netflix Prize data set (100,000,000 ratings) into this data structure requires about 3.2 GB of memory.
TimedRatings | ( | ) | [inline] |
Default constructor.
virtual void Add | ( | int | user_id, | |
int | item_id, | |||
byte | rating | |||
) | [inline, virtual, inherited] |
Add byte-valued rating to the collection.
user_id | the user ID | |
item_id | the item ID | |
rating | the rating |
Implements IRatings.
Reimplemented in StaticByteRatings, and StaticFloatRatings.
virtual void Add | ( | int | user_id, | |
int | item_id, | |||
float | rating | |||
) | [inline, virtual, inherited] |
Add float-valued rating to the collection.
user_id | the user ID | |
item_id | the item ID | |
rating | the rating |
Implements IRatings.
Reimplemented in StaticFloatRatings.
virtual void Add | ( | int | user_id, | |
int | item_id, | |||
double | rating, | |||
DateTime | time | |||
) | [inline, virtual] |
add a rating event including time information
user_id | the user ID | |
item_id | the item ID | |
rating | the rating value | |
time | A DateTime specifying the time of the rating event |
Implements ITimedRatings.
override void Add | ( | int | user_id, | |
int | item_id, | |||
double | rating | |||
) | [inline, virtual] |
Add a new rating.
user_id | the user ID | |
item_id | the item ID | |
rating | the rating value |
Reimplemented from Ratings.
void BuildItemIndices | ( | ) | [inline, inherited] |
Build the item indices.
Implements IDataSet.
void BuildRandomIndex | ( | ) | [inline, inherited] |
Build the random index.
Implements IDataSet.
void BuildUserIndices | ( | ) | [inline, inherited] |
Build the user indices.
Implements IDataSet.
virtual double Get | ( | int | user_id, | |
int | item_id, | |||
ICollection< int > | indexes | |||
) | [inline, virtual, inherited] |
Directly access rating by user and item.
user_id | the user ID | |
item_id | the item ID | |
indexes | the indexes to look at |
Implements IRatings.
Reimplemented in StaticByteRatings, and StaticFloatRatings.
double Get | ( | int | user_id, | |
int | item_id | |||
) | [inline, inherited] |
Directly access rating by user and item.
user_id | the user ID | |
item_id | the item ID |
Implements IRatings.
int GetIndex | ( | int | user_id, | |
int | item_id, | |||
ICollection< int > | indexes | |||
) | [inline, inherited] |
Get index for given user and item.
user_id | the user ID | |
item_id | the item ID | |
indexes | the indexes to look at |
Implements IRatings.
int GetIndex | ( | int | user_id, | |
int | item_id | |||
) | [inline, inherited] |
Get index for a given user and item.
user_id | the user ID | |
item_id | the item ID |
Implements IRatings.
ISet<int> GetItems | ( | IList< int > | indices | ) | [inline, inherited] |
Get all items that are referenced by a given list of indices.
indices | the indices to take into account |
Implements IRatings.
ISet<int> GetUsers | ( | IList< int > | indices | ) | [inline, inherited] |
Get all users that are referenced by a given list of indices.
indices | the indices to take into account |
Implements IRatings.
override void RemoveItem | ( | int | item_id | ) | [inline, virtual, inherited] |
Remove all events related to a given item.
item_id | the item ID |
Implements DataSet.
Reimplemented in StaticRatings.
override void RemoveUser | ( | int | user_id | ) | [inline, virtual, inherited] |
Remove all events related to a given user.
user_id | the user ID |
Implements DataSet.
Reimplemented in StaticRatings.
virtual bool TryGet | ( | int | user_id, | |
int | item_id, | |||
ICollection< int > | indexes, | |||
out double | rating | |||
) | [inline, virtual, inherited] |
Try to retrieve a rating for a given user-item combination.
user_id | the user ID | |
item_id | the item ID | |
indexes | the indexes to look at | |
rating | will contain the first rating encountered that matches the user ID and item ID |
Implements IRatings.
Reimplemented in StaticByteRatings, and StaticFloatRatings.
virtual bool TryGet | ( | int | user_id, | |
int | item_id, | |||
out double | rating | |||
) | [inline, virtual, inherited] |
Try to retrieve a rating for a given user-item combination.
user_id | the user ID | |
item_id | the item ID | |
rating | will contain the first rating encountered that matches the user ID and item ID |
Implements IRatings.
Reimplemented in StaticByteRatings, and StaticFloatRatings.
bool TryGetIndex | ( | int | user_id, | |
int | item_id, | |||
ICollection< int > | indexes, | |||
out int | index | |||
) | [inline, inherited] |
Try to get the index for given user and item.
user_id | the user ID | |
item_id | the item ID | |
indexes | the indexes to look at | |
index | will contain the index of the first event encountered that matches the user ID and item ID |
Implements IRatings.
bool TryGetIndex | ( | int | user_id, | |
int | item_id, | |||
out int | index | |||
) | [inline, inherited] |
Try to get the index for given user and item.
user_id | the user ID | |
item_id | the item ID | |
index | will contain the index of the first event encountered that matches the user ID and item ID |
Implements IRatings.
IList<IList<int> > by_item [protected, inherited] |
Rating indices organized by item.
IList<IList<int> > by_user [protected, inherited] |
Rating indices organized by user.
IList<int> AllItems [get, inherited] |
all item IDs in the dataset
Implements IDataSet.
IList<int> AllUsers [get, inherited] |
all user IDs in the dataset
Implements IDataSet.
double Average [get, inherited] |
average rating in the dataset
Implements IRatings.
IList<IList<int> > ByItem [get, inherited] |
IList<IList<int> > ByUser [get, inherited] |
IList<int> CountByItem [get, inherited] |
IList<int> CountByUser [get, inherited] |
DateTime EarliestTime [get, set] |
earliest time
Implements ITimedDataSet.
IList<int> Items [get, set, inherited] |
the item entries
Implements IDataSet.
DateTime LatestTime [get, set] |
latest time
Implements ITimedDataSet.
int MaxItemID [get, set, inherited] |
the maximum item ID in the dataset
Implements IDataSet.
double MaxRating [get, inherited] |
the maximum rating in the dataset
int MaxUserID [get, set, inherited] |
the maximum user ID in the dataset
Implements IDataSet.
double MinRating [get, inherited] |
the minimum rating in the dataset
IList<int> RandomIndex [get, inherited] |
get a randomly ordered list of all indices
Should be implemented as a lazy data structure
Implements IDataSet.
double this [get, set, inherited] |
Directly access rating by user and item.
user_id | the user ID | |
item_id | the item ID |
Implements IRatings.
Reimplemented in StaticByteRatings, and StaticFloatRatings.
IList<DateTime> Times [get, set] |
the item entries
Implements ITimedDataSet.
IList<int> Users [get, set, inherited] |
the user entries
Implements IDataSet.