|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mymedialite.data.DataSet
org.mymedialite.data.Ratings
public class Ratings
Data structure for storing ratings Small memory overhead for added flexibility. This data structure supports incremental updates.
Field Summary | |
---|---|
protected double |
maxRating
|
protected double |
minRating
|
protected DoubleList |
values
|
Fields inherited from class org.mymedialite.data.DataSet |
---|
byItem, byUser, items, maxItemID, maxUserID, users |
Constructor Summary | |
---|---|
Ratings()
|
Method Summary | |
---|---|
void |
add(int user_id,
int item_id,
byte rating)
Add byte-valued rating to the collection. |
void |
add(int user_id,
int item_id,
double rating)
Add a new rating. |
void |
add(int user_id,
int item_id,
float rating)
Add float-valued rating to the collection. |
double |
average()
Average rating in the dataset. |
void |
buildByItemCounts()
|
void |
buildByUserCounts()
|
IntList |
countByItem()
Get the rating count by item. |
IntList |
countByUser()
Get the rating count by user. |
double |
get(int index)
Directly access ratings. |
double |
get(int user_id,
int item_id)
Directly access rating by user and item |
double |
get(int user_id,
int item_id,
IntCollection indexes)
Directly access rating by user and item. |
boolean |
isReadOnly()
|
double |
maxRating()
Get the maximum rating in the dataset. |
double |
minRating()
Get the minimum rating in the dataset. |
void |
removeAt(int index)
Remove the rating at the specified index |
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. |
double |
set(int index,
double rating)
Directly access the ratings |
java.lang.Double |
tryGet(int user_id,
int item_id)
Try to retrieve a rating for a given user-item combination. |
java.lang.Double |
tryGet(int user_id,
int item_id,
IntCollection indexes)
Try to retrieve a rating for a given user-item combination. |
java.lang.Integer |
tryGetIndex(int user_id,
int item_id)
Try to get the index for given user and item. |
DoubleList |
values()
|
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, 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.IRatings |
---|
size |
Methods inherited from interface org.mymedialite.data.IDataSet |
---|
allItems, allUsers, buildItemIndices, buildRandomIndex, buildUserIndices, byItem, byUser, getIndex, getIndex, getItems, getUsers, items, maxItemID, maxUserID, randomIndex, tryGetIndex, users |
Field Detail |
---|
protected DoubleList values
protected double minRating
protected double maxRating
Constructor Detail |
---|
public Ratings()
Method Detail |
---|
public DoubleList values()
values
in interface IRatings
public double get(int index)
IRatings
get
in interface IRatings
index
- the index of the rating
public double set(int index, double rating)
IRatings
set
in interface IRatings
index
- the rating indexrating
- the rating valuepublic double minRating()
IRatings
minRating
in interface IRatings
public double maxRating()
IRatings
maxRating
in interface IRatings
public IntList countByUser()
IRatings
countByUser
in interface IRatings
public void buildByUserCounts()
public IntList countByItem()
IRatings
countByItem
in interface IRatings
public void buildByItemCounts()
public double average()
IRatings
average
in interface IRatings
public double get(int user_id, int item_id)
IRatings
get
in interface IRatings
user_id
- the user IDitem_id
- the item ID
public java.lang.Double tryGet(int user_id, int item_id)
IRatings
tryGet
in interface IRatings
user_id
- the user IDitem_id
- the item ID
public double get(int user_id, int item_id, IntCollection indexes)
IRatings
get
in interface IRatings
user_id
- the user IDitem_id
- the item IDindexes
- the indexes to look at
public java.lang.Double tryGet(int user_id, int item_id, IntCollection indexes)
IRatings
tryGet
in interface IRatings
user_id
- the user IDitem_id
- the item IDindexes
- the indexes to look at
public java.lang.Integer tryGetIndex(int user_id, int item_id)
IDataSet
tryGetIndex
in interface IDataSet
tryGetIndex
in class DataSet
user_id
- the user IDitem_id
- the item ID
public void add(int user_id, int item_id, float rating)
IRatings
add
in interface IRatings
user_id
- the user IDitem_id
- the item IDrating
- the ratingpublic void add(int user_id, int item_id, byte rating)
IRatings
add
in interface IRatings
user_id
- the user IDitem_id
- the item IDrating
- the ratingpublic void add(int user_id, int item_id, double rating)
IRatings
add
in interface IRatings
user_id
- the user IDitem_id
- the item IDrating
- the rating valuepublic void removeAt(int index)
IRatings
removeAt
in interface IRatings
index
- the rating indexpublic void removeUser(int user_id)
IDataSet
removeUser
in interface IDataSet
user_id
- the user IDpublic void removeItem(int item_id)
IDataSet
removeItem
in interface IDataSet
item_id
- the item IDpublic boolean isReadOnly()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |