How does the k-means++ initialization algorithm select initial cluster centers?
Last updated
Pick the first center uniformly at random. Then sample each next center with probability proportional to D(x)², its squared distance to the nearest chosen center, until k are chosen.
D² sampling spreads seeds into uncovered regions without always grabbing the farthest outlier. It gives an expected O(log k) approximation before running Lloyd iterations.
It is the scikit-learn default (
init='k-means++'). It remains somewhat outlier-sensitive, and k-means|| is a parallel variant for large data.