- Introduced by
- Ester, M. et al. (DBSCAN); XAI layer via Lundberg & Lee (SHAP)
- Year
- 1996 (DBSCAN); 2010s (XAI integration)
- Type
- Unsupervised clustering with post-hoc interpretability
- Family
- Machine learning
What does it do?
Explainable DBSCAN runs the DBSCAN density-based clustering algorithm and then applies a post-hoc explanation step, usually SHAP values or local surrogate models, to show which input features are associated with each point's cluster or noise label.
The explanation step does not change the clusters; it describes them after they are formed. The combination is not a single standardised algorithm, so its exact setup should be stated when results are reported.
The intuition behind the method
DBSCAN groups points that have enough neighbours within a radius epsilon and labels points that fall outside every cluster as noise. It does not report which variables drove a particular assignment. The explainable variant leaves the clustering unchanged and adds a second stage that attributes each assignment to input features. SHAP values, which draw on Shapley values from cooperative game theory, split an output among features by their average marginal contribution, while a local surrogate such as LIME fits a simple model around one point. Both approaches describe the cluster labels as a function of the features, so the attributions are only as meaningful as the clustering they explain.
History
DBSCAN was introduced by Ester, Kriegel, Sander, and Xu at KDD-96 in 1996. SHAP, the attribution framework most often used in this setting, was introduced by Lundberg and Lee in 2017 in Advances in Neural Information Processing Systems. The specific combination of the two, usually called Explainable DBSCAN, is best understood as a practice that joins the two methods rather than as a named algorithm with its own originating publication.
When to use it
Choose this approach when you need density-based clustering on continuous tabular data or spatial coordinates, and must also explain individual cluster or noise labels to a reviewer, regulator, or domain expert. It is most useful when the noise points are the main outcome, as in outlier review, and when cluster shapes are irregular enough that centroid-based methods would fit poorly. For mixed numeric and categorical variables, a distance measure suited to those variable types must be chosen and stated before epsilon can be set, because Euclidean distance is not meaningful for categorical codes. Do not use it to obtain an interpretable predictive model: standard DBSCAN has no built-in rule for assigning new observations, and an explanation layer does not improve a clustering produced with a poor epsilon or minPts. If the dataset is small, the density estimates that DBSCAN relies on, and the attributions computed from them, are unstable, and a simpler descriptive analysis may be more defensible.
Limitations and considerations
- The explanations describe the clustering that was produced. If epsilon or minPts is poorly chosen, the attributions faithfully describe a poor partition rather than real structure.
- Exact SHAP calculation becomes expensive as the number of features and observations grows, and approximations such as KernelSHAP can be slow. TreeSHAP applies only if a tree-based surrogate is trained on the cluster labels; it does not apply to DBSCAN itself.
- DBSCAN uses a single epsilon for the whole dataset, so clusters of very different densities are split or merged inconsistently, and the explanation stage cannot correct this.
- Surrogate explanations approximate the cluster boundary only near the points they were fitted to and may mislead about observations close to the boundary.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Inherits DBSCAN's ability to find clusters of arbitrary shape and to label points that belong to no cluster as noise, without a preset number of clusters.
- SHAP attributions come from Shapley values, so for each observation the contributions of the features add up to the difference between the explained model's output for that observation and a baseline.
- Each observation receives its own ranked list of contributing features, so a point flagged as noise can be explained individually rather than only through cluster averages.
- Does not assume normal or spherical clusters, so it can be applied to irregular distributions such as spatial data.
- Per-cluster attributions can help domain experts judge whether a cluster is plausible, but they do not validate the partition, so internal validity measures and expert review should be used as well.
Applications
- Outlier and fraud review, where the noise labels are the output and each flagged point needs a stated reason.
- Geospatial grouping of irregularly shaped regions, where cluster boundaries follow the data and experts check the features behind each cluster.
- Sensor or instrument data, where density-based grouping separates dense operating regimes from scattered readings and the attributions show which channels drive each assignment.
- Segment profiling, where per-cluster attributions help check whether clusters differ on the variables analysts expect them to differ on.
How it works
How it works
Epsilon, the neighbourhood radius, is commonly chosen by sorting each point's k-nearest-neighbour distances and looking for the elbow in the curve. minPts, the minimum neighbour count for a core point, has no single validated default for this method; choose it by checking that the clustering stays stable across nearby values. The distance measure must also be stated. Euclidean distance is the usual choice for continuous features, and a different measure changes what epsilon means.
Each point's neighbourhood is the set of points within epsilon, as defined in the formula above. A point is a core point if its neighbourhood contains at least minPts points. A border point lies within epsilon of a core point but is not itself a core point, and every other point is noise.
Formula
N_{\varepsilon}(p) = \{q \in D \mid \text{dist}(p,q) \le \varepsilon\}Core points that are linked through epsilon-neighbourhoods form a cluster, and border points join a neighbouring cluster. A border point reachable from two clusters can be assigned to either one depending on processing order. Points that are neither core nor border points receive the noise label (-1), which gives the final cluster index for every observation.
SHAP explains the output of a model, but standard DBSCAN has no rule for assigning new points and so provides no function that can be explained directly. Attributions are therefore computed for the labels of the observations that were clustered, by fitting a surrogate classifier to those labels and explaining that classifier with SHAP. A tree-based classifier allows TreeSHAP, and a model-agnostic one can use KernelSHAP. The explanation then describes the classifier, which may disagree with DBSCAN near cluster boundaries, so its agreement with the cluster labels should be reported. LIME-type local surrogates instead approximate the boundary around individual points.
Attribution scores are reported for each observation and aggregated within each cluster and for the noise class. Mean absolute SHAP values give a global ranking of features, and per-point plots show why a specific observation was placed in a cluster or flagged as noise.
Common pitfalls
- Choosing epsilon and minPts without inspecting a k-distance plot or testing sensitivity, then treating the explained clusters as validated.
- Reading SHAP attributions as causal effects. They describe how the labelling procedure responds to features, not why the observations are alike in the underlying process.
- Leaving the noise label out of the explanation. Noise points are often the main output in anomaly work and should be explained individually.
- Running DBSCAN on unscaled features with different units, so the distances used by epsilon are dominated by the highest-variance variables.
- Reporting only mean absolute attributions across the whole dataset, which can hide features that matter for one cluster but not for the rest.
Frequently asked questions
Does Explainable DBSCAN change how DBSCAN clusters?
No. The clustering is standard DBSCAN with the same epsilon, minPts, and distance measure. The explanation is a second step applied to the assignments; it describes them and does not change them.
Can SHAP be applied directly to DBSCAN?
SHAP needs a model that maps features to an output. Standard DBSCAN provides no such mapping for new points; it produces labels only for the observations it was run on. Attributions are therefore computed by training a classifier on those cluster labels and explaining that classifier with SHAP. A tree-based classifier allows TreeSHAP, and a model-agnostic one can use KernelSHAP. The attributions then describe the classifier, which may disagree with DBSCAN near cluster boundaries, so report how well the classifier reproduces the cluster labels. Attributions from a classifier with low agreement should not be read as explanations of the DBSCAN labels.
How do I choose epsilon and minPts before computing explanations?
For epsilon, plot the sorted k-nearest-neighbour distances and look for the elbow, where the curve bends most sharply. minPts has no single validated default for this method, so compare a few nearby values and keep a choice only if the clusters and their explanations remain broadly stable. State the distance measure as well, since the epsilon threshold depends on it. Report the epsilon, minPts, and distance values used.
What if SHAP explanations contradict domain knowledge?
Treat the contradiction as a diagnostic. Either the epsilon or minPts choice has produced clusters that do not reflect the data structure, or the data contain a pattern that is not yet known. Check cluster quality with internal validity measures and review the result with domain experts before drawing conclusions.
Is Explainable DBSCAN suitable for high-dimensional data?
Not directly. In high dimensions, distances between points tend to become similar, which weakens the meaning of the epsilon threshold. Reducing dimensions first, for example with PCA or UMAP, is a common step, but the attributions then refer to the reduced components rather than the original features.
Related methods
Sources
Ester, M., Kriegel, H.-P., Sander, J., & Xu, X. (1996). A density-based algorithm for discovering clusters in large spatial databases with noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD-96), 226–231. AAAI Press.
Open publication referenceLundberg, S. M., & Lee, S.-I. (2017). A unified approach to interpreting model predictions. Advances in Neural Information Processing Systems, 30. Curran Associates.
Open publication reference