public class PopularItemRecommender extends AbstractItemRecommender implements ItemRecommender, ItemBasedItemRecommender
Recommend the most popular items. More efficient than using a popularity rank scorer.
Constructor and Description |
---|
PopularItemRecommender(InteractionStatistics stats,
DataAccessObject dao)
Create a new popular item recommender.
|
Modifier and Type | Method and Description |
---|---|
protected LongList |
recommend(long user,
int n,
LongSet candidates,
LongSet exclude)
Primary method for implementing an item recommender without details.
|
java.util.List<java.lang.Long> |
recommendRelatedItems(long reference)
Recommend all possible items for a reference item using the default exclude set.
|
java.util.List<java.lang.Long> |
recommendRelatedItems(long reference,
int n)
Recommend up to n possible items for a reference item using the default exclude set.
|
java.util.List<java.lang.Long> |
recommendRelatedItems(java.util.Set<java.lang.Long> basket)
Recommend all possible items for a set of reference items using the default exclude set.
|
java.util.List<java.lang.Long> |
recommendRelatedItems(java.util.Set<java.lang.Long> basket,
int n)
Recommend up to n items for a set of reference items using the default exclude set.
|
LongList |
recommendRelatedItems(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.
|
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.
|
protected ResultList |
recommendWithDetails(long user,
int n,
LongSet candidates,
LongSet exclude)
Primary method for implementing an item recommender.
|
recommend, recommend, recommend, recommendWithDetails
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
recommend, recommend, recommend, recommendWithDetails
@Inject public PopularItemRecommender(InteractionStatistics stats, DataAccessObject dao)
Create a new popular item recommender.
stats
- The interaction statistics.public java.util.List<java.lang.Long> recommendRelatedItems(long reference)
ItemBasedItemRecommender
Recommend all possible items for a reference item using the default exclude set.
recommendRelatedItems
in interface ItemBasedItemRecommender
reference
- The reference item.ItemBasedItemRecommender.recommendRelatedItems(Set, int, Set, Set)
public java.util.List<java.lang.Long> recommendRelatedItems(long reference, int n)
ItemBasedItemRecommender
Recommend up to n possible items for a reference item using the default exclude set.
recommendRelatedItems
in interface ItemBasedItemRecommender
reference
- The reference item.n
- The number of items to recommend. If negative, recommend as many as possible.ItemBasedItemRecommender.recommendRelatedItems(Set, int, Set, Set)
public java.util.List<java.lang.Long> recommendRelatedItems(java.util.Set<java.lang.Long> basket)
ItemBasedItemRecommender
Recommend all possible items for a set of reference items using the default exclude set.
recommendRelatedItems
in interface ItemBasedItemRecommender
basket
- The reference items.ItemBasedItemRecommender.recommendRelatedItems(Set, int, Set, Set)
public java.util.List<java.lang.Long> recommendRelatedItems(java.util.Set<java.lang.Long> basket, int n)
ItemBasedItemRecommender
Recommend up to n items for a set of reference items using the default exclude set.
recommendRelatedItems
in interface ItemBasedItemRecommender
basket
- The reference items.n
- The number of recommendations to return. If negative, recommend as many as possible.ItemBasedItemRecommender.recommendRelatedItems(Set, int, Set, Set)
public LongList recommendRelatedItems(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. 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.
recommendRelatedItems
in interface ItemBasedItemRecommender
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.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.
recommendRelatedItemsWithDetails
in interface ItemBasedItemRecommender
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 LongList recommend(long user, int n, @Nullable LongSet candidates, @Nullable LongSet exclude)
AbstractItemRecommender
Primary method for implementing an item recommender without details. The default implementation delegates to AbstractItemRecommender.recommendWithDetails(long, int, LongSet, LongSet)
.
recommend
in class AbstractItemRecommender
user
- The user ID.n
- The number of recommendations to produce, or a negative value to produce unlimited recommendations.candidates
- The candidate items, or null
for default.exclude
- The exclude set, or null
for default.AbstractItemRecommender.recommend(long, int, Set, Set)
protected ResultList recommendWithDetails(long user, int n, @Nullable LongSet candidates, @Nullable LongSet exclude)
AbstractItemRecommender
Primary method for implementing an item recommender.
recommendWithDetails
in class AbstractItemRecommender
user
- The user ID.n
- The number of recommendations to produce, or a negative value to produce unlimited recommendations.candidates
- The candidate items, or null
for default.exclude
- The exclude set, or null
for default.AbstractItemRecommender.recommendWithDetails(long, int, Set, Set)