Introduction
k-means and DBSCAN cover many situations, but there's no single best clustering algorithm — each makes different assumptions about what a "cluster" is. scikit-learn offers several more, and knowing their strengths helps you choose quickly.
| Algorithm | Main idea | Needs k? | Shapes | Scales to large data? |
|---|---|---|---|---|
| k-means | nearest centroid | yes | round | ✅ |
| DBSCAN / HDBSCAN | dense regions | no | any | medium |
| Agglomerative | merge closest groups step by step | yes (or a distance cut) | depends on linkage | ⚠️ medium (with connectivity) |
| Mean-shift | move to density peaks | no | blob-like | ❌ |
| Spectral | cluster a similarity graph | yes | any (complex) | ❌ |
| BIRCH | compact summary tree | yes (optional) | round | ✅ (many rows, few features) |
| Affinity propagation | points vote for "exemplars" | no | various | ❌ |