@Immutable @DefaultImplementation(value=PackedRatingMatrix.class) public interface RatingMatrix
Snapshot of the ratings data for building a recommender.
This provides a snapshot of each user’s most current rating for each item. It may also represent synthetic ratings derived from other types of events, depending on the builder that is used for it.
The ratings obtained from a rating matrix do not have timestamps.
The users, items, and ratings in the rating matrix are associated with 0-based indexes, so that they can be used in conjunction with vectors or arrays. The rating matrix can be thought of as a sparse matrix in coordinate list (COO) format, and the index of the rating is its position in the coordinate list.
Modifier and Type | Method and Description |
---|---|
LongCollection |
getItemIds()
Get the set of item IDs in the snapshot.
|
java.util.List<RatingMatrixEntry> |
getRatings()
Get the collection of ratings in the snapshot.
|
LongCollection |
getUserIds()
Get the set of user IDs in the snapshot.
|
java.util.Collection<RatingMatrixEntry> |
getUserRatings(long userId)
Get the ratings for a particular user.
|
Long2DoubleMap |
getUserRatingVector(long userId)
Get the current preferences of a particular user as a vector.
|
KeyIndex |
itemIndex()
Get the item ID index.
|
KeyIndex |
userIndex()
Get the user ID index.
|
LongCollection getUserIds()
Get the set of user IDs in the snapshot.
LongCollection getItemIds()
Get the set of item IDs in the snapshot.
KeyIndex userIndex()
Get the user ID index.
KeyIndex itemIndex()
Get the item ID index.
java.util.List<RatingMatrixEntry> getRatings()
Get the collection of ratings in the snapshot. The ratings are returned in an undetermined order. It is guaranteed that no duplicate ratings appear - each (user,item) pair is rated at most once. Each preference’s index is also in the range [0,len), where len is the size of this collection.
Modifying the returned indexed preferences will not modify the underlying snapshot.
java.util.Collection<RatingMatrixEntry> getUserRatings(long userId)
Get the ratings for a particular user. It is guaranteed that no duplicate ratings appear - each (user,item) pair is rated at most once.
Modifying the returned indexed preferences will not modify the underlying snapshot.
userId
- The user’s ID.Long2DoubleMap getUserRatingVector(long userId)
Get the current preferences of a particular user as a vector.
userId
- The user’s ID.