← Questions

Implement k-means clustering

0
AmazonMetaMicrosoftCodingLast asked Sep 2026

Implement k-means from scratch: initialize k centroids, assign every point to its nearest centroid, move each centroid to the mean of its points, and repeat until the assignments stop changing. Discuss initialization, empty clusters and the cost per iteration. The same round also had short interval and frequency-counting problems.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding