public class KMeansClusterer
extends java.lang.Object
Constructor and Description |
---|
KMeansClusterer() |
Modifier and Type | Method and Description |
---|---|
boolean |
assignNewClusters()
Assign each data point to the nearest centroid and return whether or not any cluster assignments changed.
|
void |
computeNewCentroids()
Compute new centroids at the mean point of each cluster of points.
|
double[][] |
getCentroids()
Return the array of centroids indexed by cluster number and centroid dimension.
|
int[] |
getClusters()
Return a parallel array of cluster assignments such that data[i] belongs to the cluster clusters[i] with centroid centroids[clusters[i]].
|
double[][] |
getData()
Return the clustering data as a double[][] with each row being a data point and each column being a dimension of the data.
|
int |
getDim()
Return the number of dimensions of the clustering data.
|
int |
getK()
Return the number of clusters k.
|
double |
getWCSS()
Return the minimum Within-Clusters Sum-of-Squares measure for the chosen k number of clusters.
|
void |
kMeansCluster()
Perform k-means clustering with Forgy initialization and return the 0-based cluster assignments for corresponding data points.
|
static void |
main(java.lang.String[] args)
Read UNIX-style command line parameters to as to specify the type of k-Means Clustering algorithm applied to the formatted data on the standard input.
|
double[][] |
readData()
Read the specified data input format from the standard input stream and return a double[][] with each row being a data point and each column being a dimension of the data.
|
void |
setData(double[][] data)
Set the given data as the clustering data as a double[][] with each row being a data point and each column being a dimension of the data.
|
void |
setIter(int iter)
Set the number of iterations to perform k-Means Clustering and choose the minimum WCSS result.
|
void |
setKRange(int kMin,
int kMax)
Set the minimum and maximum allowable number of clusters k.
|
void |
writeClusterData()
Export cluster data in the given data output format.
|
public double[][] readData()
public void setData(double[][] data)
data
- the given clustering datpublic double[][] getData()
public int getDim()
public void setKRange(int kMin, int kMax)
kMin
- minimum number of clusterskMax
- maximum number of clusterspublic int getK()
public void setIter(int iter)
iter
- the number of iterations to perform k-Means Clusteringpublic double[][] getCentroids()
public int[] getClusters()
public double getWCSS()
public boolean assignNewClusters()
public void computeNewCentroids()
public void kMeansCluster()
public void writeClusterData()
public static void main(java.lang.String[] args)
args
- command-line parameters specifying the type of k-Means Clustering