public class GenericUserBasedRecommender extends AbstractRecommender implements UserBasedRecommender
A simple Recommender
which uses a given DataModel
and UserNeighborhood
to produce recommendations.
Constructor and Description |
---|
GenericUserBasedRecommender(DataModel dataModel,
UserNeighborhood neighborhood,
UserSimilarity similarity) |
Modifier and Type | Method and Description |
---|---|
protected float |
doEstimatePreference(long theUserID,
long[] theNeighborhood,
long itemID) |
float |
estimatePreference(long userID,
long itemID) |
protected FastIDSet |
getAllOtherItems(long[] theNeighborhood,
long theUserID,
boolean includeKnownItems) |
UserSimilarity |
getSimilarity() |
long[] |
mostSimilarUserIDs(long userID,
int howMany) |
long[] |
mostSimilarUserIDs(long userID,
int howMany,
Rescorer<LongPair> rescorer) |
List<RecommendedItem> |
recommend(long userID,
int howMany,
IDRescorer rescorer,
boolean includeKnownItems) |
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation.
|
String |
toString() |
getAllOtherItems, getDataModel, getDefaultCandidateItemsStrategy, recommend, recommend, recommend, removePreference, setPreference
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDataModel, recommend, recommend, recommend, removePreference, setPreference
public GenericUserBasedRecommender(DataModel dataModel, UserNeighborhood neighborhood, UserSimilarity similarity)
public UserSimilarity getSimilarity()
public List<RecommendedItem> recommend(long userID, int howMany, IDRescorer rescorer, boolean includeKnownItems) throws TasteException
recommend
in interface Recommender
userID
- user for which recommendations are to be computedhowMany
- desired number of recommendationsrescorer
- rescoring function to apply before final list of recommendations is determinedincludeKnownItems
- whether to include items already known by the user in recommendationsList
of recommended RecommendedItem
s, ordered from most strongly recommend to
leastTasteException
- if an error occurs while accessing the DataModel
public float estimatePreference(long userID, long itemID) throws TasteException
estimatePreference
in interface Recommender
userID
- user ID whose preference is to be estimateditemID
- item ID to estimate preference forDouble.NaN
TasteException
- if an error occurs while accessing the DataModel
public long[] mostSimilarUserIDs(long userID, int howMany) throws TasteException
mostSimilarUserIDs
in interface UserBasedRecommender
userID
- ID of user for which to find most similar other usershowMany
- desired number of most similar users to findTasteException
- if an error occurs while accessing the DataModel
public long[] mostSimilarUserIDs(long userID, int howMany, Rescorer<LongPair> rescorer) throws TasteException
mostSimilarUserIDs
in interface UserBasedRecommender
userID
- ID of user for which to find most similar other usershowMany
- desired number of most similar users to findrescorer
- Rescorer
which can adjust user-user similarity estimates used to determine most similar
usersTasteException
- if an error occurs while accessing the DataModel
protected float doEstimatePreference(long theUserID, long[] theNeighborhood, long itemID) throws TasteException
TasteException
protected FastIDSet getAllOtherItems(long[] theNeighborhood, long theUserID, boolean includeKnownItems) throws TasteException
TasteException
public void refresh(Collection<Refreshable> alreadyRefreshed)
Refreshable
Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any
Refreshable
should always leave itself in a consistent, operational state, and that the refresh
atomically updates internal state from old to new.
refresh
in interface Refreshable
alreadyRefreshed
- Refreshable
s that are known to have already been
refreshed as a result of an initial call to a {#refresh(Collection)} method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.