Clustering finds groups of similar items in unlabelled data. The algorithms make different assumptions about what "groups" look like; picking the wrong one produces strange results. This page is the working set, with the assumptions and failure modes of each.
The classic. Pick K; iteratively assign points to the nearest centroid; recompute centroids.
init centroids randomly
repeat:
assign each point to nearest centroid
update each centroid to mean of its points
until convergence
Assumes:
Strengths: fast (O(NKI)); simple; understood; widely-implemented.
Weaknesses:
Use K-means when: clusters are roughly spherical and you have a reasonable K.
Don't use when: clusters have variable density, shape, or size; outliers matter; you can't choose K.
Like K-means but cluster centres are actual data points (medoids), not centroids. More robust to outliers.
Slower than K-means. Useful when your distance metric isn't Euclidean (you can use any distance) or when outliers are a problem.
Start with each point as its own cluster; iteratively merge nearest clusters. Produces a dendrogram (tree).
each point is a cluster
repeat:
find the two nearest clusters
merge them
until one cluster
The "nearest" depends on linkage:
Strengths: no need to choose K up front (cut the dendrogram at any level); produces a hierarchy that's interpretable.
Weaknesses: O(N²) memory; O(N³) time naively. Doesn't scale beyond ~10k-100k points.
Use when: you want hierarchy; data isn't huge.
Density-based. A cluster is a region where points have many neighbours within distance eps. Points in low-density regions are noise.
Two parameters: eps (distance threshold) and min_samples (minimum density).
Strengths:
Weaknesses:
eps. Wrong choice produces all-noise or one-huge-cluster.Use when: clusters have similar density; you don't know K; outliers are real.
Hierarchical DBSCAN. Builds a hierarchy then extracts clusters at varying density. Solves DBSCAN's "single eps" problem.
Strengths:
eps.Weaknesses:
Use when: real-world clustering, especially on embeddings. The default for document clustering, customer segmentation, anomaly detection. See DocumentClusteringApproaches.
Assume data is generated from K Gaussian distributions with different means and covariances; learn the parameters.
Strengths:
Weaknesses:
Use when: clusters are roughly elliptical; soft assignment matters; you can choose K with cross-validation or BIC.
Build a similarity graph; compute eigenvectors of its Laplacian; cluster in eigenvector space.
Strengths:
Weaknesses:
Use when: data has clear graph structure; small N; classical methods fail on the geometry.
Like K-means but each point shifts toward the local density mode. Number of clusters emerges from the data.
Strengths: no K; finds modes of any shape. Weaknesses: O(N²); bandwidth parameter is sensitive; rarely the best choice.
Density-based like DBSCAN; produces a reachability plot from which you can extract clusters at varying density.
Less popular than HDBSCAN now; HDBSCAN is the modern preferred choice.
Streaming-friendly clustering. Builds a CF tree summary; clusters from that.
Use when: data is too large to hold in memory.
A decision flow:
For most production work in 2026: K-means for fast simple cases, HDBSCAN for real data complexity. The rest are specialised.
For algorithms requiring K:
For clustering you can manually inspect: try a few K, look at the clusters, pick what looks right. Often the most useful approach.
The choice of distance metric affects cluster shapes:
For high-dimensional data (especially embeddings), cosine is usually the right pick. For low-dimensional numeric features, Euclidean.
Always normalise / standardise features for distance-based methods. Otherwise the dimension with the largest scale dominates.
Internal validation (no labels):
External validation (with ground-truth labels):
For production: have a small labelled set; compute external metrics; trust them more than internal ones.
For a new clustering task:
Most clustering tasks don't need fancy algorithms. They need sensible preprocessing, a reasonable algorithm, and human inspection of the output.