Density-Based Clustering in Data Mining
Density-based clustering groups data points by how tightly packed they are, rather than by how close they are to some pre-decided number of central points. That single design choice — defining a cluster as "a dense region" instead of "the points nearest to this center" — is what lets it do two things that k-means and hierarchical clustering both struggle with: find clusters of any shape, and identify outliers as a byproduct rather than as an afterthought.
Why "Distance to a Center" Is the Wrong Idea for Some Data
K-means assigns every point to whichever of k cluster centers is nearest. This works well when clusters are roughly round and similarly sized, but it fails on data shaped like two interleaving crescents, or a dense core surrounded by a sparse ring — shapes where the "correct" cluster is not a compact blob around one center at all. Forcing such data into round clusters produces a result that is confidently wrong: the algorithm still reports two clusters, they are simply not the two shapes that are actually there.
Density-based clustering avoids this by never assuming a shape. Its only claim about a cluster is that it is a region where points are packed closely enough, separated from other such regions by space where points are sparse. A cluster can therefore be round, elongated, crescent-shaped, or anything else — density does not care about geometry, only about how crowded a neighborhood is.
The Two Parameters That Define "Dense"
Density-based clustering needs a precise, computable definition of "packed closely enough," and that definition rests on exactly two parameters.
Eps (ε, epsilon) is a distance: the radius of the neighborhood drawn around each point. Two points are considered neighbors if the distance between them is at most ε.
MinPts is a count: the minimum number of points that must fall inside a point's ε-neighborhood (including the point itself) for that neighborhood to count as dense.
Formally, the ε-neighborhood of a point i is:
N_eps(i) = { k ∈ D | distance(i, k) ≤ ε }
where D is the full dataset. If |N_eps(i)| ≥ MinPts, point i is called a core point — it sits in a genuinely dense area. If a point has fewer than MinPts neighbors within ε, but it falls inside the ε-neighborhood of some core point, it is a border point — on the edge of a dense region rather than inside it. A point that is neither is noise.
Building Clusters From Core Points: A Worked Example
The definitions above only become concrete with actual coordinates and distances, so consider nine points: two tight groups of four, plus one point sitting far from both.
Group 1 (around (1,1)): (1,1), (1.2,1.1), (0.9,1.3), (1.1,0.8)
Group 2 (around (8,8)): (8,8), (8.2,7.9), (7.8,8.1), (8.1,8.3)
Isolated point: (4,4)
With ε = 0.6 and MinPts = 3, computing every pairwise distance shows that each point within Group 1 is within 0.22–0.54 units of the other three — all comfortably under ε = 0.6. Each point in Group 1 therefore has at least 3 neighbors within its ε-neighborhood (itself plus the other three), satisfying MinPts, so all four points in Group 1 are core points. The same is true within Group 2, by the same reasoning, with distances of 0.22–0.45 between its members.
The isolated point (4,4) is a different story. Its distance to the nearest point in either group is roughly 4.0 — nowhere close to ε = 0.6. It has zero neighbors within its ε-neighborhood besides itself, so it satisfies neither the core point condition nor the border point condition (since it lies in no core point's neighborhood either). It is classified as noise.
Running this exact configuration through DBSCAN confirms the reasoning: the four points of Group 1 are assigned to one cluster, the four points of Group 2 to a second cluster, and (4,4) is labeled as noise rather than forced into either group. This is the behavior that distinguishes density-based clustering from k-means most sharply — a k-means run with k=2 on this same data would still assign (4,4) to whichever group's center is nearer, silently absorbing the outlier into a cluster it does not belong to.
How Clusters Actually Grow: Three Reachability Concepts
The example above shows whether a point is core, border, or noise, but not how single core points combine into one connected cluster spanning many points. Three linked definitions answer that.
Directly density-reachable. Point i is directly density-reachable from point k if i lies within k's ε-neighborhood, and k is a core point. Note the asymmetry: this relationship is defined from a core point — a border point cannot pull other points into a cluster the way a core point can, because a border point's own neighborhood is not dense enough to satisfy MinPts.
Density-reachable. Point i is density-reachable from point j if there exists a chain of points j → i₁ → i₂ → ... → i, where each link in the chain is directly density-reachable from the one before it. This is what lets a cluster grow across a large region even when no single point is within ε of every other point in the cluster — density can "hop" from core point to core point as long as each hop stays within ε.
Density-connected. Two points i and j are density-connected if there is some third point o from which both are density-reachable. This handles the case of two points that cannot reach each other directly through a chain in one direction, but are both provably part of the same dense region because a common point connects to both.
A cluster, in the end, is simply the largest possible set of points that are all mutually density-connected. This is why density-based clustering naturally produces clusters of arbitrary shape: the cluster boundary is wherever density-reachability stops holding, which can trace out any contour the actual data forms, not a shape imposed by the algorithm.
The Algorithm's Actual Procedure
- Pick a point that has not yet been visited.
- Count how many points fall within its ε-neighborhood.
- If that count meets MinPts, the point is a core point: start a new cluster and add it.
- Expand the cluster by finding every point density-reachable from that core point, following the chain described above, and add each one found.
- If the count does not meet MinPts and the point is not reachable from any core point, mark it as noise (an assignment that can later change, if a subsequent core point's expansion happens to reach it — noise is only final once every point has been processed).
- Move to the next unvisited point and repeat, until all points have been processed.
What ε and MinPts Actually Control
Choosing these two parameters is the practical heart of using density-based clustering, and the trade-off is direct:
- A larger ε makes neighborhoods bigger, which merges clusters that a smaller ε would have kept separate, and reduces the number of points classified as noise.
- A smaller ε keeps neighborhoods tight, which can fragment one real cluster into several smaller ones and increase the count of points labeled as noise.
- A larger MinPts raises the bar for what counts as dense, making the algorithm more conservative about declaring core points, which tends to produce fewer, larger, more clearly-separated clusters.
- A smaller MinPts makes it easier for a point to qualify as core, which can let noise be misclassified as a small, spurious cluster.
There is no universally correct setting for either parameter — the right values depend entirely on the natural scale of the data, and the standard practical approach is to plot the distance from each point to its k-th nearest neighbor (where k equals the chosen MinPts) in increasing order, then look for the point on that plot where the distance rises sharply — that "elbow" is a reasonable estimate of ε for the dataset in hand.
Named Algorithms in This Family
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) is the algorithm just described, and it is the one that established the core/border/noise framework and the ε/MinPts parameters used throughout this lesson. Its main practical weakness is that a single global ε cannot handle a dataset containing clusters of genuinely different densities — an ε chosen to correctly separate a sparse cluster will absorb a nearby dense one, and vice versa.
OPTICS (Ordering Points To Identify the Clustering Structure) addresses exactly that weakness. Instead of fixing one ε for the whole run, it orders all points by their density relationships and produces a reachability plot, from which clusters at multiple different density levels can be extracted afterward — effectively letting the dataset have several different local values of ε rather than one global one.
DENCLUE (DENsity-based CLUstEring) takes a different mathematical route: instead of counting neighbors within a fixed radius, it models the overall data density as a continuous function — typically a sum of influence functions, one centered at each point — and finds clusters at the local peaks (density attractors) of that function. This lets it detect clusters with more complex, smoothly varying shapes and tends to perform well on high-dimensional data with substantial noise, at the cost of being more computationally demanding to fit than DBSCAN's straightforward neighbor-counting.