public class TopNItemBasedItemRecommender extends AbstractItemBasedItemRecommender
A global item recommender that recommends the top N items from a scorer.
Modifier and Type | Field and Description |
---|---|
protected ItemDAO |
itemDAO |
protected ItemBasedItemScorer |
scorer |
Constructor and Description |
---|
TopNItemBasedItemRecommender(ItemDAO idao,
ItemBasedItemScorer scorer) |
Modifier and Type | Method and Description |
---|---|
protected LongSet |
getDefaultExcludes(LongSet items)
Get the default exclude set for a item in the global recommendation.
|
protected ResultList |
recommend(int n,
ResultMap scores)
Pick the top n items from a score vector.
|
ResultList |
recommendRelatedItemsWithDetails(Set<Long> basket,
int n,
Set<Long> candidates,
Set<Long> exclude)
Produce a set of recommendations for the item, with details.
|
recommendRelatedItems, recommendRelatedItems, recommendRelatedItems, recommendRelatedItems, recommendRelatedItems
protected final ItemDAO itemDAO
protected final ItemBasedItemScorer scorer
@Inject public TopNItemBasedItemRecommender(ItemDAO idao, ItemBasedItemScorer scorer)
public ResultList recommendRelatedItemsWithDetails(Set<Long> basket, int n, @Nullable Set<Long> candidates, @Nullable Set<Long> exclude)
ItemBasedItemRecommender
Produce a set of recommendations for the item, with details. This is the most general recommendation method, allowing the recommendations to be constrained by both a candidate set and an exclude set and potentially providing more details on each recommendation. The exclude set is applied to the candidate set, so the final effective candidate set is candidates minus exclude.
basket
- The reference items.n
- The number of ratings to return. If negative, no specific size is requested.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
.protected LongSet getDefaultExcludes(LongSet items)
Get the default exclude set for a item in the global recommendation. The base implementation returns the input set.
items
- The items for which we are recommending.protected ResultList recommend(int n, ResultMap scores)
Pick the top n items from a score vector.
n
- The number of items to recommend.scores
- The scored item vector.