public final class ItemUserAverageRecommender extends AbstractRecommender
Like ItemAverageRecommender
, except that estimated preferences are adjusted for the users' average
preference value. For example, say user X has not rated item Y. Item Y's average preference value is 3.5.
User X's average preference value is 4.2, and the average over all preference values is 4.0. User X prefers
items 0.2 higher on average, so, the estimated preference for user X, item Y is 3.5 + 0.2 = 3.7.
Constructor and Description |
---|
ItemUserAverageRecommender(DataModel dataModel) |
Modifier and Type | Method and Description |
---|---|
float |
estimatePreference(long userID,
long itemID) |
List<RecommendedItem> |
recommend(long userID,
int howMany,
IDRescorer rescorer,
boolean includeKnownItems) |
void |
refresh(Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation.
|
void |
removePreference(long userID,
long itemID)
Default implementation which just calls
DataModel.removePreference(long, long) (Object, Object)}. |
void |
setPreference(long userID,
long itemID,
float value)
Default implementation which just calls
DataModel.setPreference(long, long, float) . |
String |
toString() |
getAllOtherItems, getDataModel, getDefaultCandidateItemsStrategy, recommend, recommend, recommend
public ItemUserAverageRecommender(DataModel dataModel) throws TasteException
TasteException
public List<RecommendedItem> recommend(long userID, int howMany, IDRescorer rescorer, boolean includeKnownItems) throws TasteException
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
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 void setPreference(long userID, long itemID, float value) throws TasteException
AbstractRecommender
Default implementation which just calls DataModel.setPreference(long, long, float)
.
setPreference
in interface Recommender
setPreference
in class AbstractRecommender
userID
- user to set preference foritemID
- item to set preference forvalue
- preference valueTasteException
- if an error occurs while accessing the DataModel
public void removePreference(long userID, long itemID) throws TasteException
AbstractRecommender
Default implementation which just calls DataModel.removePreference(long, long)
(Object, Object)}.
removePreference
in interface Recommender
removePreference
in class AbstractRecommender
userID
- user from which to remove preferenceitemID
- item for which to remove preferenceTasteException
- if an error occurs while accessing the DataModel
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.
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.