org.apache.mahout.cf.taste.impl.recommender
Class NearestNeighborClusterSimilarity

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.recommender.NearestNeighborClusterSimilarity
All Implemented Interfaces:
Refreshable, ClusterSimilarity

public final class NearestNeighborClusterSimilarity
extends Object
implements ClusterSimilarity

Defines cluster similarity as the largest similarity between any two users in the clusters -- that is, it says that clusters are close when some pair of their members has high similarity.


Constructor Summary
NearestNeighborClusterSimilarity(UserSimilarity similarity)
           Constructs a based on the given UserSimilarity.
NearestNeighborClusterSimilarity(UserSimilarity similarity, double samplingRate)
           Constructs a based on the given UserSimilarity.
 
Method Summary
 double getSimilarity(FastIDSet cluster1, FastIDSet cluster2)
           
 void refresh(Collection<Refreshable> alreadyRefreshed)
           Triggers "refresh" -- whatever that means -- of the implementation.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NearestNeighborClusterSimilarity

public NearestNeighborClusterSimilarity(UserSimilarity similarity)

Constructs a based on the given UserSimilarity. All user-user similarities are examined.


NearestNeighborClusterSimilarity

public NearestNeighborClusterSimilarity(UserSimilarity similarity,
                                        double samplingRate)

Constructs a based on the given UserSimilarity. By setting samplingRate to a value less than 1.0, this implementation will only examine that fraction of all user-user similarities between two clusters, increasing performance at the expense of accuracy.

Method Detail

getSimilarity

public double getSimilarity(FastIDSet cluster1,
                            FastIDSet cluster2)
                     throws TasteException
Specified by:
getSimilarity in interface ClusterSimilarity
Parameters:
cluster1 - first cluster of user IDs
cluster2 - second cluster of user IDs
Returns:
"distance" between clusters; a bigger value means less similarity
Throws:
TasteException - if an error occurs while computing similarity, such as errors accessing an underlying DataModel

refresh

public void refresh(Collection<Refreshable> alreadyRefreshed)
Description copied from interface: 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.

Specified by:
refresh in interface Refreshable
Parameters:
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.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.