Skip to main content

Loading the visual lab…

#dbscanUnsupervised learning

Group by density: epsilon, MinPts, core, border and noise points — the algorithm that finds arbitrary shapes and ignores intruders.

What you'll play with

  1. Welcome to #dbscan. On the plane, 240 gray points: two interlocked crescents and about twenty intruders scattered at random. A 2-center k-means would slice this cloud into halves with a line and give a cluster to each intruder, whatever the cost. DBSCAN reasons differently: it looks at density. A point that has at least MinPts neighbors (itself included) within radius eps is a core; neighboring cores merge into one cluster, whatever its shape; whatever stays isolated is noise. Current settings, in the right panel: eps = 0.25, MinPts = 5.
  2. Run the algorithm: /run. Watch the order of appearance: DBSCAN starts from a point, finds its neighbors within radius eps (the yellow ring), then the neighbors of its neighbors… the cluster spreads outward like an expanding stain.
  3. Shrink the radius: /eps 0.1. With such a small ring, few points still count 5 neighbors.
  4. The opposite now: /eps 0.5. A radius that big links everything within 0.5, including what shouldn't be linked.
  5. Return to the good setting: /eps 0.25. How to pick it without trial and error? The right panel shows the median 4-distance: the typical distance from a point to its fourth neighbor (≈ 0.13 with this dataset). An eps slightly above yields cores everywhere in the moons without crossing the gap between them.
  6. Second knob: /minpts 12. Being a core now requires 12 neighbors within the same radius.
  7. The same dataset seen by k-means: /compare. k-means looks for as many centers as DBSCAN found clusters (2 here) and cuts the plane with the perpendicular bisector of the two centers (dashed line): each moon is sliced in two, and intruders get a cluster like everyone else.
  8. To finish, replay the algorithm in slow motion: /step. Everything turns gray again, then a single point is revealed, with its eps ring and segments to its neighbors.
  9. Your turn: /minpts 5 to return to the loose setting, then /dataset rings (two concentric circles: k-means cannot, DBSCAN can), /dataset noise (only intruders: DBSCAN finds nothing, or almost), /noise 0.3 (30% intruders), /neighbors 0 0 (place the ring on the point nearest the center), /reset to start over. Limitation to know: DBSCAN has a single eps, so clusters of very different densities escape it — this is the problem HDBSCAN solves. Next steps: #anomaly-detection (DBSCAN's noise as an intruder detector) and #hierarchical-clustering.

Channel commands

  • /eps <radius=0.05..1>Epsilon neighborhood radius (reruns DBSCAN if already started).
  • /minpts <2..20>Minimum number of neighbors (itself included) required to be a core point.
  • /runCompute DBSCAN and replay the cluster expansion.
  • /stepReveal the next point in visit order (step-by-step mode).
  • /neighbors <x=-2..2> <y=-2..2>Place the eps ring on the point closest to (x, y) and link its neighbors.
  • /compareToggle coloring to the k-means result (and back).
  • /dataset <moons|blobs|rings|noise>Change the point set (moons, blobs, rings or pure noise).
  • /noise <proportion=0..0.3>Proportion of uniform intruders added to the dataset (0 to 0.3).
  • /seed <1..99>New random draw of the points (deterministic).
  • /resetReturn to moons, 10% noise, eps 0.25, MinPts 5, nothing run.

Glossary

DBSCAN
Density-based clustering algorithm (Ester, Kriegel, Sander, Xu, 1996): two parameters, eps and MinPts, no number of clusters to fix. It finds clusters of arbitrary shape and explicitly labels isolated points as noise.
epsilon (neighborhood radius)
Radius eps of the disk drawn around each point: any point at distance ≤ eps is a neighbor. Too small, everything becomes noise; too large, everything merges.
MinPts
Minimum number of neighbors (the point itself included) a point must have within its eps radius to be a core. Usual value: 2 × dimension, so 4 or 5 in 2D; raising it makes the algorithm more demanding and more robust to noise.
core point
A point that has at least MinPts neighbors within its eps radius: it belongs to the dense interior of a cluster and is allowed to expand it to its neighbors.
border point
A point that doesn't have enough neighbors to be a core, but is within the eps radius of some core: it joins that core's cluster without being able to expand it. This is the cluster's edge.
noise / outlier
A point that is neither a core nor a border: no core reaches it. DBSCAN gives it label −1 instead of forcing it into a cluster, which also makes it a rudimentary anomaly detector.
density
Number of points per unit area. DBSCAN measures it locally, counting neighbors within a disk of radius eps: a cluster is a region where this density exceeds the MinPts threshold, separated from others by sparse areas.
cluster expansion
The central mechanism: starting from a core, we add its neighbors to a queue; each neighbor that is itself a core adds its own, and so on until exhaustion. The cluster is the set of points density-reachable from the seed, hence arbitrary shapes.
k-distance plot
For each point, distance to its k-th neighbor (k = MinPts − 1, often 4), sorted. The curve rises gently for cluster points then takes off for intruders: the elbow indicates a good eps.
varying densities (DBSCAN limitation)
With a single eps, DBSCAN cannot distinguish a compact cluster from a diffuse one: one gets fragmented or the other merged. HDBSCAN lifts this limit by exploring all eps values at once and keeping the most stable clusters.

Other channels in Unsupervised learning

  • #k-meansGrouping without labels: centroids that move, inertia that drops, the choice of k — and the shapes where k-means fails.
  • #pcaPrincipal component analysis: find the axes where data varies most, project, compress — and measure what is lost.
  • #hierarchical-clusteringMerge the points two at a time until only one is left: the dendrogram, the linkage criteria, and the cut height that decides the number of clusters.
  • #dbscanGroup by density: epsilon, MinPts, core, border and noise points — the algorithm that finds arbitrary shapes and ignores intruders.
  • #anomaly-detectionSpot what fits nothing: z-score / Mahalanobis, Isolation Forest, LOF — three ways to say 'this point is odd'.
  • #t-sne-umapMap the high dimensions: t-SNE and UMAP unfold 10-dimensional data into a readable 2D map — perplexity, neighbors, and reading pitfalls.