## org.apache.mahout.cf.taste.impl.recommender
Class AbstractRecommender

    java.lang.Object
      org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender

All Implemented Interfaces:
  Refreshable, Recommender

Direct Known Subclasses:
  GenericItemBasedRecommender, GenericUserBasedRecommender, ItemAverageRecommender, ItemUserAverageRecommender, RandomRecommender, SVDRecommender

    public abstract class AbstractRecommender

extends Object
implements Recommender

Constructor Summary
`protected` `AbstractRecommender(DataModel dataModel)`
`protected` `AbstractRecommender(DataModel dataModel, CandidateItemsStrategy candidateItemsStrategy)`

Method Summary
`protected FastIDSet` `getAllOtherItems(long userID, PreferenceArray preferencesFromUser)`
`DataModel` `getDataModel()`
`protected static CandidateItemsStrategy` `getDefaultCandidateItemsStrategy()`
`List<RecommendedItem>` `recommend(long userID, int howMany)` Default implementation which just calls `Recommender.recommend(long, int, org.apache.mahout.cf.taste.recommender.IDRescorer)`, with a `Rescorer` that does nothing.
`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)`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.mahout.cf.taste.recommender.Recommender
`estimatePreference, recommend`

Methods inherited from interface org.apache.mahout.cf.taste.common.Refreshable
`refresh`

Constructor Detail

### AbstractRecommender

    protected AbstractRecommender(DataModel dataModel,
                                  CandidateItemsStrategy candidateItemsStrategy)

### AbstractRecommender

    protected AbstractRecommender(DataModel dataModel)

Method Detail

### getDefaultCandidateItemsStrategy

    protected static CandidateItemsStrategy getDefaultCandidateItemsStrategy()

### recommend

    public List<RecommendedItem> recommend(long userID,
                                           int howMany)
                                    throws TasteException

  Default implementation which just calls `Recommender.recommend(long, int, org.apache.mahout.cf.taste.recommender.IDRescorer)`, with a `Rescorer` that does nothing.

  Specified by:
    `recommend` in interface `Recommender`
  Parameters:
    `userID` - user for which recommendations are to be computed
    `howMany` - desired number of recommendations
  Returns:
    `List` of recommended `RecommendedItem`s, ordered from most strongly recommend to least
  Throws:
    `TasteException` - if an error occurs while accessing the `DataModel`

### setPreference

    public void setPreference(long userID,
                              long itemID,
                              float value)
                       throws TasteException

  Default implementation which just calls `DataModel.setPreference(long, long, float)`.

  Specified by:
    `setPreference` in interface `Recommender`
  Parameters:
    `userID` - user to set preference for
    `itemID` - item to set preference for
    `value` - preference value
  Throws:
    `IllegalArgumentException` - if userID or itemID is `null`, or if value is `Double.NaN`
    `TasteException` - if an error occurs while accessing the `DataModel`

### removePreference

    public void removePreference(long userID,
                                 long itemID)
                          throws TasteException

  Default implementation which just calls `DataModel.removePreference(long, long)` (Object, Object)}.

  Specified by:
    `removePreference` in interface `Recommender`
  Parameters:
    `userID` - user from which to remove preference
    `itemID` - item for which to remove preference
  Throws:
    `IllegalArgumentException` - if userID or itemID is `null`
    `TasteException` - if an error occurs while accessing the `DataModel`

### getDataModel

    public DataModel getDataModel()

  Specified by:
    `getDataModel` in interface `Recommender`
  Returns:
    underlying `DataModel` used by this `Recommender` implementation

### getAllOtherItems

    protected FastIDSet getAllOtherItems(long userID,
                                         PreferenceArray preferencesFromUser)
                                  throws TasteException

  Parameters:
    `userID` - ID of user being evaluated
    `preferencesFromUser` - the preferences from the user
  Returns:
    all items in the `DataModel` for which the user has not expressed a preference and could possibly be recommended to the user
  Throws:
    `TasteException` - if an error occurs while listing items

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.