Quick Reference · hierarchical density-based clustering

hdbscan cheat sheet

HDBSCAN finds clusters of varying density and leaves the rest as noise — no need to guess the number of clusters or a single distance threshold. It reshapes space by density, builds a cluster hierarchy, then keeps the most stable clusters. Two dials do most of the work: min_cluster_size (how big a group must be) and min_samples (how conservative to be about noise).

data & setup density · min_samples, metric hierarchy · min_cluster_size, selection fit / run labels & prediction pitfall most common

Distilled & cross-checked across: hdbscan.readthedocs.io (docs · API · parameter selection · how it works) · Campello, Moulavi & Sander, 2013 · McInnes, Healy & Astels — JOSS 2017 · Malzer & Baum, 2019 (ε) · scikit-learn

How a clustering is built — & the two dials that steer it
Data X n × d features or precomputed dists Mutual reachability core distances reshape space by density MST → hierarchy min spanning tree → single-linkage tree Condense & extract prune small splits → pick stable clusters labels_ + probabilities_ noise = −1 ◤ min_samples · metric ◤ min_cluster_size · eom / leaf hdbscan.approximate_predict(clusterer, X_new) — assign new points to the trained clusters outlier_scores_ (GLOSH) INPUT THE DENSITY HIERARCHY OUTPUT
01Install & Importonce per env
0260-Second Startcluster & read
03Core parameterswhat to tune
04min_cluster_size · granularitytune this first
05min_samples · conservativenessthe noise dial
06Cluster selectionreading the tree
07Metrics & inputmeasuring distance
08Reading the resultfitted attributes
09Predict new pointsassign unseen data
10Soft clusteringfuzzy membership
11Visualize the hierarchythe signature plots
12Outliers & validityscore the result
13DBSCAN* & speedextras & scale
Recommended recipesensible starting point
!Watch out forcommon gotchas

How the pieces shape the clustering

Four ideas that decide what HDBSCAN returns — based on the “How HDBSCAN Works” and parameter-selection guides.

the condensed tree

As the density threshold rises, points “fall out” of clusters and bars narrow. HDBSCAN keeps the most persistent branches (Excess of Mass) — circled here.

width = points in cluster · red = selected λ

min_cluster_size: fine ↔ coarse

Small values keep many little clusters; large values merge them and prune the small ones as noise.

small (=5) large (=60) grey = noise (−1)

min_samples: less ↔ more noise

Low values let clusters absorb sparse fringes; high values pull clusters into dense cores and declare the fringes noise.

low (=1) high (=25) fringe → noise

why not k-means / DBSCAN

With clusters of different density, k-means splits by distance alone and DBSCAN's single ε can't fit all. HDBSCAN varies the threshold per region.

dense sparse — same clusterer

Worth memorizing

min_cluster_size = granularitysmallest group that's a cluster — the dial you tune first
min_samples = conservativenesshigher ⇒ more noise & denser cores; defaults to min_cluster_size
noise is label −1HDBSCAN refuses to force outliers into clusters
eom vs leafeom = a few big clusters · leaf = many small homogeneous ones
probabilities_membership strength (persistence), not classifier confidence
no n_clusters neededdensity finds the count for you (unlike k-means)
varying densityhandled natively — plain DBSCAN's single ε can't
reduce first on high-DPCA / UMAP → HDBSCAN beats raw high-dim
prediction_data=Trueenables approximate_predict for new points
the one plotcondensed_tree_.plot(select_clusters=True)