T
- type of the points to clusterKMeansPlusPlusClusterer
instead@Deprecated
public class KMeansPlusPlusClusterer<T extends Clusterable<T>>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
KMeansPlusPlusClusterer.EmptyClusterStrategy
Deprecated.
Strategies to use for replacing an empty cluster.
|
Modifier and Type | Field and Description |
---|---|
private KMeansPlusPlusClusterer.EmptyClusterStrategy |
emptyStrategy
Deprecated.
Selected strategy for empty clusters.
|
private java.util.Random |
random
Deprecated.
Random generator for choosing initial centers.
|
Constructor and Description |
---|
KMeansPlusPlusClusterer(java.util.Random random)
Deprecated.
Build a clusterer.
|
KMeansPlusPlusClusterer(java.util.Random random,
KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy)
Deprecated.
Build a clusterer.
|
Modifier and Type | Method and Description |
---|---|
private static <T extends Clusterable<T>> |
assignPointsToClusters(java.util.List<Cluster<T>> clusters,
java.util.Collection<T> points,
int[] assignments)
Deprecated.
Adds the given points to the closest
Cluster . |
private static <T extends Clusterable<T>> |
chooseInitialCenters(java.util.Collection<T> points,
int k,
java.util.Random random)
Deprecated.
Use K-means++ to choose the initial centers.
|
java.util.List<Cluster<T>> |
cluster(java.util.Collection<T> points,
int k,
int maxIterations)
Deprecated.
Runs the K-means++ clustering algorithm.
|
java.util.List<Cluster<T>> |
cluster(java.util.Collection<T> points,
int k,
int numTrials,
int maxIterationsPerTrial)
Deprecated.
Runs the K-means++ clustering algorithm.
|
private T |
getFarthestPoint(java.util.Collection<Cluster<T>> clusters)
Deprecated.
Get the point farthest to its cluster center
|
private static <T extends Clusterable<T>> |
getNearestCluster(java.util.Collection<Cluster<T>> clusters,
T point)
Deprecated.
Returns the nearest
Cluster to the given point |
private T |
getPointFromLargestNumberCluster(java.util.Collection<Cluster<T>> clusters)
Deprecated.
Get a random point from the
Cluster with the largest number of points |
private T |
getPointFromLargestVarianceCluster(java.util.Collection<Cluster<T>> clusters)
Deprecated.
Get a random point from the
Cluster with the largest distance variance. |
private final java.util.Random random
private final KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy
public KMeansPlusPlusClusterer(java.util.Random random)
The default strategy for handling empty clusters that may appear during algorithm iterations is to split the cluster with largest distance variance.
random
- random generator to use for choosing initial centerspublic KMeansPlusPlusClusterer(java.util.Random random, KMeansPlusPlusClusterer.EmptyClusterStrategy emptyStrategy)
random
- random generator to use for choosing initial centersemptyStrategy
- strategy to use for handling empty clusters that
may appear during algorithm iterationspublic java.util.List<Cluster<T>> cluster(java.util.Collection<T> points, int k, int numTrials, int maxIterationsPerTrial) throws MathIllegalArgumentException, ConvergenceException
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 usedMathIllegalArgumentException
- 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
emptyStrategy
is set to ERROR
public java.util.List<Cluster<T>> cluster(java.util.Collection<T> points, int k, int maxIterations) throws MathIllegalArgumentException, ConvergenceException
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 usedMathIllegalArgumentException
- 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
emptyStrategy
is set to ERROR
private static <T extends Clusterable<T>> int assignPointsToClusters(java.util.List<Cluster<T>> clusters, java.util.Collection<T> points, int[] assignments)
Cluster
.private static <T extends Clusterable<T>> java.util.List<Cluster<T>> chooseInitialCenters(java.util.Collection<T> points, int k, java.util.Random random)
T
- type of the points to clusterpoints
- the points to choose the initial centers fromk
- the number of centers to chooserandom
- random generator to useprivate T getPointFromLargestVarianceCluster(java.util.Collection<Cluster<T>> clusters) throws ConvergenceException
Cluster
with the largest distance variance.clusters
- the Cluster
s to searchConvergenceException
- if clusters are all emptyprivate T getPointFromLargestNumberCluster(java.util.Collection<Cluster<T>> clusters) throws ConvergenceException
Cluster
with the largest number of pointsclusters
- the Cluster
s to searchConvergenceException
- if clusters are all emptyprivate T getFarthestPoint(java.util.Collection<Cluster<T>> clusters) throws ConvergenceException
clusters
- the Cluster
s to searchConvergenceException
- if clusters are all emptyprivate static <T extends Clusterable<T>> int getNearestCluster(java.util.Collection<Cluster<T>> clusters, T point)
Cluster
to the given point