kmeans(1) k-means clustering


kmeans [-h] [-v] -c int -i string [-e] [-C string] [-P] [-I string] [-l] [-m int] [-o string] [-O double] [-p double] [-r] [-S int] [-s int] -V


This program performs K-Means clustering on the given dataset, storing the learned cluster assignments either as a column of labels in the file containing the input dataset or in a separate file. Empty clusters are not allowed by default; when a cluster becomes empty, the point furthest from the centroid of the cluster with maximum variance is taken to fill that cluster.

Optionally, the Bradley and Fayyad approach ("Refining initial points for k-means clustering", 1998) can be used to select initial points by specifying the --refined_start (-r) option. This approach works by taking random samples of the dataset; to specify the number of samples, the --samples parameter is used, and to specify the percentage of the dataset to be used in each sample, the --percentage parameter is used (it should be a value between 0.0 and 1.0).


--clusters (-c) [int]
Number of clusters to find.
--inputFile (-i) [string]
Input dataset to perform clustering on.


--allow_empty_clusters (-e)
Allow empty clusters to be created.
--centroid_file (-C) [string]
If specified, the centroids of each cluster will be written to the given file. Default value ''.
--help (-h)
Default help info.
--in_place (-P)
If specified, a column of the learned cluster assignments will be added to the input dataset file. In this case, --outputFile is not necessary.
--info [string]
Get help on a specific module or option. Default value ''.
--initial_centroids (-I) [string]
Start with the specified initial centroids. Default value ''.
--labels_only (-l)
Only output labels into output file.
--max_iterations (-m) [int]
Maximum number of iterations before K-Means terminates. Default value 1000.
--output_file (-o) [string]
File to write output labels or labeled data to. Default value 'output.csv'.
--overclustering (-O) [double]
Finds (overclustering * clusters) clusters, then merges them together until only the desired number of clusters are left. Default value 1.
--percentage (-p) [double]
Percentage of dataset to use for each refined start sampling (use when --refined_start is specified). Default value 0.02.
--refined_start (-r)
Use the refined initial point strategy by Bradley and Fayyad to choose initial points.
--samplings (-S) [int]
Number of samplings to perform for refined start
(use when --refined_start is specified).
Default value 100.
--seed (-s) [int]
Random seed. If 0, 'std::time(NULL)' is used. Default value 0.
--verbose (-v)
Display informational messages and the full list of parameters and timers at the end of execution.
--version (-V)
Display the version of mlpack.


For further information, including relevant papers, citations, and theory, consult the documentation found at or included with your distribution of MLPACK.