Package org.hipparchus.clustering
Class MultiKMeansPlusPlusClusterer<T extends Clusterable>
java.lang.Object
org.hipparchus.clustering.Clusterer<T>
org.hipparchus.clustering.MultiKMeansPlusPlusClusterer<T>
- Type Parameters:
T
- type of the points to cluster
A wrapper around a k-means++ clustering algorithm which performs multiple trials
and returns the best solution.
-
Constructor Summary
ConstructorDescriptionMultiKMeansPlusPlusClusterer
(KMeansPlusPlusClusterer<T> clusterer, int numTrials) Build a clusterer.MultiKMeansPlusPlusClusterer
(KMeansPlusPlusClusterer<T> clusterer, int numTrials, ClusterEvaluator<T> evaluator) Build a clusterer. -
Method Summary
Modifier and TypeMethodDescriptioncluster
(Collection<T> points) Runs the K-means++ clustering algorithm.Returns the embedded k-means clusterer used by this instance.Returns theClusterEvaluator
used to determine the "best" clustering.int
Returns the number of trials this instance will do.Methods inherited from class org.hipparchus.clustering.Clusterer
distance, getDistanceMeasure
-
Constructor Details
-
MultiKMeansPlusPlusClusterer
Build a clusterer.- Parameters:
clusterer
- the k-means clusterer to usenumTrials
- number of trial runs
-
MultiKMeansPlusPlusClusterer
public MultiKMeansPlusPlusClusterer(KMeansPlusPlusClusterer<T> clusterer, int numTrials, ClusterEvaluator<T> evaluator) Build a clusterer.- Parameters:
clusterer
- the k-means clusterer to usenumTrials
- number of trial runsevaluator
- the cluster evaluator to use
-
-
Method Details
-
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
-
getClusterEvaluator
Returns theClusterEvaluator
used to determine the "best" clustering.- Returns:
- the used
ClusterEvaluator
-
cluster
public List<CentroidCluster<T>> cluster(Collection<T> points) throws MathIllegalArgumentException, MathIllegalStateException 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 pointsMathIllegalStateException
- if an empty cluster is encountered and the underlyingKMeansPlusPlusClusterer
has itsKMeansPlusPlusClusterer.EmptyClusterStrategy
is set toERROR
.
-