Gradient LabStart the lesson

Lessons › Chapter 7: Unsupervised learning

DBSCAN

Draw a small circle around each point and count the neighbors inside it. A point with enough neighbors is a core point: it sits in a crowded area.

Watch it move. This lesson is interactive on Gradient Lab: every step is an animated scene you can replay.

Start the interactive lesson

Step by step

Story

Where are the crowds?

The team maps cash withdrawals to find busy spots for new cash machines.

Problem

Clusters with odd shapes

These points form two curved bands that hook into each other, plus a few stragglers. k-means, which looks for round blobs, would slice them badly.

Key idea

Count neighbors in a circle

Draw a small circle around each point and count the neighbors inside it. A point with enough neighbors is a core point: it sits in a crowded area.

Build

Crowded areas become clusters

Core points that can reach each other link up into one cluster, however curvy its shape. Both bands are found correctly.

Insight

Stragglers are noise

Points no cluster can reach are marked as noise and left out, instead of being forced into a group. You also never had to say how many clusters to find.

Real life

In real life: hotspots on a city map

Taxi and delivery companies plot pickups on a map. DBSCAN finds the busy hotspots, like a station or a stadium, whatever their shape, and ignores the scattered one-off trips.

Quick check: What does DBSCAN do with an isolated point far from any crowd?

Points that no core point can reach are treated as noise.

Pseudocode

radius = 1.0
min_neighbors = 3
for each point:
    if it has ≥ 3 neighbors within the radius → core point
grow clusters by linking core points that reach each other
points no core point can reach → noise

Key terms

core point
In DBSCAN, a point with enough neighbors close by to be the heart of a cluster.