The idea
Picture a crowd at a festival seen from above. Groups of friends stand close together; a few people wander alone. If you can walk from person to person in small steps without crossing empty ground, those people belong to the same group.
Two settings define "close": the radius and the minimum number of neighbours inside it. A point with enough neighbours is a core point. Clusters grow outwards from core points, and anything unreachable is noise.
How it works
- For each point, count the points within radius (including itself).
- Mark points with at least Min neighbours as core points.
- Start a cluster at an unvisited core point and add everything within of it.
- Keep expanding through any core points you reach.
- Points reached but not core are border points; points never reached are noise.
Reading the picture
Each cluster gets its own colour, and noise points are shown in grey. The stats count clusters, core points and noise points.
Turn on Show around core points to see the circle each core point uses. Overlapping circles chain into one cluster; a gap wider than splits clusters apart.
Try this
- On Moons, use the defaults. Both crescents are found perfectly, something k-means cannot do.
- Shrink Radius () to 0.05. Clusters fragment and most points turn grey.
- Grow Radius () to 0.3. The gap between the moons gets bridged and everything merges into one cluster.
- On Circles, turn on Show around core points and tune Radius () until the ring and the centre separate.
The maths
Neighbourhood
Core point
Reachable
Noise
Strengths and weaknesses
Good at
- Finds clusters of any shape.
- No need to choose the number of clusters.
- Flags outliers as noise automatically.
Struggles with
- Struggles when clusters have different densities.
- Sensitive to , which depends on the data's scale.
- Distance becomes less meaningful in high dimensions.