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

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.recommender.AbstractRecommender
All Implemented Interfaces:
Refreshable, Recommender
Direct Known Subclasses:
GenericItemBasedRecommender, GenericUserBasedRecommender, ItemAverageRecommender, ItemUserAverageRecommender, RandomRecommender, SlopeOneRecommender, SVDRecommender, TreeClusteringRecommender, TreeClusteringRecommender2

public abstract class AbstractRecommender
extends java.lang.Object
implements Recommender


Constructor Summary
protected AbstractRecommender(DataModel dataModel)
           
 
Method Summary
protected  FastIDSet getAllOtherItems(long theUserID)
           
 DataModel getDataModel()
           
 java.util.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)
Method Detail

recommend

public java.util.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 RecommendedItems, 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:
java.lang.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:
java.lang.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

getAllOtherItems

protected FastIDSet getAllOtherItems(long theUserID)
                              throws TasteException
Parameters:
theUserID - ID of user being evaluated
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-2010 The Apache Software Foundation. All Rights Reserved.