---
title: HDBSCAN Hierarchical Clustering
url: https://www.emergentmind.com/topics/hierarchical-clustering-via-hdbscan
type: topic
---

# HDBSCAN Hierarchical Clustering

Hierarchical Clustering via HDBSCAN

Hierarchical Density-Based Spatial Clustering of Applications with Noise (HDBSCAN) is a density-based clustering algorithm that generalizes DBSCAN by producing a hierarchy of clusters from data with heterogeneous densities. Unlike traditional single-linkage hierarchical clustering, HDBSCAN leverages mutual reachability distance to mitigate chaining effects and utilizes a stability measure to extract robust, flat cluster assignments from a condensed cluster tree. Recent developments include hybrid selection mechanisms bridging HDBSCAN and DBSCAN*, kernelization for varying densities, efficient multi-hierarchy computations, incremental and scalable variants for dynamic or large-scale data, and specialized adaptations for structure discovery in biological, astronomical, and graph data.

## 1. Foundational Workflow and Mathematical Formulation

The HDBSCAN pipeline consists of transforming a metric space $(X, d)$ into a density-aware topology, followed by extracting a hierarchical cluster tree and summarizing it into a flat clustering via stability selection:

1. **Core Distance**: For each data point $x \in X$ and a user-supplied parameter $\text{minPts}$, compute the core-distance:
   \[
   d_{\mathrm{core}}(x) = \text{distance from } x \text{ to its } \text{minPts}^{\text{th}} \text{ nearest neighbor}.
   \]
2. **Mutual Reachability Distance**: For points $x_p, x_q$, define:
   \[
   d_{\mathrm{mreach}}(x_p, x_q) = \max\left\{ d_{\mathrm{core}}(x_p),\ d_{\mathrm{core}}(x_q),\ d(x_p, x_q) \right\}.
   \]
   This metric regularizes single-linkage fashion, suppressing chaining through low-density bridges.
3. **Minimum Spanning Tree (MST) and Dendrogram**: Construct a complete weighted graph with edge weights $d_{\mathrm{mreach}}(x_p, x_q)$, compute its MST, and perform a single-linkage hierarchy by progressively removing edges in order of decreasing weight.
4. **Condensed Cluster Tree**: The hierarchical tree is pruned by $\text{minPts}$ to form candidate clusters. At each split:
   - Both children $\geq \text{minPts}$: keep the split.
   - Both children $< \text{minPts}$: prune both.
   - One child $< \text{minPts}$: mark as noise; let larger child continue.
   This yields a smaller tree of candidate clusters at various density levels [1911.02282][2509.09839].
5. **Cluster Stability and Selection**: For cluster $C_i$,
   \[
   S(C_i)=\sum_{x_j\in C_i}\Bigl( \lambda_{\max}(x_j, C_i) - \lambda_{\min}(C_i)\Bigr),
   \]
   where $\lambda = 1/\epsilon$, $\lambda_{\min}(C_i)$ is the density at split-off, and $\lambda_{\max}(x_j, C_i)$ is the density at which $x_j$ leaves $C_i$.

Flat clusters are determined by maximizing the sum of stabilities over disjoint cluster choices, using linear-time tree traversal (the "excess-of-mass", or eom, criterion) [1911.02282][2509.09839][2311.15887][2509.02334].

## 2. Hierarchical, Flat, and Hybrid Cluster Selection Mechanisms

Hierarchical clustering in HDBSCAN enables both the exploration of density-based substructure and robust flat cluster assignment:

- **Stability-based Extraction (EOM)**: The eom flat clustering is selected as the set of disjoint clusters maximizing total stability, ensuring that each root-to-leaf path has exactly one cluster selected [1911.02282][1705.07321].
- **Cluster Leaf Extraction**: Alternatively, selecting all leaf segments yields finer partitions, often resulting in more micro-clusters.
- **Hybrid Threshold Mechanism (HDBSCAN$\;{}^{\hat\epsilon}$)**: To control over-partitioning in extremely dense regions (where a low $\text{minPts}$ produces numerous micro-clusters), a threshold $\hat\epsilon$ is specified. Splits in the hierarchy at $\epsilon \leq \hat\epsilon$ are forbidden, collapsing subtrees into DBSCAN$^*$ clusters at that level, whereas elsewhere, HDBSCAN stability selection prevails. The optimization replaces $S(C_i)$ with
   \[
   ES(C_i) =
   \begin{cases}
     \lambda_{\min}(C_i), & \text{if } \epsilon_{\max}(C_i) > \hat\epsilon; \\
     0, & \text{otherwise}.
   \end{cases}
   \]
   This hybrid selection prevents micro-clustering in high-density areas while retaining sensitivity to sparse regions [1911.02282].

## 3. Adaptations and Extensions: Kernelization, Incremental, Multi-scale, and Dynamic Data

Recent innovations extend HDBSCAN to diverse data modalities and address key limitations:

- **Kernelization via Isolation Kernel**: To combat failure modes in variable density scenarios, the base metric $d$ can be replaced by a data-adaptive similarity $\mathcal{K}_I$, defined as the probability that $x$ and $y$ fall in the same cell of a random Voronoi partition. The kernel-induced distance $d_I(x, y)=1/\mathcal{K}_I(x, y)$ and associated core/mutual-reachability distances adapt to local densities, yielding superior dendrogram purity and flat F$_1$ scores compared to Euclidean or Gaussian kernels [2010.05473]. The full pipeline supports these substitutions in MST and stability measures.
- **Efficient Multi-Hierarchy Computation**: For parameter exploration, running HDBSCAN across a range of $\text{minPts}$ is resource intensive. By building a single relative neighborhood graph (RNG) with respect to the largest $\text{minPts}$, followed by reweighting for all smaller values, one can extract all hierarchies for $M$ settings at roughly $2\times$ the cost of a single run, using subquadratic algorithms and well-separated pair decompositions [1709.04545].
- **Incremental and Scalable Variants**: FISHDBC leverages an HNSW structure to incrementally maintain an approximate MST, enabling efficient updates and clustering of dynamic or non-metric datasets with complexity $O(n\log^2 n)$, not requiring $O(n^2)$ distance computations [1910.07283]. Bubble-tree summarization provides $O(\log L)$ update cost per point for dynamic clustering, compressing to $L$ bubbles for efficient batch HDBSCAN passes [2412.07789].
- **Persistent Multiscale Clustering**: PLSCAN constructs the hierarchical clustering tree for all minimum cluster sizes $m \in [2, n]$, employing zero-dimensional persistent homology. Clusters correspond to persistent leaves in the size-filtration, identified via the persistence trace $\sum_{\text{leaf at }m} p_{\text{size}}(\ell)$, overcoming the need for manual $m$ selection and producing multi-scale robustness [2512.16558].

## 4. Parameter Optimization, Validation Metrics, and Empirical Performance

The selection of $\text{minPts}$, $\text{minClusterSize}$, and kernel/threshold parameters is crucial for cluster recovery:

- **Parameter Tuning**: Bayesian optimization frameworks such as Optuna can tune hyperparameters (e.g., $\text{minSamples}$, $\text{minClusterSize}$, and hybrid $\epsilon$ thresholds) against external (e.g., V-measure) and internal (e.g., DBCV) criteria for labeled or unlabeled data [2509.09839].
- **Validation Metrics**: Adjusted Rand Index (ARI), V-measure, DBCV, dendrogram purity, and flat clustering F$_1$-score provide quantitative evaluations. Stability/persistence measures directly guide cluster selection [2512.16558][2010.05473][1911.02282].
- **Empirical Performance**: Hybrid HDBSCAN$^{\hat\epsilon}$ outperforms standard methods for data with variable densities, reducing sensitivity to $\hat\epsilon$ compared to DBSCAN's $\epsilon$. PLSCAN achieves higher ARI than HDBSCAN* EOM and less sensitivity to mutual reachability neighbor parameters. Kernelized HDBSCAN yields highest purity and F$_1$ on diverse datasets. FISHDBC and bubble-tree methods allow clustering at scale with incremental or dynamic data workloads.

## 5. Computational Complexity and Practical Implementation

The efficiency of HDBSCAN and its variants depends on data size, dimensionality, and index structure:

- **Static HDBSCAN**: Accelerated variants use space-tree indexes (kd-tree, ball-tree) for $O(n \log n)$ average-case complexity in core-distance and MST; worst-case is $O(n^2)$ if spatial structure is absent [1705.07321]. Flat clustering extraction is $O(n)$.
- **Incremental Approaches**: FISHDBC achieves $O(n \log^2 n)$ via HNSW neighbor hulls and MST updates over sparse candidate edges [1910.07283]. Bubble-tree online summarization costs $O(\log L)$ per update with offline $O(L \log L)$ for MST-based clustering [2412.07789].
- **Parallel and Multi-hierarchy**: Polylogarithmic depth and aggressive memory optimizations ($10\times$ savings) enable 11–56$\times$ speedup on large multicore machines via well-separated pair decomposition and memoized filtered Kruskal MST extraction [2104.01126][1709.04545].
- **Parameter Sweeping and Multi-scale Selection**: Efficient multi-hierarchy construction allows hundreds of cluster hierarchies in time nearly linear with data size, enabling thorough parameter exploration [1709.04545][2512.16558].

## 6. Specialized Applications: Biological, Astronomical, and Graph Data

HDBSCAN's hierarchical density-based framework is employed in:

- **Galaxy Merger Reconstruction**: In chemodynamical space, optimized HDBSCAN with tuned $\text{minSamples}$, $\text{minClusterSize}$, and selection $\epsilon$ achieves high purity and recovers merger progenitors up to $z_{\rm acc}\sim3$ [2509.09839].
- **Flare-Sensitive Clustering**: FLASC post-processes HDBSCAN clusters to detect branching structure (flares) within clusters, assigning sub-cluster labels by single-linkage over centrality-weighted intra-cluster graphs. Flare detection enriches subpopulation identification in biomedical and cellular development datasets [2311.15887].
- **Community Detection in Graphs**: HDBSCAN is adapted to similarity matrices from node or line graphs and projects edge clusters back to overlapping node communities, supporting flexible, outlier-aware community detection on synthetic and real-world graphs [2509.02334].

## 7. Limitations, Trade-offs, and Practical Considerations

- **Parameter Sensitivity**: In extremely high dimensions, selecting meaningful $\epsilon$ or kernel parameters can be nontrivial; hybrid variants inherit global-threshold weaknesses only where thresholding is forced [1911.02282][2010.05473].
- **Resolution Limits**: Excessive pruning may mask real substructure; conversely, permissive thresholds can lead to micro-clustering.
- **Computational Constraints**: Full pairwise computations remain expensive in non-metric spaces and high dimensionality; approximation and parallelization techniques mitigate this but may regularize or coarsen output.
- **Empirical Robustness**: Persistent multi-scale clustering, kernelization, and dynamic summarization improve stability across datasets, facilitating exploratory analysis without extensive manual parameter tuning or repeated batch runs.

In summary, hierarchical clustering via HDBSCAN establishes a rigorous density-based cluster hierarchy, enables both global and local-stability driven flat selection, and supports diverse extensions—hybrid mechanisms, kernel adaptations, incremental and multi-scale computation, and application to specialized scientific domains—resulting in robust, scalable, and interpretable clusterings across heterogeneous and dynamic datasets [1911.02282][2512.16558][2010.05473][1705.07321][1709.04545][2412.07789][2509.09839][2311.15887][2509.02334][1910.07283][2104.01126].

Source: https://www.emergentmind.com/topics/hierarchical-clustering-via-hdbscan