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

java.lang.Object
  extended by org.apache.commons.math3.ml.clustering.Clusterer<T>
      extended by org.apache.commons.math3.ml.clustering.MultiKMeansPlusPlusClusterer<T>
Type Parameters:
T - type of the points to cluster

public class MultiKMeansPlusPlusClusterer<T extends Clusterable>
extends Clusterer<T>

A wrapper around a k-means++ clustering algorithm which performs multiple trials and returns the best solution.

Since:
3.2
Version:
$Id: MultiKMeansPlusPlusClusterer.html 857555 2013-04-06 23:30:25Z luc $

Constructor Summary
MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer, int numTrials)
          Build a clusterer.
 
Method Summary
 List<CentroidCluster<T>> cluster(Collection<T> points)
          Runs the K-means++ clustering algorithm.
 KMeansPlusPlusClusterer<T> getClusterer()
          Returns the embedded k-means clusterer used by this instance.
 int getNumTrials()
          Returns the number of trials this instance will do.
 
Methods inherited from class org.apache.commons.math3.ml.clustering.Clusterer
distance, getDistanceMeasure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiKMeansPlusPlusClusterer

public MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer,
                                    int numTrials)
Build a clusterer.

Parameters:
clusterer - the k-means clusterer to use
numTrials - number of trial runs
Method Detail

getClusterer

public KMeansPlusPlusClusterer<T> getClusterer()
Returns the embedded k-means clusterer used by this instance.

Returns:
the embedded clusterer

getNumTrials

public int getNumTrials()
Returns the number of trials this instance will do.

Returns:
the number of trials

cluster

public List<CentroidCluster<T>> cluster(Collection<T> points)
                                                     throws MathIllegalArgumentException,
                                                            ConvergenceException
Runs the K-means++ clustering algorithm.

Specified by:
cluster in class Clusterer<T extends Clusterable>
Parameters:
points - the points to cluster
Returns:
a list of clusters containing the points
Throws:
MathIllegalArgumentException - if the data points are null or the number of clusters is larger than the number of data points
ConvergenceException - if an empty cluster is encountered and the underlying KMeansPlusPlusClusterer has its KMeansPlusPlusClusterer.EmptyClusterStrategy is set to ERROR.


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