public final class Ratings extends Object
Utilities for working with ratings.
Modifier and Type | Method and Description |
---|---|
static Long2DoubleMap |
itemRatingVector(Collection<? extends Rating> ratings)
Construct a rating vector that contains the ratings provided by each user.
|
static Rating |
make(long uid,
long iid,
double value)
Deprecated.
|
static Rating |
make(long uid,
long iid,
double value,
long ts)
Deprecated.
|
static Equivalence<Preference> |
preferenceEquivalence()
An equivalence relation over preferences.
|
static Long2DoubleMap |
userRatingVector(Collection<Rating> ratings)
Construct a rating vector that contains the ratings provided for each item.
|
static Long2DoubleMap |
userRatingVector(ObjectStream<? extends Rating> ratings)
Extract a user rating vector from a rating stream.
|
static Function<UserHistory<? extends Event>,Long2DoubleMap> |
userRatingVectorFunction()
Obtain a function that converts a user history to a rating vector.
|
public static Long2DoubleMap itemRatingVector(@Nonnull Collection<? extends Rating> ratings)
Construct a rating vector that contains the ratings provided by each user. If all ratings in ratings are for the same item, then this will be a valid item rating vector. If multiple ratings are by the same user, the one with the highest timestamp is retained. If two ratings by the same user have identical timestamps, then the one that occurs last when the collection is iterated is retained.
ratings
- Some ratings (they should all be for the same item)public static Long2DoubleMap userRatingVector(@Nonnull Collection<Rating> ratings)
Construct a rating vector that contains the ratings provided for each item. If all ratings in ratings are by the same user, then this will be a valid user rating vector. If multiple ratings are provided for the same item, the one with the greatest timestamp is retained. Ties are broken by preferring ratings which come later when iterating through the collection.
ratings
- A collection of ratings (should all be by the same user)public static Function<UserHistory<? extends Event>,Long2DoubleMap> userRatingVectorFunction()
Obtain a function that converts a user history to a rating vector.
public static Long2DoubleMap userRatingVector(@WillClose ObjectStream<? extends Rating> ratings)
Extract a user rating vector from a rating stream.
ratings
- The rating stream.userRatingVector(Collection)
public static Equivalence<Preference> preferenceEquivalence()
An equivalence relation over preferences.
@Deprecated public static Rating make(long uid, long iid, double value)
Rating.create(long, long, double)
.Make a fresh rating object with no timestamp.
make(long, long, double, long)
@Deprecated public static Rating make(long uid, long iid, double value, long ts)
Rating.create(long, long, double, long)
Make a fresh rating event.