Partitions data into K clusters, using the K-means algorithm.
mdl = kmeansFit(X, clusters);
mdl = kmeansFit(X, clusters, ctl);
- NxP matrix, the training data.
- Scalar, the number of clusters, or a matrix containing the initial centroids.
- Optional input,
kmeansControlstructure with the following members.
| ||Scalar specifying the algorithm used to create the initial centroids. |
0 kmeans++ (default).
1 parallel k-means++.
2 k randomly selected observations.
| ||Scalar, the number of times to run the K-means algorithm with new starting centroids. Note: this input will be ignored if the |
| ||Seed for the random number generator which creates the initial centroids. Note: this input will be ignored if the 'clusters' input is a starting centroid.|
| ||Scalar, the convergence tolerance for the K-means algorithm.|
| ||Scalar, the maximum number of iterations to allow each of the |
kmeansModelstructure with the following components:
| ||kxP matrix, containing the centroids with the lowest intra-cluster sum of squares.|
| ||Nx1 matrix, containing the centroid assignment for the corresponding observation of the input matrix.|
| ||Scalar, the sum of squared differences between each observation and its assigned centroid.|
| ||Scalar, the number of iterations taken by the |
Parallel Kmeans++ initialization. B. Bahmani, B. Moseley, A. Vattani, R. Kumar, S. Vassilvitskii. Scalable K-means++. Proceedings of the VLDB Endowment, 2012.