CFEngine API

org.recommender.algorithms
Class SimplePearsonAlgorithm

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

public class SimplePearsonAlgorithm
extends java.lang.Object
implements CFAlgorithm

Describes an implementation of the CFAlgorithm interface to make CF predictions using the Simple Pearson Correlation method.

Author:
Sameer Kadam, Irwin Yoon, Olivier Godde, Daniel Lowd, Yun Wang, Matt McLaughlin

Constructor Summary
SimplePearsonAlgorithm(DataManager dataMgr)
          Constructor, pass in dataMgr and initialize algorithm parameters.
 
Method Summary
 long getAveragePredictionTime()
          Return average prediction time.
 ItemPrediction[] getRecommendations(int activeUser, int n)
          Return top n recommendations.
 ItemPrediction[] getRecommendationsByType(int activeUser, int n, int type)
          Yun Wang Return top n recommendations of specific type.
 SimilarityWeight getWeight(RatingArrays activeUserRatings, int neighbor, int itemId)
          Calculate CorrelationCoeff for an item between the activeuser and one neighbor.
 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)
          Doesn't currently need upateUser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimplePearsonAlgorithm

public SimplePearsonAlgorithm(DataManager dataMgr)
Constructor, pass in dataMgr and initialize algorithm parameters.

Method Detail

getRecommendationsByType

public ItemPrediction[] getRecommendationsByType(int activeUser,
                                                 int n,
                                                 int type)
                                          throws java.sql.SQLException,
                                                 CFNotImplementedException
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
Return top n recommendations.

Specified by:
getRecommendations in interface CFAlgorithm
Parameters:
activeUser -
n -
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:
predictedRating
CFNotImplementedException

getAveragePredictionTime

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

Specified by:
getAveragePredictionTime in interface CFAlgorithm
Returns:
average prediction time
CFNotImplementedException

getWeight

public SimilarityWeight getWeight(RatingArrays activeUserRatings,
                                  int neighbor,
                                  int itemId)
Calculate CorrelationCoeff for an item between the activeuser and one neighbor. This method is the bottleneck of this algorithm - do not add anything unnecessary - Remove all logging or debugging statements after you are done. Even a harmless if statement can slow things down.

Parameters:
neighbor -
itemId -
Returns:
SimilarityWeight

updateUser

public void updateUser(int userID)
                throws CFNotImplementedException
Doesn't currently need upateUser.

Specified by:
updateUser in interface CFAlgorithm
Parameters:
userID -
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