advancedadvanced-ml

DBSCAN

Finds clusters of any shape by following dense neighborhoods — and knows when a point is just noise.

Key Points

What it is

DBSCAN (Density-Based Spatial Clustering of Applications with Noise) groups points that are closely packed together into clusters and marks points that sit alone in low-density regions as noise/outliers. Unlike K-Means, it doesn't need a predefined number of clusters and can find clusters of any shape.

Why it exists

K-Means assumes clusters are round and roughly equal in size, and forces every point into some cluster even if it's really an outlier. DBSCAN exists to handle real-world data where clusters can be irregularly shaped and where some points genuinely don't belong to any group — like fraud transactions or sensor glitches.

Intuition

Imagine a crowded city map at night viewed from above, lit by streetlights. Dense clusters of light are neighborhoods (clusters); a single lit house out in the countryside, far from any neighborhood, is noise — not its own tiny 'neighborhood' of one. DBSCAN traces out these dense neighborhoods and correctly leaves the lone house unassigned rather than forcing it into the nearest town.

How it works

  1. Pick eps and min_samples

    eps defines the radius of a neighborhood; min_samples defines how many points must be within that radius to count as 'dense.'

  2. Classify each point

    A point with at least min_samples neighbors within eps is a 'core point.' Points near a core point but without enough neighbors themselves are 'border points.' Everything else is 'noise.'

  3. Expand clusters

    Starting from a core point, grow the cluster by including all reachable core and border points connected through dense regions.

  4. Label remaining points as noise

    Any point not reachable from a core point is marked as an outlier, not forced into a cluster.

When to use

When not to use

Common mistakes

In practice

Used for anomaly/fraud detection, geographic/spatial clustering (e.g. grouping GPS coordinates into hotspots), and any scenario where irregular cluster shapes or noise are expected in the data.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

k-means-clusteringhierarchical-clusteringcurse-of-dimensionality
Chirp at me!