Implement k-means clustering from scratch with NumPy
Interview insights are lockedSee how often this is asked and which companies asked it with Buncho Pro.Implement kmeans(X, k, n_iter=100, tol=1e-4, seed=0) using NumPy only. X has shape (n, d).
- Vectorise the assignment step.
- Handle empty clusters.
- Return centroids, labels and inertia.
- Mention improvements for real use.