HDBSCAN · DENSITY-BASED CLUSTERING · NO NEED TO CHOOSE K · NOISE AND OUTLIER SCORES · RUNS IN YOUR BROWSER · NOTHING UPLOADED

Which groups are in my data, and which rows belong to none?

Paste a table: customers and what they buy, measurements of specimens, survey answers on a numeric scale, sensor readings. HDBSCAN (Campello, Moulavi & Sander 2013) finds the groups of rows that sit close together, decides how many there are itself, and leaves rows that are not near any group as noise instead of forcing them into the nearest cluster. You get each row's cluster, how firmly it belongs, an outlier score, and a profile of what sets each cluster apart, including how your text columns (a category, a region) split across the clusters.

Nothing you enter leaves this browser tab. Statistical output from data you supply, not advice. Not legal, tax, or financial advice.

Your data

Rows with a missing value in a chosen column are left out. ID and year columns and codes with three or fewer values are left out unless you tick them.

Columns to cluster on
Paste data to choose columns.

Method and citation

HDBSCAN (Campello, Moulavi & Sander 2013) turns clustering into a question about density. A row's core distance is the distance to its min_samples-th nearest row (counting itself). The mutual reachability distance between two rows is max(core(a), core(b), d(a, b)): rows in sparse regions are pushed apart, rows in dense regions keep their true distance. The minimum spanning tree of that graph, read from its shortest edge to its longest, is a single-linkage hierarchy of every density-based clustering at every level λ = 1 / distance.

That tree is condensed: a split counts only when both sides have at least min_cluster_size rows; otherwise the smaller side's rows simply fall out of the cluster. Each cluster's stability is Σ (λleave − λbirth) over its rows, and excess of mass selection keeps the set of non-overlapping clusters with the largest total stability (a parent is kept only if it is more stable than its children together). Rows outside every selected cluster are noise. Membership is λrow / λmax of its cluster; the GLOSH outlier score (Campello, Moulavi, Zimek & Sander 2015) is 1 − λrow / λmax, where λmax is the densest level reached anywhere below the cluster the row leaves.

Verified by tests in the source against scikit-learn 1.9.1's HDBSCAN on the penguin example and two synthetic tables, at six settings each: with scikit-learn's edge sort made stable, every one of the 5,712 labels and membership values agrees, and the GLOSH scores agree with the hdbscan package's (0.8.44) to 1e-10. One thing does not: spanning-tree edges of equal weight are common (every edge out of a sparse row weighs that row's core distance) and scikit-learn sorts them with an unstable sort, so the unmodified estimator can merge them in another order. That moved up to 96 of 300 labels in “leaf” selection and up to one label in excess of mass on the test data. The same caution applies to any HDBSCAN run: a row whose label depends on tie order sits on a boundary between clusters.

BibTeX

@inproceedings{campello2013density,
  author    = {Campello, Ricardo J. G. B. and Moulavi, Davoud and Sander, Joerg},
  title     = {Density-Based Clustering Based on Hierarchical Density Estimates},
  booktitle = {Advances in Knowledge Discovery and Data Mining (PAKDD 2013)},
  series    = {Lecture Notes in Computer Science}, volume = {7819},
  pages     = {160--172}, year = {2013},
  doi       = {10.1007/978-3-642-37456-2_14}
}
@article{campello2015hierarchical,
  author  = {Campello, Ricardo J. G. B. and Moulavi, Davoud and Zimek, Arthur and Sander, Joerg},
  title   = {Hierarchical Density Estimates for Data Clustering, Visualization, and Outlier Detection},
  journal = {ACM Transactions on Knowledge Discovery from Data},
  volume  = {10}, number = {1}, pages = {5:1--5:51}, year = {2015},
  doi     = {10.1145/2733381}
}
@inproceedings{mcinnes2017accelerated,
  author    = {McInnes, Leland and Healy, John},
  title     = {Accelerated Hierarchical Density Based Clustering},
  booktitle = {2017 IEEE International Conference on Data Mining Workshops (ICDMW)},
  pages     = {33--42}, year = {2017},
  doi       = {10.1109/ICDMW.2017.12}
}

Limits

Questions

What does HDBSCAN do?

It finds groups of rows that sit close together, however many there are and whatever their shape, and leaves rows that are not near any group as noise. It does this by measuring how crowded each row's neighbourhood is, building every possible grouping from the densest level to the sparsest, and keeping the groups that last longest as the density threshold is lowered.

Do I have to choose the number of clusters?

No. Unlike k-means, HDBSCAN decides how many clusters there are. What you choose is the minimum cluster size: the smallest group you would still call a cluster. Groups smaller than that are treated as noise or as part of a bigger cluster.

Why are some rows labelled noise?

Because they are not in a dense region of the data. HDBSCAN does not force every row into a cluster; a row between groups, or far from all of them, is left out. Raising min samples makes the method more conservative, so more rows become noise; lowering it does the opposite.

What are membership and the outlier score?

Membership runs from 0 to 1 and says how deep inside its cluster a row sits: 1 at the cluster's densest part, lower towards its edge, 0 for noise. The GLOSH outlier score also runs from 0 to 1 and asks the opposite question for every row, clustered or not: near 0 means the row is as dense as the densest part of its region, near 1 means it is far out.

Should I scale my columns first?

The page does it for you. Distances mix columns, so a column in grams would swamp one in millimetres. By default each column is turned into z-scores (mean 0, standard deviation 1). Robust scaling uses the median and interquartile range instead, which a few extreme values cannot stretch; choose none only when the columns share a unit and you want their spreads to count.

Excess of mass or leaf: which selection should I use?

Excess of mass, the default, keeps the clusters that persist longest and tends to find a few large ones. Leaf keeps the smallest clusters at the bottom of the tree, giving more, tighter groups and more noise. On the penguin example, excess of mass finds two clusters (Gentoo, and Adelie with Chinstrap together); leaf with a minimum cluster size of 15 and min samples of 5 separates all three species.

Is my data uploaded anywhere?

No. The file is read and clustered by JavaScript in this browser tab. There are no accounts, cookies or analytics vendors.

Example data: Palmer penguins, bill length and depth, flipper length and body mass of 344 adult Adélie, Chinstrap and Gentoo penguins measured near Palmer Station, Antarctica, 2007 to 2009, by Dr Kristen Gorman and the Palmer Station Long Term Ecological Research programme (Gorman, Williams & Fraser 2014, doi:10.1371/journal.pone.0090081), as packaged by Horst, Hill & Gorman (2020) in palmerpenguins, under CC0, retrieved 2026-11-16. Two penguins with no measurements are left out. The species, island and sex columns are not clustered on; they show what each cluster is made of.