Live Coding Vectorized K-Means (Pure Numpy) evaluates an ML engineer's mastery over unsupervised Expectation-Maximization (EM) iterations and vectorized NumPy broadcasting; the algorithm alternates between: 1) E-step (Cluster Assignment): computing the Euclidean distance matrix
D∈RN×K between
N data points and
K centroids using the expanded matrix identity
∣x−c∣2=∣x∣2+∣c∣2−2xcT without Python loops, assigning each sample to its nearest centroid
rik=argminjDij; 2) M-step (Centroid Re-computation): recalculating centroid coordinates as the arithmetic mean of assigned points
μk=∣Ck∣1∑i∈Ckxi; 3) Convergence Check: stopping when centroid shifts fall below tolerance
ϵ.