Skip to content
mlmentorship

DBSCAN

Density-based clustering: form clusters from regions of high point density, label sparse points as noise. Handles arbitrary cluster shapes; no k to specify.

Published · 6 min read ·Core ·Foundation
Reading depth

Summary

DBSCAN connects dense neighborhoods. Core points continue expansion; border points join without continuing it. No cluster count is supplied, but the distance rule and density threshold still determine the result.

Consider six points on a line: , , , , , . Use ordinary distance, radius and , counting each point itself. Which points form a cluster, and which can extend it?

Three types of points

Define .

  • Core: .
  • Border: non-core, but within the radius of a core point.
  • Noise: neither core nor border.

Draw edges between points within the radius. Only core nodes may pass expansion along those edges.

A border point joins the cluster but cannot expand it

A border point can join without becoming an expansion sourceWith minPts=4 including self, counts are D=5, E=2, and F=1. Only the core neighborhood can expand.Joining a cluster does not grantexpansion authorityD: fiveE: twoF: oneminPts four includes self. Only D isan expansion source.
Derivation
The same radius makes D core and E borderOn a shared one-dimensional distance scale, radius .31 around D=.2 includes A=-.1, B=0, C=.1, D, and E=.5. The same radius around E includes only D and E. MinPts four counts self. F=2 is 1.5 from its nearest point and is noise.radius 0.31; minPts 4; include the point itselfZoom: actual one-dimensionaldistancesD's closed neighborhoodABCDEA + B + C + D + E = 5: COREE's closed neighborhoodABCDED + E = 2: BORDER; cannot extendA=-0.1; B=0; C=0.1; D=0.2; E=0.5F=2: nearest point E is 1.5 awayF counts only itself: 1; NOISE
The shaded spans use the same distance scale and radius. D counts five, including itself. E counts two and cannot extend the cluster. F has no core neighbor.
Check: Why is E included as border but unable to continue the cluster expansion?
Read it this way: With minPts=4 including self, counts are D=5, E=2, and F=1. Only the core neighborhood can expand.
Can border E expand the cluster when its neighborhood count is only two?

Original graph construction follows Ester et al. (1996), also available from the original paper archive, and the scikit-learn DBSCAN documentation.

The algorithm

The inclusive neighborhood sizes are for A through F. A, B, C and D are core. They form one connected core component. D reaches E at distance , but E has only two neighbors and cannot expand. F reaches no core.

The cluster contains A through E. Its diameter is , larger than the radius. The radius limits each expansion step, not the cluster’s overall diameter.

Operationally, visit a point and query its neighborhood. If it is core, start or continue expansion through its neighbors. Expand further only from newly found cores. An early noise label can later become a border label when a core reaches it.

Change the neighborhood rule

1. Require closer neighbors

New task: reduce the radius to while keeping the coordinates and minimum count.

Picture and change: remove edges that fail the new distance test, then recount every neighborhood.

Check: counts become . There are no cores, so all six points are noise.

Use when: the meaningful proximity threshold is tighter, with the same density requirement.

2. Change coordinate units

New task: multiply every coordinate by ten without changing physical proximity.

Picture and change: multiply the radius by ten to . Keep the minimum count at four.

Check: counts and membership stay unchanged. Keeping radius instead would leave only self-neighbors.

Use when: a unit conversion changes numeric distances but not the intended neighborhood.

A border point cannot bridge core components

A non-core point may be close to cores from two disconnected components. It cannot merge them because it cannot continue expansion. Standard traversal may assign this shared border point to either cluster. Core components remain fixed for the chosen metric and parameters.

Try visiting E first

E is first labeled noise. Must that label remain?

Check your answer

No. D later reaches E and includes it as border. Non-core means E cannot expand, not that it can never join.

Choosing and

Inspect sorted neighborhood distances and parameter sensitivity. With four total points including self, the relevant distance is to the third other neighbor. An elbow can suggest a scale; it does not validate the resulting groups. Rules such as are starting heuristics, not guarantees.

Strengths and weaknesses

Core paths can follow nonconvex shapes. Sparse points can receive noise labels, but noise is not a verified anomaly. A single radius can merge dense groups before admitting a sparser group. High-dimensional distance concentration can weaken neighborhood contrast; inspect the metric and representation. Naive neighborhood work is quadratic in point count. Spatial indexes can help, but do not guarantee universally. Materializing every dense neighborhood can also require quadratic memory.

Variants

  • HDBSCAN (Campello et al., 2013) builds a density hierarchy and selects stable groups.
  • OPTICS orders points to expose reachability structure across neighborhood scales.

When to use

SettingDBSCAN vs. alternative
Geospatial clustersDBSCAN (or HDBSCAN)
Outlier detectionTreat noise as a candidate signal requiring validation
Convex, similar-density clustersk-means simpler
High-dimensional dataDBSCAN struggles; use embedding + clustering
Need calibrated posterior probabilitiesA probabilistic model needs explicit assumptions; HDBSCAN membership strength is not automatically calibrated

Common pitfalls

Validate useful groups, stability and noise against the application, not an unrelated clustering objective. Changing representation or coordinate scales changes distances and requires renewed checks.