T
- type of the points to clusterpublic class KMeansPlusPlusClusterer<T extends Clusterable> extends Clusterer<T>
Modifier and Type | Class and Description |
---|---|
static class |
KMeansPlusPlusClusterer.EmptyClusterStrategy
Strategies to use for replacing an empty cluster.
|
Constructor and Description |
---|
KMeansPlusPlusClusterer(int k)
Build a clusterer.
|
KMeansPlusPlusClusterer(int k,
int maxIterations)
Build a clusterer.
|
KMeansPlusPlusClusterer(int k,
int maxIterations,
DistanceMeasure measure)
Build a clusterer.
|
KMeansPlusPlusClusterer(int k,
int maxIterations,
DistanceMeasure measure,
RandomGenerator random)
Build a clusterer.
|
KMeansPlusPlusClusterer(int k,
int maxIterations,
DistanceMeasure measure,
RandomGenerator random,
KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy)
Build a clusterer.
|
Modifier and Type | Method and Description |
---|---|
List<CentroidCluster<T>> |
cluster(Collection<T> points)
Runs the K-means++ clustering algorithm.
|
KMeansPlusPlusClusterer.EmptyClusterStrategy |
getEmptyClusterStrategy()
Returns the
KMeansPlusPlusClusterer.EmptyClusterStrategy used by this instance. |
int |
getK()
Return the number of clusters this instance will use.
|
int |
getMaxIterations()
Returns the maximum number of iterations this instance will use.
|
RandomGenerator |
getRandomGenerator()
Returns the random generator this instance will use.
|
distance, getDistanceMeasure
public KMeansPlusPlusClusterer(int k)
The default strategy for handling empty clusters that may appear during algorithm iterations is to split the cluster with largest distance variance.
The euclidean distance will be used as default distance measure.
k
- the number of clusters to split the data intopublic KMeansPlusPlusClusterer(int k, int maxIterations)
The default strategy for handling empty clusters that may appear during algorithm iterations is to split the cluster with largest distance variance.
The euclidean distance will be used as default distance measure.
k
- 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.public KMeansPlusPlusClusterer(int k, int maxIterations, DistanceMeasure measure)
The default strategy for handling empty clusters that may appear during algorithm iterations is to split the cluster with largest distance variance.
k
- 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.measure
- the distance measure to usepublic KMeansPlusPlusClusterer(int k, int maxIterations, DistanceMeasure measure, RandomGenerator random)
The default strategy for handling empty clusters that may appear during algorithm iterations is to split the cluster with largest distance variance.
k
- 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.measure
- the distance measure to userandom
- random generator to use for choosing initial centerspublic KMeansPlusPlusClusterer(int k, int maxIterations, DistanceMeasure measure, RandomGenerator random, KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy)
k
- 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.measure
- the distance measure to userandom
- random generator to use for choosing initial centersemptyStrategy
- strategy to use for handling empty clusters that
may appear during algorithm iterationspublic int getK()
public int getMaxIterations()
public RandomGenerator getRandomGenerator()
public KMeansPlusPlusClusterer.EmptyClusterStrategy getEmptyClusterStrategy()
KMeansPlusPlusClusterer.EmptyClusterStrategy
used by this instance.KMeansPlusPlusClusterer.EmptyClusterStrategy
public List<CentroidCluster<T>> cluster(Collection<T> points) throws MathIllegalArgumentException, MathIllegalStateException
cluster
in class Clusterer<T extends Clusterable>
points
- the points to clusterMathIllegalArgumentException
- 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
emptyStrategy
is set to ERROR
Copyright © 2016–2019 Hipparchus.org. All rights reserved.