CFEngine API

org.recommender.algorithms.Experimental
Class PopAlgorithm

java.lang.Object
  |
  +--org.recommender.algorithms.Experimental.PopAlgorithm
All Implemented Interfaces:
CFAlgorithm

public class PopAlgorithm
extends java.lang.Object
implements CFAlgorithm

Describes an implementation of the CFAlgorithm interface to make CF predictions using the non-personalized prediction algorithm described by Herlocker, et al 1999. Summary of algorithm: Compares all users rating for the item with their average ratings, and computes and average offset for this item. Returns the active user's mean rating plus this average offset. This turns out to be much more effective than a simple average over all user ratings for the item, since it takes into account different rating scales for different users.

Author:
Daniel Lowd <dlowd@cs.orst.edu>

Constructor Summary
PopAlgorithm(DataManager mgr)
          Constructor, simply assigns DataManager.
 
Method Summary
 long getAveragePredictionTime()
          Return average prediction time.
 ItemPrediction[] getRecommendations(int activeUser, int n)
          Returns top n recommendations.
 ItemPrediction[] getRecommendationsByType(int activeUser, int n, int type)
          Yun Wang Return top n recommendations of specific type.
 ItemPrediction predictRating(int activeUser, int item)
          Predicts the rating for the given user and item.
 java.lang.String toString()
          Return the name of this algorithm.
 void updateUser(int userID)
          Not yet implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PopAlgorithm

public PopAlgorithm(DataManager mgr)
Constructor, simply assigns DataManager.

Parameters:
mgr -
Method Detail

getRecommendationsByType

public ItemPrediction[] getRecommendationsByType(int activeUser,
                                                 int n,
                                                 int type)
                                          throws CFNotImplementedException,
                                                 java.sql.SQLException
Yun Wang Return top n recommendations of specific type.

Specified by:
getRecommendationsByType in interface CFAlgorithm
Parameters:
activeUser -
n -
type -
Returns:
itemPredList
Throws:
java.sql.SQLException
CFNotImplementedException

getRecommendations

public ItemPrediction[] getRecommendations(int activeUser,
                                           int n)
                                    throws java.sql.SQLException,
                                           CFNotImplementedException
Returns top n recommendations. Uses the same algorithm as predictRating, but predicts all items the user has not rated, rather than just one. Sorts the items in reverse order of rating and returns the list.

Specified by:
getRecommendations in interface CFAlgorithm
Parameters:
activeUser - user to predict for
n - number of recommendations to acquire
Returns:
itemPredList
Throws:
java.sql.SQLException
CFNotImplementedException

predictRating

public ItemPrediction predictRating(int activeUser,
                                    int item)
                             throws CFNotImplementedException
Predicts the rating for the given user and item.

Specified by:
predictRating in interface CFAlgorithm
Parameters:
activeUser -
item -
Returns:
predicted rating
CFNotImplementedException

updateUser

public void updateUser(int userID)
                throws CFNotImplementedException
Not yet implemented.

Specified by:
updateUser in interface CFAlgorithm
Parameters:
userID -
CFNotImplementedException

getAveragePredictionTime

public long getAveragePredictionTime()
                              throws CFNotImplementedException
Return average prediction time.

Specified by:
getAveragePredictionTime in interface CFAlgorithm
Returns:
long
CFNotImplementedException

toString

public java.lang.String toString()
Return the name of this algorithm.

Specified by:
toString in interface CFAlgorithm
Overrides:
toString in class java.lang.Object
Returns:
String

CFEngine API

Copyright © 2003 - Oregon State University www.orst.edu