|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.commons.math.stat.clustering.KMeansPlusPlusClusterer<T>
T - type of the points to clusterpublic class KMeansPlusPlusClusterer<T extends Clusterable<T>>
Clustering algorithm based on David Arthur and Sergei Vassilvitski k-means++ algorithm.
| Field Summary | |
|---|---|
private Random |
random
Random generator for choosing initial centers. |
| Constructor Summary | |
|---|---|
KMeansPlusPlusClusterer(Random random)
Build a clusterer. |
|
| Method Summary | ||
|---|---|---|
private static
|
assignPointsToClusters(Collection<Cluster<T>> clusters,
Collection<T> points)
Adds the given points to the closest Cluster. |
|
private static
|
chooseInitialCenters(Collection<T> points,
int k,
Random random)
Use K-means++ to choose the initial centers. |
|
List<Cluster<T>> |
cluster(Collection<T> points,
int k,
int maxIterations)
Runs the K-means++ clustering algorithm. |
|
private static
|
getNearestCluster(Collection<Cluster<T>> clusters,
T point)
Returns the nearest Cluster to the given point |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final Random random
| Constructor Detail |
|---|
public KMeansPlusPlusClusterer(Random random)
random - random generator to use for choosing initial centers| Method Detail |
|---|
public List<Cluster<T>> cluster(Collection<T> points,
int k,
int maxIterations)
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
private static <T extends Clusterable<T>> void assignPointsToClusters(Collection<Cluster<T>> clusters,
Collection<T> points)
Cluster.
T - type of the points to clusterclusters - the Clusters to add the points topoints - the points to add to the given Clusters
private static <T extends Clusterable<T>> List<Cluster<T>> chooseInitialCenters(Collection<T> points,
int k,
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 use
private static <T extends Clusterable<T>> Cluster<T> getNearestCluster(Collection<Cluster<T>> clusters,
T point)
Cluster to the given point
T - type of the points to clusterclusters - the Clusters to searchpoint - the point to find the nearest Cluster for
Cluster to the given point
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||