Skip to content

Clustering, density estimation, and anomaly detection · Density and exemplar clustering · UCL023 · Algorithm

HDBSCAN

Build a hierarchy of density-connected groups, condense it by minimum cluster size, and select persistent clusters. It is useful when noise and density variation make one DBSCAN radius inadequate.

Runs in CodeSplash Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Runs in CodeSplash
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through discover.hdbscan. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Build a hierarchy of density-connected groups, condense it by minimum cluster size, and select persistent clusters. It is useful when noise and density variation make one DBSCAN radius inadequate.

Question / hypotheses

Which dense groups, modes, or exemplars persist under a defensible similarity scale? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.

Architecture / computational structure

Mutual-reachability graph, spanning-tree hierarchy, condensation, and stability-based selection.

Assumptions

These control size and conservatism differently. Cluster-membership strength is not automatically a calibrated probability of real class membership. Exact neighbor-count conventions differ between implementations, so identical numeric settings may not be equivalent.

Formula / computational definition

Mutual reachability distance is dmr(x,y)=max⁡{ck(x),ck(y),d(x,y)}d_{mr}(x,y)=\max\{c_k(x),c_k(y),d(x,y)\}, where ckc_k is core distance. A minimum-spanning-tree hierarchy is viewed over inverse distance λ=1/d\lambda=1/d; cluster stability accumulates persistence of member points across λ\lambda before selection.

Parameters and notation

Learned or fitted quantities: Density hierarchy, selected clusters, and membership strengths. User-set hyperparameters/design choices: Tune minimum cluster size, minimum samples, distance, and selection method. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.

Fitting, fine-tuning, and adaptation

Neural fine-tuning is not applicable. Refit or rebuild neighborhoods when the reference distribution changes. Recalibrate neighborhood and extraction settings using stable density structure; verify whether the implementation supports genuine new-point assignment before deployment.

How to use and calibrate

Review condensed trees, persistence, noise fraction, and sensitivity. Check recovery of rare meaningful groups rather than maximizing one internal score.

Example application

Identify stable variable-density groups in embedding vectors. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.

Interpretation / pitfalls

Watch out

The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.

Python and R code examples

Scikit-learn provides HDBSCAN; R dbscan::hdbscan provides density hierarchies and labels. For deployment, verify the chosen implementation's new-point assignment capability separately; some clusterers are primarily transductive.

Component: HDBSCAN mutual-reachability matrix. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — HDBSCAN mutual-reachability matrix. · needs numpy

import numpy as np
x=np.array([0.,.2,1.]); core=np.array([.2,.2,.8])
D=np.abs(x[:,None]-x)
result=np.maximum(np.maximum(D,core[:,None]),core[None,:])
print(result)
R

Component demo, not a trained model — HDBSCAN mutual-reachability matrix.

x=c(0,.2,1); core=c(.2,.2,.8); D=abs(outer(x,x,'-'))
result=pmax(D,outer(core,core,pmax))
print(result)

Sources

From the CodeSplash reference, entry UCL023.