com.planetj.taste.impl.recommender
Class NearestNeighborClusterSimilarity

java.lang.Object
  extended by com.planetj.taste.impl.recommender.NearestNeighborClusterSimilarity
All Implemented Interfaces:
Refreshable, ClusterSimilarity

public final class NearestNeighborClusterSimilarity
extends java.lang.Object
implements ClusterSimilarity

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

Since:
1.1
Author:
Sean Owen

Constructor Summary
NearestNeighborClusterSimilarity(UserCorrelation correlation)
          Constructs a NearestNeighborClusterSimilarity based on the given UserCorrelation.
NearestNeighborClusterSimilarity(UserCorrelation correlation, double samplingPercentage)
          Constructs a NearestNeighborClusterSimilarity based on the given UserCorrelation.
 
Method Summary
 double getSimilarity(java.util.Collection<User> cluster1, java.util.Collection<User> cluster2)
          
 void refresh()
          

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

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

Constructor Detail

NearestNeighborClusterSimilarity

public NearestNeighborClusterSimilarity(UserCorrelation correlation)

Constructs a NearestNeighborClusterSimilarity based on the given UserCorrelation. All user-user correlations are examined.

Parameters:
correlation -

NearestNeighborClusterSimilarity

public NearestNeighborClusterSimilarity(UserCorrelation correlation,
                                        double samplingPercentage)

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

Parameters:
correlation -
samplingPercentage -
Since:
1.4.5
Method Detail

getSimilarity

public double getSimilarity(java.util.Collection<User> cluster1,
                            java.util.Collection<User> cluster2)
                     throws TasteException

Specified by:
getSimilarity in interface ClusterSimilarity
Parameters:
cluster1 - first cluster of Users
cluster2 - second cluste rof Users
Returns:
"distance" between clusters; a positiv
Throws:
TasteException - if an error occurs while computing similarity, such as errors accessing an underlying DataModel

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

toString

@NotNull
public java.lang.String toString()
Overrides:
toString in class java.lang.Object