K-Means clustering — run it on your CSV
K-Means places k centroids in the feature space and alternates two steps: assign every row to the nearest centroid, then move each centroid to the mean of its rows. It stops when assignments stop changing. The objective it actually minimizes is inertia, the sum of squared distances to those means, so the clusters it prefers are round and similar in size.
On the Iris measurements, with standard scaling, k set to 3, and seed 42, inertia landed at 139.8 and the silhouette was 0.460. Adjusted Rand against the held-out species column was 0.620: the three species are not three perfect spheres, and versicolor overlaps virginica. The k sweep on that same matrix peaks at k=2 (silhouette 0.582), which is the setosa-versus-the-rest cut, not the three-species cut.
Scale the columns first. A feature in the thousands will own the Euclidean distance and the centroids will ignore everything else. K-Means also has no noise label: every row is forced into a cluster, including outliers.
Settings that change this fit
- k
- How many centroids are fit. Too small and distinct groups are averaged together; too large and inertia keeps falling while the clusters stop meaning anything.
- init
- k-means++ spreads the starting centroids apart. A random start can collapse two centroids onto one dense blob.