CFEngine API

org.recommender.algorithms.Experimental
Class ItemItemAlgorithm

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

public class ItemItemAlgorithm
extends java.lang.Object
implements CFAlgorithm

Describes an implementation of the CFAlgorithm interface to make CF predictions using the Item-Item adjusted cosine algorithm described in Sarwar, et al, 2001.

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

Field Summary
(package private)  float[] itemAverages
           
(package private)  java.util.List[] neighborLists
           
 
Constructor Summary
ItemItemAlgorithm(DataManager dataMgr)
          Constructor, initialize algorithm parameters and DataManager.
 
Method Summary
 long getAveragePredictionTime()
          Return average prediction time.
 ItemPrediction[] getRecommendations(int activeUser, int n)
          Get top n item recommendations for the activeUser.
 ItemPrediction[] getRecommendationsByType(int activeUser, int n, int type)
          Yun Wang Return top n recommendations of specific type.
 SimilarityWeight getWeight(int activeitem, int neighbor)
          Calculate similarity weight between two items.
 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)
          Currently does not need updateUser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

neighborLists

java.util.List[] neighborLists

itemAverages

float[] itemAverages
Constructor Detail

ItemItemAlgorithm

public ItemItemAlgorithm(DataManager dataMgr)
Constructor, initialize algorithm parameters and DataManager.

Parameters:
dataMgr -
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
Get top n item recommendations for the activeUser.

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

updateUser

public void updateUser(int userID)
                throws CFNotImplementedException
Currently does not need updateUser

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:
average prediction time
CFNotImplementedException

getWeight

public SimilarityWeight getWeight(int activeitem,
                                  int neighbor)
Calculate similarity weight between two items. Uses the adjusted cosine similarity measure.

Parameters:
activeitem -
neighbor -
Returns:
SimilarityWeight

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