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 DataAccessObject |
dao |
protected ItemBasedItemScorer |
scorer |
Constructor and Description |
---|
TopNItemBasedItemRecommender(DataAccessObject data,
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(java.util.Set<java.lang.Long> basket,
int n,
java.util.Set<java.lang.Long> candidates,
java.util.Set<java.lang.Long> exclude)
Produce a set of recommendations for the item, with details.
|
recommendRelatedItems, recommendRelatedItems, recommendRelatedItems, recommendRelatedItems, recommendRelatedItems
protected final DataAccessObject dao
protected final ItemBasedItemScorer scorer
@Inject public TopNItemBasedItemRecommender(DataAccessObject data, ItemBasedItemScorer scorer)
public ResultList recommendRelatedItemsWithDetails(java.util.Set<java.lang.Long> basket, int n, @Nullable java.util.Set<java.lang.Long> candidates, @Nullable java.util.Set<java.lang.Long> exclude)
ItemBasedItemRecommender
Produce a set of recommendations for the item, with details. This method functions identically to ItemBasedItemRecommender.recommendRelatedItems(Set, int, Set, Set)
, except that it returns more detailed results.
basket
- The reference items.n
- The number of ratings to return. If negative, recommend as many 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
.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.