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, setPreferenceclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDataModel, recommend, recommend, recommend, removePreference, setPreferencepublic 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 RecommenderuserID - 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 RecommendedItems, ordered from most strongly recommend to
leastTasteException - if an error occurs while accessing the DataModelpublic float estimatePreference(long userID,
long itemID)
throws TasteException
estimatePreference in interface RecommenderuserID - user ID whose preference is to be estimateditemID - item ID to estimate preference forDouble.NaNTasteException - if an error occurs while accessing the DataModelpublic long[] mostSimilarUserIDs(long userID,
int howMany)
throws TasteException
mostSimilarUserIDs in interface UserBasedRecommenderuserID - 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 DataModelpublic long[] mostSimilarUserIDs(long userID,
int howMany,
Rescorer<LongPair> rescorer)
throws TasteException
mostSimilarUserIDs in interface UserBasedRecommenderuserID - 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 DataModelprotected float doEstimatePreference(long theUserID,
long[] theNeighborhood,
long itemID)
throws TasteException
TasteExceptionprotected FastIDSet getAllOtherItems(long[] theNeighborhood, long theUserID, boolean includeKnownItems) throws TasteException
TasteExceptionpublic 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 RefreshablealreadyRefreshed - Refreshables 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.