Class KMeansPlusPlusClusterer<T extends Clusterable<T>>
java.lang.Object
org.apache.commons.math3.stat.clustering.KMeansPlusPlusClusterer<T>
- Type Parameters:
T
- type of the points to cluster
Deprecated.
Clustering algorithm based on David Arthur and Sergei Vassilvitski k-means++ algorithm.
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Deprecated.Strategies to use for replacing an empty cluster. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final KMeansPlusPlusClusterer.EmptyClusterStrategy
Deprecated.Selected strategy for empty clusters.private final Random
Deprecated.Random generator for choosing initial centers. -
Constructor Summary
ConstructorsConstructorDescriptionKMeansPlusPlusClusterer
(Random random) Deprecated.Build a clusterer.KMeansPlusPlusClusterer
(Random random, KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy) Deprecated.Build a clusterer. -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T extends Clusterable<T>>
intassignPointsToClusters
(List<Cluster<T>> clusters, Collection<T> points, int[] assignments) Deprecated.Adds the given points to the closestCluster
.private static <T extends Clusterable<T>>
List<Cluster<T>> chooseInitialCenters
(Collection<T> points, int k, Random random) Deprecated.Use K-means++ to choose the initial centers.cluster
(Collection<T> points, int k, int maxIterations) Deprecated.Runs the K-means++ clustering algorithm.cluster
(Collection<T> points, int k, int numTrials, int maxIterationsPerTrial) Deprecated.Runs the K-means++ clustering algorithm.private T
getFarthestPoint
(Collection<Cluster<T>> clusters) Deprecated.Get the point farthest to its cluster centerprivate static <T extends Clusterable<T>>
intgetNearestCluster
(Collection<Cluster<T>> clusters, T point) Deprecated.Returns the nearestCluster
to the given pointprivate T
getPointFromLargestNumberCluster
(Collection<Cluster<T>> clusters) Deprecated.Get a random point from theCluster
with the largest number of pointsprivate T
getPointFromLargestVarianceCluster
(Collection<Cluster<T>> clusters) Deprecated.Get a random point from theCluster
with the largest distance variance.
-
Field Details
-
random
Deprecated.Random generator for choosing initial centers. -
emptyStrategy
Deprecated.Selected strategy for empty clusters.
-
-
Constructor Details
-
KMeansPlusPlusClusterer
Deprecated.Build a clusterer.The default strategy for handling empty clusters that may appear during algorithm iterations is to split the cluster with largest distance variance.
- Parameters:
random
- random generator to use for choosing initial centers
-
KMeansPlusPlusClusterer
public KMeansPlusPlusClusterer(Random random, KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy) Deprecated.Build a clusterer.- Parameters:
random
- random generator to use for choosing initial centersemptyStrategy
- strategy to use for handling empty clusters that may appear during algorithm iterations- Since:
- 2.2
-
-
Method Details
-
cluster
public List<Cluster<T>> cluster(Collection<T> points, int k, int numTrials, int maxIterationsPerTrial) throws MathIllegalArgumentException, ConvergenceException Deprecated.Runs the K-means++ clustering algorithm.- Parameters:
points
- the points to clusterk
- the number of clusters to split the data intonumTrials
- number of trial runsmaxIterationsPerTrial
- the maximum number of iterations to run the algorithm for at each trial run. If negative, no maximum will be used- 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 theemptyStrategy
is set toERROR
-
cluster
public List<Cluster<T>> cluster(Collection<T> points, int k, int maxIterations) throws MathIllegalArgumentException, ConvergenceException Deprecated.Runs the K-means++ clustering algorithm.- Parameters:
points
- the points to clusterk
- the number of clusters to split the data intomaxIterations
- the maximum number of iterations to run the algorithm for. If negative, no maximum will be used- 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 theemptyStrategy
is set toERROR
-
assignPointsToClusters
private static <T extends Clusterable<T>> int assignPointsToClusters(List<Cluster<T>> clusters, Collection<T> points, int[] assignments) Deprecated.Adds the given points to the closestCluster
. -
chooseInitialCenters
private static <T extends Clusterable<T>> List<Cluster<T>> chooseInitialCenters(Collection<T> points, int k, Random random) Deprecated.Use K-means++ to choose the initial centers.- Type Parameters:
T
- type of the points to cluster- Parameters:
points
- the points to choose the initial centers fromk
- the number of centers to chooserandom
- random generator to use- Returns:
- the initial centers
-
getPointFromLargestVarianceCluster
private T getPointFromLargestVarianceCluster(Collection<Cluster<T>> clusters) throws ConvergenceException Deprecated.Get a random point from theCluster
with the largest distance variance.- Parameters:
clusters
- theCluster
s to search- Returns:
- a random point from the selected cluster
- Throws:
ConvergenceException
- if clusters are all empty
-
getPointFromLargestNumberCluster
private T getPointFromLargestNumberCluster(Collection<Cluster<T>> clusters) throws ConvergenceException Deprecated.Get a random point from theCluster
with the largest number of points- Parameters:
clusters
- theCluster
s to search- Returns:
- a random point from the selected cluster
- Throws:
ConvergenceException
- if clusters are all empty
-
getFarthestPoint
Deprecated.Get the point farthest to its cluster center- Parameters:
clusters
- theCluster
s to search- Returns:
- point farthest to its cluster center
- Throws:
ConvergenceException
- if clusters are all empty
-
getNearestCluster
private static <T extends Clusterable<T>> int getNearestCluster(Collection<Cluster<T>> clusters, T point) Deprecated.Returns the nearestCluster
to the given point
-
KMeansPlusPlusClusterer
instead