|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.planetj.taste.impl.correlation.PearsonCorrelation
public final class PearsonCorrelation
An implementation of the Pearson correlation. For Users X and Y, the following values
are calculated:
The correlation is then:
sumXY / sqrt(sumX2 * sumY2)
where size is the number of Items in the DataModel.
Note that this correlation "centers" its data, shifts the user's preference values so that each of their means is 0. This is necessary to achieve expected behavior on all data sets.
This correlation implementation is equivalent to the cosine measure correlation since the data it receives is assumed to be centered -- mean is 0. The correlation may be interpreted as the cosine of the angle between the two vectors defined by the users' preference values.
| Constructor Summary | |
|---|---|
PearsonCorrelation(DataModel dataModel)
Creates a normal (unweighted) PearsonCorrelation. |
|
PearsonCorrelation(DataModel dataModel,
boolean weighted)
Creates a weighted PearsonCorrelation. |
|
| Method Summary | |
|---|---|
CorrelationTransform<?> |
getCorrelationTransform()
|
PreferenceTransform2 |
getPrefTransform()
|
double |
itemCorrelation(Item item1,
Item item2)
Returns the "itemCorrelation", or degree of similarity, of two |
void |
refresh()
Triggers "refresh" -- whatever that means -- of the implementation. |
void |
setCorrelationTransform(CorrelationTransform<java.lang.Object> correlationTransform)
|
void |
setPreferenceInferrer(PreferenceInferrer inferrer)
Attaches a |
void |
setPrefTransform(PreferenceTransform2 prefTransform)
|
java.lang.String |
toString()
|
double |
userCorrelation(User user1,
User user2)
Returns the "itemCorrelation", or degree of similarity, of two |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public PearsonCorrelation(@Nullable
DataModel dataModel)
Creates a normal (unweighted) PearsonCorrelation.
dataModel -
public PearsonCorrelation(@Nullable
DataModel dataModel,
boolean weighted)
Creates a weighted PearsonCorrelation.
dataModel - weighted - | Method Detail |
|---|
public void setPreferenceInferrer(@Nullable
PreferenceInferrer inferrer)
Attaches a PreferenceInferrer to the UserCorrelation implementation.
setPreferenceInferrer in interface UserCorrelationinferrer - PreferenceInferrer@Nullable public PreferenceTransform2 getPrefTransform()
public void setPrefTransform(@Nullable
PreferenceTransform2 prefTransform)
@Nullable public CorrelationTransform<?> getCorrelationTransform()
public void setCorrelationTransform(@Nullable
CorrelationTransform<java.lang.Object> correlationTransform)
public double userCorrelation(@Nullable
User user1,
@Nullable
User user2)
throws TasteException
Returns the "itemCorrelation", or degree of similarity, of two Users, based
on the their preferences.
userCorrelation in interface UserCorrelationuser1 - first useruser2 - second user
TasteException - if an error occurs while accessing the data
public double itemCorrelation(@Nullable
Item item1,
@Nullable
Item item2)
throws TasteException
Returns the "itemCorrelation", or degree of similarity, of two Items, based
on the preferences that Users have expressed for the items.
itemCorrelation in interface ItemCorrelationitem1 - first itemitem2 - second item
Items
TasteException - if an error occurs while accessing the datapublic 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.
refresh in interface Refreshable@NotNull public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||