Implement K-means clustering from scratch (no ML libraries).
You are given a dataset of points:
X
of shape
(n, d)
(n points, each d-dimensional)
k
(number of clusters)
max_iters
and a convergence tolerance
tol
k
centroids (you may choose a standard approach such as random points from
X
).
max_iters
:
Return:
centroids
: array of shape
(k, d)
labels
: array of length
n
with cluster indices
0..k-1