|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.cf.taste.impl.similarity.EuclideanDistanceSimilarity
public final class EuclideanDistanceSimilarity
An implementation of a "similarity" based on the Euclidean "distance" between two users X and Y. Thinking of items as dimensions and preferences as points along those dimensions, a distance is computed using all items (dimensions) where both users have expressed a preference for that item. This is simply the square root of the sum of the squares of differences in position (preference) along each dimension. The similarity is then computed as 1 / (1 + distance), so the resulting values are in the range (0,1].
Constructor Summary | |
---|---|
EuclideanDistanceSimilarity(DataModel dataModel)
|
|
EuclideanDistanceSimilarity(DataModel dataModel,
Weighting weighting)
|
Method Summary | |
---|---|
PreferenceTransform |
getPrefTransform()
|
SimilarityTransform |
getSimilarityTransform()
|
double |
itemSimilarity(long itemID1,
long itemID2)
Returns the degree of similarity, of two items, based on the preferences that users have expressed for the items. |
void |
refresh(java.util.Collection<Refreshable> alreadyRefreshed)
Triggers "refresh" -- whatever that means -- of the implementation. |
void |
setPreferenceInferrer(PreferenceInferrer inferrer)
Attaches a PreferenceInferrer to the implementation. |
void |
setPrefTransform(PreferenceTransform prefTransform)
|
void |
setSimilarityTransform(SimilarityTransform similarityTransform)
|
java.lang.String |
toString()
|
double |
userSimilarity(long userID1,
long userID2)
Returns the 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, wait, wait, wait |
Constructor Detail |
---|
public EuclideanDistanceSimilarity(DataModel dataModel) throws TasteException
java.lang.IllegalArgumentException
- if DataModel
does not have preference values
TasteException
public EuclideanDistanceSimilarity(DataModel dataModel, Weighting weighting) throws TasteException
java.lang.IllegalArgumentException
- if DataModel
does not have preference values
TasteException
Method Detail |
---|
public final void setPreferenceInferrer(PreferenceInferrer inferrer)
UserSimilarity
Attaches a PreferenceInferrer
to the implementation.
setPreferenceInferrer
in interface UserSimilarity
inferrer
- PreferenceInferrer
public final PreferenceTransform getPrefTransform()
public final void setPrefTransform(PreferenceTransform prefTransform)
public final SimilarityTransform getSimilarityTransform()
public final void setSimilarityTransform(SimilarityTransform similarityTransform)
public double userSimilarity(long userID1, long userID2) throws TasteException
UserSimilarity
Returns the degree of similarity, of two users, based on the their preferences.
userSimilarity
in interface UserSimilarity
userID1
- first user IDuserID2
- second user ID
TasteException
- if an error occurs while accessing the datapublic final double itemSimilarity(long itemID1, long itemID2) throws TasteException
ItemSimilarity
Returns the degree of similarity, of two items, based on the preferences that users have expressed for the items.
itemSimilarity
in interface ItemSimilarity
itemID1
- first item IDitemID2
- second item ID
TasteException
- if an error occurs while accessing the datapublic final void refresh(java.util.Collection<Refreshable> alreadyRefreshed)
Refreshable
Triggers "refresh" -- whatever that means -- of the implementation. The general contract is that any 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
alreadyRefreshed
- s that are known to have already been
refreshed as a result of an initial call to a method on some
object. This ensure that objects in a refresh dependency graph aren't refreshed twice
needlessly.public final 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 |