public class KMeans extends Object implements Clusterer, Serializable
| Modifier and Type | Method and Description |
|---|---|
Integer |
classify(double[] features)
Classifies a given sample and updates clusters.
|
protected double[] |
computeDxs()
For each features in
initFeatures, compute D(x), the
distance between x and the nearest center that has already been chosen. |
double[] |
distribution(double[] features)
Predicts the cluster memberships for a given instance.
|
double[][] |
getCentroids()
Returns learned clusters as a
List of feature's means |
protected void |
initCentroids()
Init clusters using the k-means++ algorithm.
|
protected void |
initIfPossible(double[] features) |
protected boolean |
isReady() |
protected Integer |
nearestCentroid(double[] features) |
void |
reset() |
Integer |
update(double[] features)
Updates clusters with a given sample and return classification.
|
public KMeans(Integer nbCluster)
public Integer classify(double[] features)
Clustererpublic Integer update(double[] features)
Clustererpublic double[] distribution(double[] features)
Clustererdistribution in interface Clustererpublic double[][] getCentroids()
ClustererList of feature's meansgetCentroids in interface Clustererprotected Integer nearestCentroid(double[] features)
protected boolean isReady()
protected void initIfPossible(double[] features)
protected void initCentroids()
protected double[] computeDxs()
initFeatures, compute D(x), the
distance between x and the nearest center that has already been chosen.Copyright © 2013. All Rights Reserved.