Procs
proc kmeans[T: SomeFloat](x: Tensor[T]; centroids: Tensor[T]): Tensor[int] {. noinit.}
-
K-Means Clustering Inputs:
- x: A matrix of shape Nb of observations, Nb of features
- centroids: A matrix of shape Nb of centroids, Nb of features
Returns:
- Cluster labels : a matrix of shape Nb of observations, 1
proc kmeans[T: SomeFloat](x: Tensor[T]; n_clusters = 10; tol: float = 0.0001; n_init = 10; max_iters = 300; seed = 1000; random = false): tuple[labels: Tensor[int], centroids: Tensor[T], inertia: T] {.noinit.}
-
K-Means Clustering Inputs:
- x: A matrix of shape Nb of observations, Nb of features
- n_clusters: The number of cluster centroids to compute
- tol: early stopping criterion if centroids move less than this amount on an iteration
- max_iters: maximum total passes over x before stopping
- seed: random seed for reproducability
Returns:
- a tuple of:
- Cluster labels : a matrix of shape Nb of observations, 1
- Centroid coordinates : a matrix of shape n_clusters, Nb of features
- Inertia: the sum of sq distances from each point to its centroid