Class MultiKMeansPlusPlusClusterer<T extends Clusterable>
- java.lang.Object
-
- org.apache.commons.math4.legacy.ml.clustering.Clusterer<T>
-
- org.apache.commons.math4.legacy.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
-
-
Constructor Summary
Constructors Constructor Description MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer, int numTrials)
Build a clusterer.MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer, int numTrials, ClusterRanking evaluator)
Build a clusterer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<CentroidCluster<T>>
cluster(Collection<T> points)
Runs the K-means++ clustering algorithm.-
Methods inherited from class org.apache.commons.math4.legacy.ml.clustering.Clusterer
distance, getDistanceMeasure
-
-
-
-
Constructor Detail
-
MultiKMeansPlusPlusClusterer
public MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer, int numTrials)
Build a clusterer.- Parameters:
clusterer
- the k-means clusterer to usenumTrials
- number of trial runs
-
MultiKMeansPlusPlusClusterer
public MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer, int numTrials, ClusterRanking evaluator)
Build a clusterer.- Parameters:
clusterer
- the k-means clusterer to usenumTrials
- number of trial runsevaluator
- the cluster evaluator to use- Since:
- 3.3
-
-
Method Detail
-
cluster
public List<CentroidCluster<T>> cluster(Collection<T> points)
Runs the K-means++ clustering algorithm.- Specified by:
cluster
in classClusterer<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 pointsConvergenceException
- if an empty cluster is encountered and the underlyingKMeansPlusPlusClusterer
has itsKMeansPlusPlusClusterer.EmptyClusterStrategy
is set toERROR
.
-
-