CFEngine API

org.recommender.algorithms.Experimental
Class SimpleDistributionAlgorithm

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

public class SimpleDistributionAlgorithm
extends java.lang.Object
implements CFAlgorithm

Describes an implementation of the CFAlgorithm interface to make CF predictions using the Simple Pearson Correlation combined with distribtion vectors.

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

Field Summary
(package private)  int formula
          Variables declaring how the algorithm will run
(package private)  int predictionStyle
           
 
Constructor Summary
SimpleDistributionAlgorithm(DataManager dataMgr)
          Constructor, pass in dataMgr and initialize algorithm parameters.
 
Method Summary
 ItemPrediction computeRating(float[] activeDist, float[] difDist, float activeMean, int itemNumber)
          Return the computed prediction
 float[] getActiveUserDist(int activeuser)
          Return the DistributionArray of the active user
 long getAveragePredictionTime()
          Return average prediction time.
 float[] getItemDist(int item)
          Return the DistributionArray of the active user
 ItemPrediction[] getRecommendations(int activeUser, int n)
          Return top n recommendations.
 ItemPrediction[] getRecommendationsByType(int activeUser, int n, int type)
          Return top n recommendations of specific type.
 SimilarityWeight getWeight(int activeuser, int neighbor, int itemId)
          Calculate CorrelatinCoeff for an item between the activeuser and one neighbor.
 float[] mapDist(float[] ActiveUserDist, float[] DifDist, float ActiveAverage)
          Return the return the sum/Mapping of the ActiveDistribution and the DifDistribution
 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.
 int transfer_to_index(float difference)
          Return the return the mapped index of the relativeDifDist
 void updateUser(int userID)
          Haven't been implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

formula

int formula
Variables declaring how the algorithm will run


predictionStyle

int predictionStyle
Constructor Detail

SimpleDistributionAlgorithm

public SimpleDistributionAlgorithm(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
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:
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 itemId)
Calculate CorrelatinCoeff for an item between the activeuser and one neighbor.

Parameters:
activeuser -
neighbor -
itemId -
Returns:
SimilarityWeight

updateUser

public void updateUser(int userID)
                throws CFNotImplementedException
Haven't been 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

mapDist

public float[] mapDist(float[] ActiveUserDist,
                       float[] DifDist,
                       float ActiveAverage)
Return the return the sum/Mapping of the ActiveDistribution and the DifDistribution

Parameters:
ActiveUserDist -
DifDist -
Returns:
Sum/Mapping of Distributions

transfer_to_index

public int transfer_to_index(float difference)
Return the return the mapped index of the relativeDifDist

Parameters:
difference -
Returns:
Mapped Index

getActiveUserDist

public float[] getActiveUserDist(int activeuser)
Return the DistributionArray of the active user

Returns:
ActiveUserDistArray

getItemDist

public float[] getItemDist(int item)
Return the DistributionArray of the active user

Returns:
ActiveUserDistArray

computeRating

public ItemPrediction computeRating(float[] activeDist,
                                    float[] difDist,
                                    float activeMean,
                                    int itemNumber)
Return the computed prediction

Parameters:
difDist -
Returns:
predicted rating

CFEngine API

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