M-File Help: kmeans | View code for kmeans |
K-means clustering
[L,C] = kmeans(x, k, options) is a k-means clustering of multi-dimensional data points x (DxN) where N is the number of points, and D is the dimension. The data is organized into k clusters based on Euclidean distance from cluster centres C (DxK). L is a vector (Nx1) whose elements indicates which cluster the corresponding element of x belongs to.
[L,C] = kmeans(x, k, c0) as above but the initial clusters c0 (DxK) is given and column I is the initial estimate of the centre of cluster I.
L = kmeans(x, C) is similar to above but the clustering step is not performed, it is assumed to have been completed previously. C (DxK) contains the cluster centroids and L (Nx1) indicates which cluster the corresponding element of x is closest to.
'random' | initial cluster centres are chosen randomly from the set of data points X |
'spread' | initial cluster centres are chosen randomly from within the hypercube spanned by X. |
"Pattern Recognition Principles", Tou and Gonzalez, Addison-Wesley 1977, pp 94
© 1990-2012 Peter Corke.