CFEngine API

org.recommender.algorithms.Experimental
Class ClusteringAlgorithm

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

public class ClusteringAlgorithm
extends java.lang.Object
implements CFAlgorithm

Collaborative filtering algorithm using Bayesian clustering, to divide users into different "classes," and recommend items based on membership in these classes.

Author:
Daniel Lowd

Field Summary
(package private)  float[] classPriors
           
(package private)  DataManager dataMgr
           
(package private) static float GRADIENT_RATIO
           
(package private)  int maxClass
           
(package private)  int maxItem
           
(package private)  int maxRating
           
(package private)  boolean USE_EXPECTED_VALUE
           
(package private)  float[][][] wArray
           
 
Constructor Summary
ClusteringAlgorithm(DataManager dataMgr)
          Constructor, initialize DataManager, parameters and wArray.
 
Method Summary
(package private)  float[] calcAllProbs(java.util.Iterator evidence)
          Calculate all probabilities.
 long getAveragePredictionTime()
          Return average prediction time
 ItemPrediction[] getRecommendations(int activeUser, int n)
          Not yet implemented.
 ItemPrediction[] getRecommendationsByType(int activeUser, int n, int type)
          Haven't been implemented yet.
(package private)  float gradientAscentStep()
          Do one step of gradient ascent to refine the values in wArray
 void initRandomArray(int numClasses)
          Create the wArray and fill it with random values.
(package private)  void normalizeArray()
          Normalize wArray so that the probabilities for each rating on an item sum to 1.
 ItemPrediction predictRating(int userID, int itemID)
          Asks the prediction engine to return a prediction for how a particular user will rate a particular 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
 

Field Detail

dataMgr

DataManager dataMgr

wArray

float[][][] wArray

classPriors

float[] classPriors

maxClass

int maxClass

maxItem

int maxItem

maxRating

int maxRating

GRADIENT_RATIO

static final float GRADIENT_RATIO
See Also:
Constant Field Values

USE_EXPECTED_VALUE

boolean USE_EXPECTED_VALUE
Constructor Detail

ClusteringAlgorithm

public ClusteringAlgorithm(DataManager dataMgr)
Constructor, initialize DataManager, parameters and wArray.

Parameters:
dataMgr -
Method Detail

initRandomArray

public void initRandomArray(int numClasses)
Create the wArray and fill it with random values.

Parameters:
numClasses -

gradientAscentStep

float gradientAscentStep()
Do one step of gradient ascent to refine the values in wArray


normalizeArray

void normalizeArray()
Normalize wArray so that the probabilities for each rating on an item sum to 1. This condition is required because ratings are mutually exclusive (no item can have a rating of both 1 and 2 from the same user).


calcAllProbs

float[] calcAllProbs(java.util.Iterator evidence)
Calculate all probabilities.

Parameters:
evidence - - Iterator over evidence
Returns:
Array of probabilities

predictRating

public ItemPrediction predictRating(int userID,
                                    int itemID)
                             throws CFNotImplementedException
Asks the prediction engine to return a prediction for how a particular user will rate a particular item.

Specified by:
predictRating in interface CFAlgorithm
Parameters:
userID -
itemID -
Returns:
predictedRating
CFNotImplementedException

getAveragePredictionTime

public long getAveragePredictionTime()
                              throws CFNotImplementedException
Return average prediction time

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

getRecommendations

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

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

updateUser

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

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

getRecommendationsByType

public ItemPrediction[] getRecommendationsByType(int activeUser,
                                                 int n,
                                                 int type)
                                          throws java.sql.SQLException,
                                                 CFNotImplementedException
Haven't been implemented yet. Once getRecommendations() implemented, implement this.

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

CFEngine API

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