public class RescoringItemRecommender extends java.lang.Object implements ItemRecommender
Item recommender that wraps a base item recommender and replaces its scores with those produced by another item scorer. The order from the original recommender is preserved.
For performance reasons, the scorer is only invoked by recommendWithDetails(long, int, Set, Set)
, because scores are not returend in the other recommendation operations. The results produced by this recommender are of type RescoredResult
; for any recommended item that the scorer cannot score, the result has no score.
Results.rescore(Result, Result)
Constructor and Description |
---|
RescoringItemRecommender(ItemRecommender rec,
ItemScorer score)
Create a new rescoring item recommender.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.Long> |
recommend(long user)
Recommend all possible items for a user using the default exclude set.
|
java.util.List<java.lang.Long> |
recommend(long user,
int n)
Recommend up to
n items for a user using the default exclude set. |
java.util.List<java.lang.Long> |
recommend(long user,
int n,
java.util.Set<java.lang.Long> candidates,
java.util.Set<java.lang.Long> exclude)
Produce a set of recommendations for the user.
|
ResultList |
recommendWithDetails(long user,
int n,
java.util.Set<java.lang.Long> candidates,
java.util.Set<java.lang.Long> exclude)
Produce a set of recommendations for the user with additional details.
|
@Inject public RescoringItemRecommender(ItemRecommender rec, ItemScorer score)
Create a new rescoring item recommender.
rec
- The recommender.score
- The item scorer.public java.util.List<java.lang.Long> recommend(long user)
ItemRecommender
Recommend all possible items for a user using the default exclude set.
recommend
in interface ItemRecommender
user
- The user ID.ItemRecommender.recommend(long, int, Set, Set)
public java.util.List<java.lang.Long> recommend(long user, int n)
ItemRecommender
Recommend up to n
items for a user using the default exclude set.
recommend
in interface ItemRecommender
user
- The user ID.n
- The number of recommendations to return. Negative values request as many recommendations as possible.ItemRecommender.recommend(long, int, Set, Set)
public java.util.List<java.lang.Long> recommend(long user, int n, @Nullable java.util.Set<java.lang.Long> candidates, @Nullable java.util.Set<java.lang.Long> exclude)
ItemRecommender
Produce a set of recommendations for the user. This is the most general recommendation method, allowing the recommendations to be constrained by both a candidate set \(\mathcal{C}\) and an exclude set \(\mathcal{E}\). The exclude set is applied to the candidate set, so the final effective candidate set is \(\mathcal{C} \backslash \mathcal{E}\).
The recommender is not guaranteed to return a full n
recommendations. There are many reasons why it might return a shorter list, including lack of items, lack of coverage for items, or a predefined notion of a maximum recommendation list length. However, a negative value for n
instructs the recommender to return as many as it can consistent with any limitations built in to its design and/or supporting algorithms.
recommend
in interface ItemRecommender
user
- The user’s IDn
- The number of ratings to return. If negative, the recommender will return as many recommendations as possible.candidates
- A set of candidate items which can be recommended. If null
, all items are considered candidates.exclude
- A set of items to be excluded. If null
, a default exclude set is used.public ResultList recommendWithDetails(long user, int n, @Nullable java.util.Set<java.lang.Long> candidates, @Nullable java.util.Set<java.lang.Long> exclude)
ItemRecommender
Produce a set of recommendations for the user with additional details. This method functions identically to ItemRecommender.recommend(long, int, Set, Set)
, except that it may produce more detailed results. Implementations may return subclasses of ResultList
that provide access to additional details about each recommendation.
recommendWithDetails
in interface ItemRecommender
user
- The user’s IDn
- The number of ratings to return. If negative, then the recommender will return as many recommendations as possible.candidates
- A set of candidate items which can be recommended. If null
, all items are considered candidates.exclude
- A set of items to be excluded. If null
, a default exclude set is used.Double.NaN
. For most scoring recommenders, the items will be ordered in decreasing order of score. This is not a hard requirement — e.g. set recommenders are allowed to be more flexible.