PYTHON
Free Section Starter Challenge
25 min
7. K-Means Clustering & Centroid Recalculation
Overview: Group unlabeled points into K distinct clusters by iteratively updating geometric centroids.
Concept & Syntax Guide
K-Means partitions $n$ data points into $K$ clusters. In each iteration: (1) each point is assigned to its nearest centroid using Euclidean distance, and (2) each centroid is repositioned to the mean of all points assigned to its cluster.
Hands-On Practice Exercise
Compute Updated Cluster Centroids
Calculate the updated centroid coordinates for Cluster 1 points [(2, 2), (3, 4)] and Cluster 2 points [(7, 7), (9, 8)].
Target Output:
Updated Centroids: [(2.5, 3.0), (8.0, 7.5)]
Need a hint? Click here to reveal
Hint: Check syntax carefully and make sure your code contains:
Updated Centroids: [(2.5, 3.0), (8.0, 7.5)]
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10