Back to problems

Implement K-means and run two iterations

Algorithm · ByteDance · Hard

Implement a deterministic k-means clustering routine. You are given a list of points points, the number of clusters k, an integer random seed seed, and the number of Lloyd iterations iterations. The routine must use k-means++ initialization and return the initial centers, the cluster assignments and centroids after every iteration, the final centroids, and the final sum of squared Euclidean distances. Use random.Random(seed) so initialization is reproducible. Select the…

Checking your access…