CFEngine API

org.recommender.algorithms.Experimental
Class UserItemAlgorithm

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

public class UserItemAlgorithm
extends java.lang.Object
implements CFAlgorithm

Describes an implementation of the CFAlgorithm interface to make CF predictions using a modification of the Simple Pearson Correlation method. We find neighbors using Pearson correlations, but weight the effect of each item by its similarity to the target item we're predicting. i.e. in computing the similarity between two users, some items have a larger effect than others.

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

Field Summary
(package private)  float[] itemAverages
           
(package private)  float[][] itemWeights
           
 
Constructor Summary
UserItemAlgorithm(DataManager dataMgr)
          Initialize parameters, set up neighborhood, and calculate item average.
 
Method Summary
(package private)  void calcItemAverages()
          Calculate item averages.
 long getAveragePredictionTime()
          Return average prediction time.
 ItemPrediction[] getRecommendations(int activeUser, int n)
          Not yet complete.
 ItemPrediction[] getRecommendationsByType(int activeUser, int n, int type)
          Not yet complete
 float getWeight(int activeitem, int neighbor)
          Weight the effect of each item by its similarity to the target item we're predicting.
 SimilarityWeight getWeight(int activeuser, int neighbor, int item)
          Calculate CorrelatinCoeff for an item between the activeuser and one neighbor.
 ItemPrediction predictRating(int activeUser, int item)
          Predicts the rating for the given user and item.
(package private)  void setUpNeighborhoods()
          Set up neighborhood using pearson correlations.
 java.lang.String toString()
          Return the name of this algorithm.
 void updateUser(int userID)
          Not yet complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

itemWeights

float[][] itemWeights

itemAverages

float[] itemAverages
Constructor Detail

UserItemAlgorithm

public UserItemAlgorithm(DataManager dataMgr)
Initialize parameters, set up neighborhood, and calculate item average.

Parameters:
dataMgr - the DataManager to get data from
Method Detail

setUpNeighborhoods

void setUpNeighborhoods()
Set up neighborhood using pearson correlations.


getWeight

public float getWeight(int activeitem,
                       int neighbor)
Weight the effect of each item by its similarity to the target item we're predicting.

Parameters:
activeitem -
neighbor -

calcItemAverages

void calcItemAverages()
Calculate item averages.


getRecommendations

public ItemPrediction[] getRecommendations(int activeUser,
                                           int n)
                                    throws java.sql.SQLException,
                                           CFNotImplementedException
Not yet complete.

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

getRecommendationsByType

public ItemPrediction[] getRecommendationsByType(int activeUser,
                                                 int n,
                                                 int type)
                                          throws java.sql.SQLException,
                                                 CFNotImplementedException
Not yet complete

Specified by:
getRecommendationsByType in interface CFAlgorithm
Parameters:
activeUser -
n -
type -
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. Similar to SimplePearsonAlgorithm

Specified by:
predictRating in interface CFAlgorithm
Parameters:
activeUser -
item -
Returns:
predicted rating
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(int activeuser,
                                  int neighbor,
                                  int item)
Calculate CorrelatinCoeff for an item between the activeuser and one neighbor. This is a method in SimplePearsonAlgorithm

Parameters:
activeuser -
neighbor -
Returns:
SimilarityWeight

updateUser

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

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:
the name of this algorithm.

CFEngine API

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