BIRCH clustering — a CF-tree, then a cut
BIRCH does not merge raw rows. It streams them into a clustering-feature tree: each leaf stores a count, a linear sum, and a squared sum, which is enough to know the leaf's centroid and radius. Leaves that sit within the threshold are absorbed. A second step, K-Means on the leaf centroids, cuts the summary into the k you asked for. The tree is the part that would matter on a table too large to cluster directly; on these sample CSVs it is the summary, not the scale, that changes the result.
Threshold 0.5 and k=3 on scaled Iris gave silhouette 0.454 and adjusted Rand 0.661 against species. On wine, the same settings matched Ward agglomerative exactly: silhouette 0.277, adjusted Rand 0.790, and the same k path from 2 to 8. The leaf summary was fine enough that the final K-Means cut reproduced the Ward partition.
If the threshold is large, many distinct rows share a leaf and the final cut can never split them. Lower the threshold before you raise k.
Settings that change this fit
- threshold
- Maximum radius of a leaf. Smaller leaves keep more detail and a larger tree.
- n_clusters
- How the leaf centroids are partitioned after the tree is built. It does not change which rows were absorbed together.