Online HDBSCAN

Machine Learning
Introduced by
Campello, R. J. G. B. et al. (base); incremental extensions by Hassani, M. et al.
Year
2015–2017
Type
Incremental hierarchical density-based clustering
Family
Machine learning

What does it do?

Online HDBSCAN is an incremental adaptation of the HDBSCAN hierarchical density-based clustering algorithm for data that arrives over time.

Instead of recomputing the mutual reachability graph, minimum spanning tree and condensed cluster tree for every new observation, the idea is to keep these structures and update the affected parts locally. The aim is to approximate the batch HDBSCAN result on the data seen so far without reprocessing the full dataset. Batch HDBSCAN is described by Campello et al. (2015). The incremental procedure outlined here is a general scheme, not a single validated algorithm with a primary reference, and details vary between implementations.

The intuition behind the method

Standard HDBSCAN needs all the data up front: it builds a mutual reachability graph, extracts its minimum spanning tree, converts this into a condensed hierarchy, and selects stable clusters. When data arrives as a stream, rerunning this pipeline on the growing dataset becomes expensive. Online HDBSCAN keeps the existing graph and tree structures and performs local updates when a new point arrives: it adds the edges involving that point, repairs the affected parts of the tree, and recomputes stability only for clusters that have changed. Points that do not belong to a selected cluster are labelled as noise. The result approximates the batch HDBSCAN solution on the accumulated data, and the approximation is not guaranteed to match that solution exactly.

History

HDBSCAN builds on the hierarchical density estimates of Campello, Moulavi, Zimek and Sander, whose 2015 paper describes the cluster hierarchy, outlier scoring and stability-based flat extraction used by the batch method. That paper does not describe an incremental variant. Hassani and Seidl studied internal evaluation measures for stream clustering, which is related to, but distinct from, an incremental HDBSCAN algorithm. No single primary reference for the incremental procedure is cited here.

When to use it

Choose Online HDBSCAN when data arrives continuously or in batches and rerunning batch HDBSCAN on the growing dataset is too slow or too costly for the application. It suits problems where the number of clusters is unknown, cluster densities differ, and points that fit no cluster should be labelled as noise, which are the conditions that favour HDBSCAN over k-means or DBSCAN. Do not use it when the full dataset fits in memory and periodic batch reruns are acceptable, because the batch method gives the exact hierarchy without approximation. Avoid the basic version under strong concept drift, where accumulated older points distort the current structure; a sliding-window or forgetting variant is needed in that case.

Limitations and considerations

  • Incremental minimum spanning tree and condensed-tree repair is considerably more complex to implement than the single pass of batch HDBSCAN over the full dataset.
  • Core distances of earlier points can become stale as new arrivals change local neighbourhoods, so the incremental result can drift from the batch solution computed on the same data.
  • Without a forgetting or windowing mechanism, historical points accumulate, so memory use and update cost move toward those of full batch reprocessing.
  • How closely the incremental result matches the exact batch solution, and the per-insertion cost, depend on the implementation and should be checked empirically against batch HDBSCAN on a sample of your data.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Keeps HDBSCAN's ability to find clusters of arbitrary shape and varying density and to label noise, in a setting where data arrives over time.
  • In principle, updates only the parts of the minimum spanning tree, condensed tree and stability scores affected by a new point, rather than recomputing the whole hierarchy; the actual saving depends on the implementation.
  • Memory grows with the number of retained points, and this growth can be limited with a sliding window or micro-cluster summaries.
  • Does not require the number of clusters to be specified in advance; the main parameters are the minimum cluster size and the neighbour count k (min_samples).

Applications

  • Monitoring data streams in which the number of groups is unknown and new groups appear over time, with noise labels for points that fit no stable group.
  • Sensor or network-event streams where cluster density varies between sources (illustrative), where HDBSCAN's variable-density behaviour is preferred over a fixed-radius DBSCAN.
  • Online segmentation of event or customer data where the number of segments is not fixed in advance (illustrative).

How it works

How it works

1

The algorithm starts from an initial batch of points large enough to compute a first minimum spanning tree and condensed cluster tree. The neighbour count k used for core distances is set at this stage (in common HDBSCAN implementations it corresponds to the min_samples parameter, which is separate from the minimum cluster size). Quantities needed for later updates, such as core distances, neighbour lists and stability accumulators, are kept in memory so that each insertion can be applied locally rather than by recomputing everything.

2

When a new point x arrives, its core distance d_core(x,k) is the distance to its k-th nearest neighbour among the existing points, with k as fixed at initialisation. Mutual reachability distances between x and its candidate neighbours are then evaluated with the formula above, using the stored core distances of the existing points. Only the edges involving x need to be calculated, although the core distances of nearby existing points may also change because of the insertion.

Formula
d_{\text{mreach}}(x, y) = \max\{d_{\text{core}}(x,k),\, d_{\text{core}}(y,k),\, d(x,y)\}
3

The edges created by x are candidates for insertion into the current minimum spanning tree. The tree is repaired by adding the new edges that improve it and removing edges they supersede, so that the structure remains a valid spanning tree. The exact local update procedure and its cost per insertion depend on the implementation and are not fixed here.

4

Only the parts of the dendrogram and condensed cluster tree that are affected by the minimum spanning tree changes are rebuilt. Birth and death lambda values are updated where splits or merges occur, and memberships are revised within the affected subtree.

5

Stability scores S(C) are recomputed only for clusters whose member sets or lambda boundaries have changed. In the formula, lambda_max(x) is the lambda value at which point x leaves cluster C (by falling out as noise or because C splits), and lambda_birth(C) is the lambda at which C appears; this is the batch HDBSCAN stability definition of Campello et al. (2015). Flat extraction then selects the most stable clusters, as in batch HDBSCAN, and noise labels are updated for points whose assignment has changed. Other cluster assignments remain unchanged.

Formula
S(C) = \sum_{x \in C} \left(\lambda_{\max}(x) - \lambda_{\text{birth}}(C)\right)

Common pitfalls

  • Seeding the algorithm with too few initial points, causing the first MST and cluster tree to be unreliable and propagating errors into subsequent incremental updates.
  • Neglecting to bound memory growth: without a sliding window or micro-cluster summarisation, the retained point set grows without bound in long-running streams.
  • Treating the online solution as equivalent to batch HDBSCAN on the same data — the incremental approximation can deviate, especially after many insertions have altered core distances of existing points.
  • Applying the algorithm directly to high-dimensional raw features without prior dimensionality reduction, which undermines the mutual reachability distance geometry just as in batch HDBSCAN.
  • Ignoring that minimum cluster size tuned on an initial batch may become inappropriate as the stream evolves and the point-count distribution changes.

Frequently asked questions

How does Online HDBSCAN differ from batch HDBSCAN?

Batch HDBSCAN builds the full mutual reachability graph, minimum spanning tree, and condensed cluster tree from all data at once. Online HDBSCAN maintains these structures incrementally, updating only the affected portions when a new point arrives. The result approximates what batch HDBSCAN would produce on the accumulated data, usually at lower computational cost.

How should I handle concept drift in Online HDBSCAN?

Online HDBSCAN in its basic form accumulates all historical points, which can cause stale structure to dominate current clusters when the distribution shifts. To address drift, use a sliding window (discarding old points) or micro-cluster summarisation so that recent data is weighted more heavily than distant history.

What minimum cluster size should I use in a streaming context?

Start from the same domain-based reasoning as for batch HDBSCAN. Track the number of clusters and the noise fraction over time: a steadily rising noise fraction or a growing number of very small clusters suggests the minimum cluster size may need revisiting. Hassani and Seidl (2017) evaluated eleven internal validity measures on synthetic streams for generic k-means-based and density-based algorithms; their study does not address HDBSCAN or its minimum cluster size, and no tuning procedure for this method is established.

Is Online HDBSCAN available in standard libraries?

Check current library documentation before relying on any package. Widely used HDBSCAN libraries are generally built around the batch algorithm, so a custom incremental update layer may be needed.

When should I prefer Online DBSCAN over Online HDBSCAN?

If your clusters have roughly uniform density and you can choose an epsilon radius and min-samples threshold in advance, an online DBSCAN is the simpler option. Online HDBSCAN is more suitable when densities vary across clusters, the number of clusters is unknown, or stability-based noise labelling is needed.

Related methods

Sources

  1. Hassani, M., Seidl, T. (2017). Using internal evaluation measures to validate the quality of diverse stream clustering algorithms. Vietnam Journal of Computer Science, 4(3), 171–183.

    Open DOI reference
  2. Campello, 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 reference