Density-based clustering
What is density-based clustering?
Density-based clustering is an unsupervised method that groups data points into clusters based on regions of high point density, separated by sparser regions treated as noise or outliers. Unlike centroid-based methods, it can find clusters of irregular shape.
Why density-based clustering matters
Because it doesn't assume clusters are round or evenly sized, density-based clustering finds groupings that centroid-based methods like k-means miss, and it naturally separates outliers instead of forcing every point into a cluster. Data scientists use it to flag malfunctioning servers, group genes with similar expression patterns, and surface anomalies in biomedical images, cases where the "shape" of a normal cluster isn't known in advance.
How DBSCAN works
DBSCAN works by picking a neighborhood radius (epsilon) and a minimum point count (MinPts). Points with at least MinPts neighbors within epsilon become core points; points near a core point but without enough neighbors of their own become border points; everything else is labeled noise. Clusters grow by expanding outward from core points until no more neighbors qualify. For example, in a scatter plot of customer purchase frequency, a dense cluster of frequent buyers would form its own group, while a handful of one-time purchasers scattered across the plot would be labeled noise rather than forced into that cluster or a cluster of their own.
Types of density-based clustering
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) The most widely used density-based algorithm, first introduced by Ester et al. in 1996. It was recognized with the KDD conference's Test of Time Award in 2014 for its lasting influence on the field. See the comparison below for how it stacks up against its variants.
OPTICS Builds on DBSCAN's core idea but handles clusters of varying density better, at the cost of additional computation.
HDBSCAN A hierarchical variant of DBSCAN that removes the need to manually set a single density threshold, useful when cluster density varies across a dataset.
Choosing between DBSCAN, OPTICS, and HDBSCAN
Algorithm
Best for
Tradeoff
DBSCAN
Uniform-density clusters
Struggles when density varies across the dataset
OPTICS
Clusters of varying density
More computation than DBSCAN
Industry use cases
Financial services
Fraud detection systems use density-based clustering to flag transactions that fall outside dense, "normal" spending regions, without needing to define fraud patterns in advance.
Life sciences
Researchers use density-based clustering to identify patient subgroups in clinical trial data whose outcomes cluster together in ways a predefined staging system wouldn't capture, useful when the number of natural subgroups isn't known ahead of time.
Public sector
Public sector agencies use density-based clustering to identify unusual clusters in benefits claims or utility usage data, surfacing patterns that don't fit predefined categories without requiring the number of anomaly types to be known in advance.
FAQ
What's the difference between density-based clustering and k-means?
K-means assigns every point to the nearest of a fixed number of centroids, which works well for round, evenly sized clusters. Density-based clustering instead groups points by local density and can find irregularly shaped clusters, while explicitly labeling sparse points as noise instead of forcing them into a cluster.
What is DBSCAN used for?
Identifying clusters of arbitrary shape in data where the number of clusters isn't known in advance, and where outliers should be excluded rather than assigned. Libraries like scikit-learn implement DBSCAN directly, exposing epsilon and MinPts as tunable parameters.
What are epsilon and MinPts?
The two parameters DBSCAN needs: epsilon sets how close points must be to count as neighbors, and MinPts sets how many neighbors a point needs to become a core point.
Does density-based clustering require you to specify the number of clusters in advance?
No, that's one of its main advantages over k-means. The tradeoff is that DBSCAN and its variants require tuning a density threshold instead, which has its own learning curve.