com.planetj.taste.impl.correlation
Class SpearmanCorrelation

java.lang.Object
  extended by com.planetj.taste.impl.correlation.SpearmanCorrelation
All Implemented Interfaces:
Refreshable, UserCorrelation

public final class SpearmanCorrelation
extends java.lang.Object
implements UserCorrelation

Like PearsonCorrelation, but compares relative ranking of preference values instead of preference values themselves. That is, each User's preferences are sorted and then assign a rank as their preference value, with 1 being assigned to the least preferred item. Then the Pearson itemCorrelation of these rank values is computed.

Author:
Sean Owen

Constructor Summary
SpearmanCorrelation(DataModel dataModel)
           
SpearmanCorrelation(UserCorrelation rankingUserCorrelation)
           
 
Method Summary
 void refresh()
          

Triggers "refresh" -- whatever that means -- of the implementation.

 void setPreferenceInferrer(PreferenceInferrer inferrer)
          

Attaches a PreferenceInferrer to the UserCorrelation implementation.

 double userCorrelation(User user1, User user2)
          

Returns the "itemCorrelation", or degree of similarity, of two Users, based on the their preferences.

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpearmanCorrelation

public SpearmanCorrelation(DataModel dataModel)

SpearmanCorrelation

public SpearmanCorrelation(UserCorrelation rankingUserCorrelation)
Method Detail

userCorrelation

public double userCorrelation(User user1,
                              User user2)
                       throws TasteException

Returns the "itemCorrelation", or degree of similarity, of two Users, based on the their preferences.

Specified by:
userCorrelation in interface UserCorrelation
Parameters:
user1 - first user
user2 - second user
Returns:
itemCorrelation between the two users
Throws:
TasteException - if an error occurs while accessing the data

setPreferenceInferrer

public void setPreferenceInferrer(PreferenceInferrer inferrer)

Attaches a PreferenceInferrer to the UserCorrelation implementation.

Specified by:
setPreferenceInferrer in interface UserCorrelation
Parameters:
inferrer - PreferenceInferrer

refresh

public void refresh()

Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any Refreshable should always leave itself in a consistent, operational state, and that the refresh atomically updates internal state from old to new.

Specified by:
refresh in interface Refreshable