Finds centers of clusters and groups input samples around the clusters.
Parameters: 


The function kmeans implements a kmeans algorithm that finds the centers of cluster_count clusters and groups the input samples around the clusters. As an output, contains a 0based cluster index for the sample stored in the row of the samples matrix.
The function returns the compactness measure that is computed as
after every attempt. The best (minimum) value is chosen and the corresponding labels and the compactness value are returned by the function. Basically, you can use only the core of the function, set the number of attempts to 1, initialize labels each time using a custom algorithm, pass them with the ( flags = KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best (mostcompact) clustering.
Splits an element set into equivalency classes.
Parameters: 


The generic function partition implements an algorithm for splitting a set of elements into one or more equivalency classes, as described in http://en.wikipedia.org/wiki/Disjointset_data_structure . The function returns the number of equivalency classes.
[Arthur2007]  Arthur and S. Vassilvitskii. kmeans++: the advantages of careful seeding, Proceedings of the eighteenth annual ACMSIAM symposium on Discrete algorithms, 2007 