cr.sparse.cluster.vq.kmeans_with_seed

cr.sparse.cluster.vq.kmeans_with_seed(key, points, k, thresh=1e-05, max_iters=100)[source]

Runs the k-means algorithm for a specific random initialization

Parameters
  • key – a PRNG key used as the random key for choosing initial centroids

  • points (jax.numpy.ndarray) – Each row of the points matrix is a point.

  • k (int) – The number of clusters

  • thresh (float) – Convergence threshold on change in distortion

  • max_iters (int) – Maximum number of iterations for k-means algorithm

Returns

A named tuple consisting of: centroids for each cluster, assignment of each point to a cluster, current distorition, previous distortion, number of iterations for convergence.

Return type

(KMeansState)