cv.kmeans - MATLAB File Help |
Finds centers of clusters and groups input samples around the clusters
labels = cv.kmeans(data, K)
[labels, centers, compactness] = cv.kmeans(...)
[...] = cv.kmeans(..., 'OptionName', optionValue, ...)
criteria.epsilon
. As soon as each of the cluster centers
moves by less than criteria.epsilon
on some iteration, the algorithm
stops. default
struct('type','Count+EPS', 'maxCount',100, 'epsilon',eps('float'))
Initialization
methods to specify
the exact method. Not set by default.The function cv.kmeans implements a k-means algorithm that finds the centers
of K
clusters and groups the input samples around the clusters. As an
output, labels(i)
contains a 0-based cluster index for the sample stored
in the i-th row of the samples matrix.
The function returns the compactness measure that is computed as:
sum_{i} (|| samples_i - centers_{labels_i} ||^2)
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 InitialLabels
option, and then choose the
best (most-compact) clustering.
[Arthur2007]:
D. Arthur, S. Vassilvitskii: "k-means++: The Advantages of Careful Seeding". In Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, 1027-1035, 2007.