How does K-means optimize its objective?
Reveal the answer and explore the explanation.
01EasyCoreVisualHow does K-means optimize its objective?
Answer
EasyCoreVisual
How does K-means optimize its objective?
Answer
Partitions observations into k groups to minimize within-cluster squared distances.
Practical example
Assign points to centroids and update centroids iteratively.
PythonRelated concept example
from sklearn.cluster import KMeans
X = [[0,0], [0,1], [8,8], [9,8]]
m = KMeans(n_clusters=2, n_init=10, random_state=42).fit(X)
print(m.cluster_centers_)Cluster labels themselves are arbitrary.
Reference: Further reading ↗