com.planetj.taste.impl.recommender
Class GenericUserBasedRecommender

java.lang.Object
  extended by com.planetj.taste.impl.recommender.AbstractRecommender
      extended by com.planetj.taste.impl.recommender.GenericUserBasedRecommender
All Implemented Interfaces:
Refreshable, Recommender, UserBasedRecommender

public final class GenericUserBasedRecommender
extends AbstractRecommender
implements UserBasedRecommender

A simple Recommender which uses a given DataModel and UserNeighborhood to produce recommendations.

Author:
Sean Owen

Constructor Summary
GenericUserBasedRecommender(DataModel dataModel, UserNeighborhood neighborhood, UserCorrelation correlation)
           
 
Method Summary
 double estimatePreference(java.lang.Object userID, java.lang.Object itemID)
          
 java.util.List<User> mostSimilarUsers(java.lang.Object userID, int howMany)
          
 java.util.List<User> mostSimilarUsers(java.lang.Object userID, int howMany, Rescorer<Pair<User,User>> rescorer)
          
 java.util.List<RecommendedItem> recommend(java.lang.Object userID, int howMany, Rescorer<Item> rescorer)
          
 void refresh()
          

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.

 java.lang.String toString()
           
 
Methods inherited from class com.planetj.taste.impl.recommender.AbstractRecommender
getAllOtherItems, getDataModel, recommend, removePreference, setPreference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.planetj.taste.recommender.Recommender
getDataModel, recommend, removePreference, setPreference
 

Constructor Detail

GenericUserBasedRecommender

public GenericUserBasedRecommender(DataModel dataModel,
                                   UserNeighborhood neighborhood,
                                   UserCorrelation correlation)
Method Detail

recommend

@NotNull
public java.util.List<RecommendedItem> recommend(java.lang.Object userID,
                                                         int howMany,
                                                         Rescorer<Item> rescorer)
                                          throws TasteException

Specified by:
recommend in interface Recommender
Parameters:
userID - user for which recommendations are to be computed
howMany - desired number of recommendations
rescorer - rescoring function to apply before final list of recommendations is determined
Returns:
List of recommended RecommendedItems, ordered from most strongly recommend to least
Throws:
TasteException - if an error occurs while accessing the DataModel

estimatePreference

public double estimatePreference(java.lang.Object userID,
                                 java.lang.Object itemID)
                          throws TasteException

Specified by:
estimatePreference in interface Recommender
Parameters:
userID - user ID whose preference is to be estimated
itemID - item ID to estimate preference for
Returns:
an estimated preference if the user has not expressed a preference for the item, or else the user's actual preference for the item. If a preference cannot be estimated, returns Double.NaN
Throws:
TasteException - if an error occurs while accessing the DataModel

mostSimilarUsers

@NotNull
public java.util.List<User> mostSimilarUsers(java.lang.Object userID,
                                                     int howMany)
                                      throws TasteException

Specified by:
mostSimilarUsers in interface UserBasedRecommender
Parameters:
userID - ID of User for which to find most similar other Users
howMany - desired number of most similar Users to find
Returns:
Users most similar to the given user
Throws:
TasteException - if an error occurs while accessing the DataModel

mostSimilarUsers

@NotNull
public java.util.List<User> mostSimilarUsers(java.lang.Object userID,
                                                     int howMany,
                                                     Rescorer<Pair<User,User>> rescorer)
                                      throws TasteException

Specified by:
mostSimilarUsers in interface UserBasedRecommender
Parameters:
userID - ID of User for which to find most similar other Users
howMany - desired number of most similar Users to find
rescorer - Rescorer which can adjust user-user correlation estimates used to determine most similar users
Returns:
Users most similar to the given user
Throws:
TasteException - if an error occurs while accessing the DataModel

refresh

public void refresh()

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.

Specified by:
refresh in interface Refreshable
Overrides:
refresh in class AbstractRecommender

toString

@NotNull
public java.lang.String toString()
Overrides:
toString in class java.lang.Object