public class TopNItemRecommender extends AbstractItemRecommender
AbstractItemRecommender. The
default exclude set is all items rated by the user.
Recommendations are returned in descending order of score.
| Modifier and Type | Class and Description |
|---|---|
static class |
TopNItemRecommender.Provider
An intelligent provider for Top-N recommenders.
|
| Modifier and Type | Field and Description |
|---|---|
protected ItemDAO |
itemDAO |
protected ItemScorer |
scorer |
protected UserEventDAO |
userEventDAO |
| Constructor and Description |
|---|
TopNItemRecommender(UserEventDAO uedao,
ItemDAO idao,
ItemScorer scorer) |
| Modifier and Type | Method and Description |
|---|---|
protected LongSet |
getDefaultExcludes(long user)
Get the default exclude set for a user.
|
protected LongSet |
getDefaultExcludes(UserHistory<? extends Event> user)
Get the default exclude set for a user.
|
protected LongSet |
getPredictableItems(long user)
Determine the items for which predictions can be made for a certain user.
|
ItemScorer |
getScorer() |
protected List<ScoredId> |
recommend(int n,
SparseVector scores)
Pick the top n items from a score vector.
|
protected List<ScoredId> |
recommend(long user,
int n,
LongSet candidates,
LongSet exclude)
Implement the ID-based recommendation in terms of the scorer.
|
recommend, recommend, recommend, recommendprotected final UserEventDAO userEventDAO
protected final ItemDAO itemDAO
protected final ItemScorer scorer
@Inject public TopNItemRecommender(UserEventDAO uedao, ItemDAO idao, ItemScorer scorer)
public ItemScorer getScorer()
protected List<ScoredId> recommend(long user, int n, LongSet candidates, LongSet exclude)
getDefaultExcludes(long) to supply a missing exclude set.recommend in class AbstractItemRecommenderuser - The user ID.n - The number of items to return, or negative to return all possible items.candidates - The candidate set, or null to use a default set of candidates.exclude - The set of excluded items, or null to use the default exclude set.ItemRecommender.recommend(long, int, Set, Set)protected List<ScoredId> recommend(int n, SparseVector scores)
n - The number of items to recommend.scores - The scored item vector.protected LongSet getDefaultExcludes(long user)
user - The user ID.protected LongSet getDefaultExcludes(@Nullable UserHistory<? extends Event> user)
UserHistory.itemSet()).user - The user history.protected LongSet getPredictableItems(long user)
user - The user's ID.