org.hermit.geometry.cluster
Class FuzzyClusterer

java.lang.Object
  extended by org.hermit.geometry.cluster.Clusterer
      extended by org.hermit.geometry.cluster.FuzzyClusterer

public class FuzzyClusterer
extends Clusterer

An implementation of Lloyd's k-clusterMeans clustering algorithm.


Constructor Summary
FuzzyClusterer()
           
 
Method Summary
 boolean iterate()
          Runs a single iteration of the clustering algorithm on the stored data.
 double metric()
          Calculate a quality metric for the current clustering solution.
 void prepare(Point[] points, int[] ids, double[][] means, Region region)
          Prepare a clustering pass on the indicated data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FuzzyClusterer

public FuzzyClusterer()
Method Detail

prepare

public void prepare(Point[] points,
                    int[] ids,
                    double[][] means,
                    Region region)
Prepare a clustering pass on the indicated data.

Overrides:
prepare in class Clusterer
Parameters:
points - The array of dataPoints to be clustered.
ids - Array of cluster numbers which this call will fill in, defining which cluster each point belongs to. The caller must leave the data here intact between iterations.
means - Array of x,y values in which to place centroids of the clusters.
region - The region of the plane in which the points lie.

iterate

public boolean iterate()
Runs a single iteration of the clustering algorithm on the stored data. The results are stored in the arrays that were passed into prepare(Point[], int[], double[][], Region).

After each iteration, the cluster IDs and cluster means should be consistent with each other.

Specified by:
iterate in class Clusterer
Returns:
true if the algorithm has converged.

metric

public double metric()
Calculate a quality metric for the current clustering solution. This number is available after each call to iterate().

Specified by:
metric in class Clusterer
Returns:
Quality metric for this solution; small is better.