Machine learning models · Phase 3 · Lesson 22

DBSCAN and density-based clustering

Use density to find irregular clusters and mark isolated points as noise.

This is one focused step in the 60-lesson course. Use the retrieval check before moving on.

Lesson goal

Use density to find irregular clusters and mark isolated points as noise.

The core idea

A cluster is a dense neighbourhood connected to other dense neighbourhoods. Points in sparse regions need not be forced into a group.

Mental model

Picture it this way. A cluster is a dense neighbourhood connected to other dense neighbourhoods. Points in sparse regions need not be forced into a group. The important question is what assumption this picture makes, and whether that assumption fits the data.

Mathematical core

DBSCAN uses eps, a neighbourhood radius, and min_samples, the minimum count for a core point. Density connectivity expands clusters from core points.

Worked example

Map delivery locations. Dense suburbs form irregular clusters while isolated rural addresses are labelled noise instead of being assigned to a nearby city cluster.

When to use it

It earns a place when

  • Use it when clusters have arbitrary shapes and noise is meaningful.
  • You can evaluate it against a credible baseline.
  • Its output fits the decision and data constraints.

Do not make it the default when

  • Do not expect one eps value to handle groups with very different densities or high-dimensional distances.
  • A simpler model has not been tested.
  • The data or target definition is still unclear.

Failure modes

Watch for this. Parameter selection is sensitive to scale and dimension. Border points can be assigned in ways that depend on traversal details.

When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.

Practice

Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.

Do this. Scale a two-dimensional dataset, plot a k-distance curve, vary eps and report how many points are noise.

Retrieval check

Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.

1. What can DBSCAN label explicitly?

2. What does eps control?

3. Why is scaling important for DBSCAN?

Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.

Primary source

scikit-learn User Guide. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.