com.hedgehog.geo.twod.points
Class KMeansPoint2D

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.geo.twod.points.KMeansPoint2D
All Implemented Interfaces:
java.lang.Comparable, java.util.Comparator

public class KMeansPoint2D
extends HObject

Title: KMeansPoint2D - performs a k-means clustering of 2D points.

Description: Performs a k-means clustering of Point2D points. The k-means algorithm specifies how many cluster centroids (mNumberOfClusters) are to be prescribed. The point set is then partitioned into mNumberOfClusters sub-point sets centred around an associated centroid point. The input is a Point2DSet and the output of the extraction method extractClusters() is an array of sub-cluster points and field mCentroids set to the cluster centroids.

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
KMeansPoint2D()
          Default constructor.
KMeansPoint2D(int numberClusters, int numberIterations, double tolerance)
          Constructor.
 
Method Summary
 double[] averageDistanceFromClusterCentroid()
          Returns the average distance of each point of the set rom its associated cluster centroid.
 double[] clusterStandardDeviations()
          Returns the cluster standard deviations from the their average cluster centroid distance.
 void extractClusters(Point2DSet pset)
          Extracts the clusters from the point set.
 Point2D[] getClusterCentroids()
          Returns the cluster centroids.
 Point2DSet[] getClusterPoints()
          Returns the cluster point sets.
 int getNumberOfClusters()
          Returns the number of clusters.
 int getNumberOfIterations()
          Returns the maximum number of iterations.
 double getTolerance()
          Returns the tolerance.
 void setNumberOfIterations(int numberOfIterations)
          Sets the maximum number of iterations.
 void setTolerance(double tolerance)
          Sets the tolerance.
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KMeansPoint2D

public KMeansPoint2D()
Default constructor. Creates a default Simple K-means clusterer with 100 iterations, 2 clusters, a default random generator and using the Euclidean distance.


KMeansPoint2D

public KMeansPoint2D(int numberClusters,
                     int numberIterations,
                     double tolerance)
              throws java.lang.IllegalArgumentException
Constructor. Creates a k-means clusterer with the specified number of clusters, maxmimum number of iterations and tolerance.

Parameters:
numberClusters - The number of clustesrs.
numberIterations - The number of iterations. The maximum is 1,000.
tolerance - Required tolerance.
Throws:
java.lang.IllegalArgumentException - Thrown if numberClusters < 1,
Method Detail

getClusterCentroids

public Point2D[] getClusterCentroids()
Returns the cluster centroids.

Returns:
Array of cluster centroids.

getClusterPoints

public Point2DSet[] getClusterPoints()
Returns the cluster point sets.

Returns:
CLuster point sets.

getNumberOfClusters

public int getNumberOfClusters()
Returns the number of clusters.

Returns:
The number of clusters.

getNumberOfIterations

public int getNumberOfIterations()
Returns the maximum number of iterations.

Returns:
The maximum number of iterations.

getTolerance

public double getTolerance()
Returns the tolerance.

Returns:
Tolerance used.

setNumberOfIterations

public void setNumberOfIterations(int numberOfIterations)
Sets the maximum number of iterations.

Parameters:
numberOfIterations - The new maximum number of iterations.

setTolerance

public void setTolerance(double tolerance)
Sets the tolerance.

Parameters:
tolerance - Tolerance.

averageDistanceFromClusterCentroid

public double[] averageDistanceFromClusterCentroid()
Returns the average distance of each point of the set rom its associated cluster centroid.

Returns:
The average distance of each point of the set rom its associated cluster centroid.

clusterStandardDeviations

public double[] clusterStandardDeviations()
Returns the cluster standard deviations from the their average cluster centroid distance.

Returns:
The standard deviation of each cluster from its associated cluster centroid.

extractClusters

public void extractClusters(Point2DSet pset)
                     throws java.lang.IllegalArgumentException
Extracts the clusters from the point set. Sets mClusterPoints to the extracted array of cluster point sets.

Parameters:
pset - Point set.
Throws:
java.lang.IllegalArgumentException - Thrown if pset is null or empty.