- Introduced by
- Campello, R. J. G. B.; Moulavi, D.; Sander, J.
- Year
- 2013
- Type
- Hierarchical density-based clustering
What does it do?
HDBSCAN (Hierarchical Density-Based Spatial Clustering of Applications with Noise) is a density-based clustering algorithm introduced by Campello, Moulavi, and Sander in 2013.
It extends DBSCAN by building a hierarchy of density-based clusters across all density levels and then extracting a flat partition from that hierarchy by stability. It does not require one global density threshold when cluster densities differ across regions of the data.
The intuition behind the method
Standard DBSCAN requires a single global density threshold (epsilon) and fails when clusters have very different densities. A dense urban cluster and a sparse rural cluster cannot both be captured by one threshold. HDBSCAN solves this by asking: across all possible density thresholds, which groupings persist for the longest range? It builds a hierarchy of clusters from high density down to low density, then selects the groupings that are most persistent (stable) in that hierarchy as the final clusters. Points that never join a stable cluster are labelled as noise. The result is a principled method with few tuning parameters that naturally handles multi-density datasets.
History
Campello, Moulavi, and Sander introduced HDBSCAN at the Pacific-Asia Conference on Knowledge Discovery and Data Mining (PAKDD) in 2013. The 2015 article in ACM Transactions on Knowledge Discovery from Data, co-authored with Arthur Zimek, sets out the hierarchical density estimates, stability-based cluster extraction, and outlier scoring in fuller form. An open-source Python implementation of the method by McInnes, Healy, and Astels is also available.
When to use it
Choose HDBSCAN when the data contain clusters of visibly different density, when the number of clusters is not known in advance, or when points that belong to no group should be identified as noise rather than forced into a cluster. It is also a common choice when DBSCAN's single epsilon cannot be set sensibly across the whole dataset. The main user-set parameter is the minimum cluster size; the neighbourhood size k is a second setting that also affects results. Because it does not assume a particular cluster shape, it suits spatial coordinates and continuous embeddings such as UMAP projections. Avoid it when every point must receive a cluster label, when the raw feature space is very high-dimensional (reduce dimensionality first), or when a fixed, interpretable density threshold is part of the research question.
Limitations and considerations
- Performance can degrade in very high-dimensional spaces where distance concentration diminishes the meaning of nearest-neighbour distances (the curse of dimensionality); dimensionality reduction before clustering is recommended.
- The minimum cluster size parameter influences results significantly; too small a value produces many tiny clusters and too large a value merges distinct groups.
- Every density step depends on nearest-neighbour searches over the whole dataset, so runtime and memory grow with sample size and depend on the search method used. The 2015 paper gives an asymptotic analysis, but on large inputs the method can be slower than k-means.
- Results depend on the neighbourhood size k and the minimum cluster size, which control both the density estimate and the stability comparisons. Changing either can merge or split clusters, so solutions should be compared across settings.
- Results also depend on the distance metric, which defines both the core distances and the mutual reachability graph. Features measured on different scales should be standardised before clustering, or the variable with the largest range will dominate the distances.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Discovers clusters of arbitrary shape and varying density without requiring a global epsilon parameter.
- Points that do not join any selected cluster receive the label -1, so noise identification comes directly from the procedure. The 2015 framework also assigns each object a normalised outlierness score, giving a graded view of outliers.
- Its main parameter is the minimum cluster size, which can be read as the smallest group worth treating as a genuine cluster; a second setting, the neighbourhood size k, also affects results.
- The condensed cluster tree shows how clusters split and persist across density levels, which helps in judging whether a split is meaningful.
- Common implementations return a membership strength between 0 and 1 alongside the hard labels, so borderline points can be flagged for inspection.
Applications
- Clustering UMAP or t-SNE projections of high-dimensional data in genomics, neuroimaging, and NLP.
- Anomaly and outlier detection in fraud detection, network intrusion detection, and sensor data monitoring.
- Geographic and spatial data clustering where cluster density varies by region.
- Topic modelling and document clustering as a post-processing step on text embeddings.
- Single-cell RNA sequencing analysis for identifying cell type clusters of varying abundance.
How it works
How it works
For each data point x, the core distance at neighbourhood size k is the distance to its k-th nearest neighbour. A large core distance means the point sits in a sparse region; a small core distance means it is in a dense region. This quantity smooths over local density fluctuations.
Formula
d_{\text{core}}(x, k) = d(x, x^{(k)})The mutual reachability distance between two points x and y is the maximum of their individual core distances and their direct distance d(x, y) under the chosen distance metric. This transformation spreads sparse-region points apart while preserving the geometry of dense regions, suppressing noise-driven edges in the subsequent graph.
Formula
d_{\text{mreach}}(x, y) = \max\{d_{\text{core}}(x,k),\, d_{\text{core}}(y,k),\, d(x,y)\}A weighted graph is built in which every pair of points is connected by an edge weighted by their mutual reachability distance. The minimum spanning tree (MST) of this graph is then computed. Because the MST retains only the cheapest edges needed to connect all points, it encodes the density structure of the dataset compactly.
The MST edges are sorted by mutual reachability weight and used to build a single-linkage hierarchy. At each weight level, the hierarchy records which groups of points are connected, giving a tree of nested groupings over the mutual reachability space.
The dendrogram is converted to a condensed cluster tree by discarding splits that produce groups smaller than the minimum cluster size parameter. Each retained node in the tree represents a genuine cluster born at a density level lambda (lambda = 1/epsilon), and each point carries the lambda value at which it falls out of its cluster.
Formula
\lambda = \frac{1}{\varepsilon}For every cluster C in the condensed tree, a stability score S(C) is computed as the sum over all member points of how long (in lambda units) each point remained inside C before either falling out or the cluster splitting. Clusters with high stability are coherent and long-lived across the density scale. Because the condensed tree depends on the minimum cluster size, stability values obtained with different settings are not directly comparable. A cluster that persists across a wide range of lambda values scores highly; a split that appears only briefly contributes little, which makes the condensed tree useful for checking whether a split is meaningful.
Formula
S(C) = \sum_{x \in C} \left(\lambda_{\max}(x) - \lambda_{\text{birth}}(C)\right)A bottom-up selection procedure traverses the condensed tree. For each cluster, if its own stability exceeds the sum of its children's stabilities, it is selected as a final cluster; otherwise its children are selected instead. Points not assigned to any selected cluster are labelled as noise (label -1). This yields the final flat partition without requiring a user-specified epsilon. In the output, a label of -1 means the point is unassigned and does not form a cluster. Each assigned point also has a membership probability: values near 1 indicate a point deep inside its selected cluster, and values near 0 mark marginal assignments that deserve a closer look.
Common pitfalls
- Applying HDBSCAN directly to raw high-dimensional data (e.g. bag-of-words, images) without first reducing dimensionality with PCA or UMAP, causing distance measures to become uninformative.
- Interpreting the noise label (-1) as a distinct cluster rather than as unassigned points.
- Ignoring cluster membership probabilities and treating all assignments as equally certain.
- Setting minimum cluster size to 1 or 2, which defeats noise suppression and produces spurious singleton clusters.
- Comparing HDBSCAN solutions across different minimum cluster size settings without re-validating cluster quality using an internal validity index.
Frequently asked questions
What is the main advantage of HDBSCAN over DBSCAN?
DBSCAN requires a single global density threshold (epsilon) that must be the same for every cluster. When clusters differ in density — a common situation in real data — no single epsilon works well simultaneously. HDBSCAN eliminates this requirement by exploring the full density hierarchy and selecting clusters based on their persistence across density scales, automatically adapting to varying local densities.
How do I choose the minimum cluster size?
There is no universal default. Set the minimum cluster size from the smallest group that would be meaningful in your domain, since it controls the smallest grouping treated as a genuine cluster rather than noise. Larger values produce fewer, coarser clusters and more noise points; smaller values produce finer granularity and less noise suppression. Compare a few settings and check whether the main groupings remain stable.
What do the cluster membership probabilities mean?
Each point is assigned a probability between 0 and 1 reflecting how confidently it belongs to its assigned cluster. A probability of 1 means the point was deep inside a stable cluster throughout the hierarchy; a probability near 0 means it was on the fringes and only marginally assigned. Points with low probabilities are borderline cases and may warrant closer inspection.
Is HDBSCAN suitable for very large datasets?
Scalability depends on the implementation and on how nearest neighbours are found. The complexity analysis in Campello et al. (2015) covers running time and memory. For very large datasets, check the documented limits of the implementation you use and test on a representative sample first.
Related methods
Sources
Campello, R. J. G. B., Moulavi, D., & Sander, J. (2013). Density-Based Clustering Based on Hierarchical Density Estimates. In J. Pei et al. (Eds.), Advances in Knowledge Discovery and Data Mining. PAKDD 2013. Lecture Notes in Computer Science, vol. 7819 (pp. 160–172). Springer, Berlin, Heidelberg.
Open DOI referenceCampello, R. J. G. B., Moulavi, D., Zimek, A., & Sander, J. (2015). Hierarchical Density Estimates for Data Clustering, Visualization, and Outlier Detection. ACM Transactions on Knowledge Discovery from Data, 10(1), Article 5.
Open DOI referenceMcInnes, L., Healy, J., & Astels, S. (2017). hdbscan: Hierarchical density based clustering. Journal of Open Source Software, 2(11), 205.
Open DOI reference