org.apache.commons.math3.ml.clustering
Class Clusterer<T extends Clusterable>

java.lang.Object
  extended by org.apache.commons.math3.ml.clustering.Clusterer<T>
Type Parameters:
T - the type of points that can be clustered
Direct Known Subclasses:
DBSCANClusterer, KMeansPlusPlusClusterer, MultiKMeansPlusPlusClusterer

public abstract class Clusterer<T extends Clusterable>
extends Object

Base class for clustering algorithms.

Since:
3.2
Version:
$Id $

Constructor Summary
protected Clusterer(DistanceMeasure measure)
          Build a new clusterer with the given DistanceMeasure.
 
Method Summary
abstract  List<? extends Cluster<T>> cluster(Collection<T> points)
          Perform a cluster analysis on the given set of Clusterable instances.
protected  double distance(Clusterable p1, Clusterable p2)
          Calculates the distance between two Clusterable instances with the configured DistanceMeasure.
 DistanceMeasure getDistanceMeasure()
          Returns the DistanceMeasure instance used by this clusterer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clusterer

protected Clusterer(DistanceMeasure measure)
Build a new clusterer with the given DistanceMeasure.

Parameters:
measure - the distance measure to use
Method Detail

cluster

public abstract List<? extends Cluster<T>> cluster(Collection<T> points)
                                                                throws MathIllegalArgumentException,
                                                                       ConvergenceException
Perform a cluster analysis on the given set of Clusterable instances.

Parameters:
points - the set of Clusterable instances
Returns:
a List of clusters
Throws:
MathIllegalArgumentException - if points are null or the number of data points is not compatible with this clusterer
ConvergenceException - if the algorithm has not yet converged after the maximum number of iterations has been exceeded

getDistanceMeasure

public DistanceMeasure getDistanceMeasure()
Returns the DistanceMeasure instance used by this clusterer.

Returns:
the distance measure

distance

protected double distance(Clusterable p1,
                          Clusterable p2)
Calculates the distance between two Clusterable instances with the configured DistanceMeasure.

Parameters:
p1 - the first clusterable
p2 - the second clusterable
Returns:
the distance between the two clusterables


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.