ExDBSCAN: Counterfactual Explanations for DBSCAN
- ExDBSCAN is a counterfactual explanation method for DBSCAN that clarifies why points are labeled as noise or assigned to specific clusters based on density connectivity.
- It constructs explanations using a fixed assignment rule and a greedy approximation to select diverse and proximal candidate core points from a density-connected graph.
- Empirical evaluations show ExDBSCAN achieves 100% validity and an optimal trade-off between proximity and diversity compared to alternative explanation methods.
ExDBSCAN is a post-hoc explanation method for DBSCAN that generates counterfactual explanations for individual clustering assignments. It is designed to answer questions such as why a point is labeled as noise, what minimal changes would move it into a specific cluster, or what would need to change for a point assigned to one cluster to belong to another. The method is tailored to density-based clustering, where membership is governed by density reachability and density connectivity rather than centroid proximity or class probabilities (Matthews et al., 28 May 2026). In current arXiv literature, this explicit use of the name “ExDBSCAN” refers to explainability for DBSCAN rather than to parameter-tuning or scalability variants, although several related DBSCAN-family works pursue those latter aims under different names (Matthews et al., 28 May 2026).
1. Definition and scope
ExDBSCAN operates after DBSCAN has already been run and seeks explanations for the resulting clustering. Its target is the interpretability gap in density-based clustering: DBSCAN assigns points as inliers or outliers but does not indicate why a point receives its assignment or whether its assignment is robust to small changes in the data (Matthews et al., 28 May 2026). The method is presented as the first counterfactual explanation method tailored to DBSCAN, and its central claim is that it provides actionable counterfactual explanations with theoretical guarantees for validity (Matthews et al., 28 May 2026).
The method is explicitly distinguished from supervised counterfactual explanation techniques. DBSCAN has no differentiable objective, no class probabilities, and no native out-of-sample assignment rule. Moreover, cluster membership depends on density connectivity rather than on direct Euclidean closeness alone. ExDBSCAN addresses this by fixing the original clustering and defining a post-hoc assignment rule for new candidate points, rather than re-running DBSCAN after each candidate modification (Matthews et al., 28 May 2026).
This scope differs from other DBSCAN-family developments on arXiv. Some works extend DBSCAN toward automatic parameter generation, multiscale cluster-tree estimation, or scalable metric and streaming settings, but those works are not explicitly named ExDBSCAN (Vijendra et al., 2016, Wang et al., 2017, Mo et al., 2024). ExDBSCAN, in contrast, is an explanation framework built on top of an existing DBSCAN result (Matthews et al., 28 May 2026).
2. DBSCAN foundations and the fixed assignment framework
ExDBSCAN inherits the standard DBSCAN neighborhood and core-point definitions. For a point , the -neighborhood is
The set of core points is
A border point is not core but lies in the -neighborhood of a core point, and a noise point is neither core nor border (Matthews et al., 28 May 2026). These are the structural objects ExDBSCAN explains rather than replaces.
Because DBSCAN does not natively assign a new point to an existing clustering, ExDBSCAN defines a fixed cluster assignment function after DBSCAN has been run. Under this rule, a new point is assigned to cluster if there exists a core point such that and 0 (Matthews et al., 28 May 2026). This choice is foundational: ExDBSCAN does not explain a re-clustered dataset, but rather the original clustering under a fixed membership extension.
Within this framework, a counterfactual 1 for a point 2 targeting cluster 3 is valid if 4 and 5 (Matthews et al., 28 May 2026). The paper starts from the generic counterfactual formulation
6
ExDBSCAN instantiates this objective for DBSCAN and returns multiple counterfactuals that are intended to be valid, proximal, and diverse (Matthews et al., 28 May 2026).
3. Density-connected graph representation and objective function
The method represents each target cluster by an undirected weighted graph 7 whose vertices are the core points of the cluster. Two core points are connected if they are directly density-reachable, and edge weights are given by the metric used for DBSCAN, which is Euclidean in the experiments (Matthews et al., 28 May 2026). This graph encodes intracluster geometry in a way that respects DBSCAN’s density-connected structure.
The use of graph shortest-path distance is central. ExDBSCAN distinguishes the distance from the explained point 8 to a candidate target-cluster core point from the distance between candidate counterfactual regions within the cluster. The latter is measured by a density-connected weighted shortest-path distance 9 on the graph rather than by direct Euclidean distance (Matthews et al., 28 May 2026). This matters in non-convex clusters, where Euclidean proximity can misrepresent DBSCAN’s connectivity structure.
Counterfactual selection is performed first over reference core points rather than over arbitrary points in 0. ExDBSCAN defines an energy over a candidate set 1:
2
The first term is a repulsion term: if two selected core points are close in graph distance, the contribution is large, so minimizing it promotes diversity. The second term is an attraction term: it penalizes target-cluster cores far from the explained point, thereby promoting proximity (Matthews et al., 28 May 2026). The paper interprets these two terms using a physics-inspired analogy, with repulsion resembling Coulomb-like electrostatic force and attraction resembling Hooke’s-law spring energy (Matthews et al., 28 May 2026).
The exact optimization problem is
3
This problem is NP-hard, because the repulsion-only case maps to a maximum diversity problem (Matthews et al., 28 May 2026). The paper therefore uses a greedy approximation that initializes 4 and repeatedly adds the unselected target-cluster core point whose inclusion yields the lowest total energy (Matthews et al., 28 May 2026). A useful special case is also stated: if only the attraction term is used, the optimization reduces to selecting the 5 nearest target-cluster core points to 6 (Matthews et al., 28 May 2026).
4. Counterfactual construction and theoretical guarantees
Once a reference core point 7 has been selected, ExDBSCAN converts it into an actual counterfactual point 8 by placing 9 on the line segment from 0 toward 1, exactly inside the 2-neighborhood of 3:
4
where 5 (Matthews et al., 28 May 2026). This construction ensures that the counterfactual is as close as possible to the original point along that direction while still being assigned to the target cluster under the fixed assignment rule.
The method’s main theoretical statement is a validity theorem. Every counterfactual point 6 generated with reference core point 7 such that 8, for a point 9 with 0, is part of cluster 1 (Matthews et al., 28 May 2026). The proof follows directly from construction: 2 lies within 3 of a core point in the target cluster, and the fixed assignment function assigns such points to that cluster. The paper presents this as perfect validity under its fixed-assignment interpretation (Matthews et al., 28 May 2026).
The additional material also analyzes the quality of the greedy approximation against exact MIQP or Gurobi solutions. For 4, the greedy method matches the exact optimum in 87% of cases, has mean objective ratio 1.0014, worst case 1.05, and is within 1% of optimum in 98% of cases. For 5, it is exact in 90% of cases, with mean ratio 1.0005 and worst case 1.02 (Matthews et al., 28 May 2026). A local-search refinement initialized from the greedy solution reaches the exact optimum in 100% of cases for 6 and 99% for 7 (Matthews et al., 28 May 2026). These results suggest that the greedy procedure is very close to optimal in practice, although the paper’s theorem-level guarantee concerns validity rather than approximation ratio.
The computational complexity stated in the additional material separates core-point selection, counterfactual construction, and precomputed distances. Core-point selection is 8, counterfactual construction is 9, and precomputing distances is 0, where 1 denotes the target-cluster core points, 2 the graph edges, 3 the number of features, and 4 the number of counterfactuals (Matthews et al., 28 May 2026).
5. Empirical evaluation
The experimental evaluation uses 30 tabular datasets from OpenML. DBSCAN parameters are selected by grid search maximizing the DBCV clustering validity index. For each cluster and the noise partition, 10 points are sampled, every other cluster is used as a target, and 5 counterfactuals are requested (Matthews et al., 28 May 2026).
The comparison includes BayCon, DiCE, Growing Spheres, and ExDBSCAN Random, the last of which uses the same core-to-counterfactual construction but chooses reference core points uniformly at random (Matthews et al., 28 May 2026). The main evaluation criteria are validity, average proximity, and average diversity. Diversity is measured using a DPP-style kernel
6
and the determinant 7, where larger values indicate more diverse sets (Matthews et al., 28 May 2026).
The headline empirical claim is that ExDBSCAN achieves 100% validity across all queries, and ExDBSCAN Random also achieves 100% validity because it shares the same construction rule for candidate placement (Matthews et al., 28 May 2026). The paper further reports that ExDBSCAN attains the best overall proximity-diversity tradeoff among high-validity methods and achieves the highest diversity among all compared methods (Matthews et al., 28 May 2026). The explanation given is that ExDBSCAN explicitly optimizes diversity using graph shortest-path distance, which aligns with DBSCAN’s density-connected geometry (Matthews et al., 28 May 2026).
The additional material includes ablations. “ExDBSCAN Nearest,” which uses only the attraction term, is best for proximity. “ExDBSCAN Furthest,” which uses only the repulsion term, is best for pure diversity on some queries. Full ExDBSCAN nearly matches the attraction-only variant on proximity while surpassing the repulsion-only variant on diversity over most queries (Matthews et al., 28 May 2026). This is presented as evidence that the attraction and repulsion terms are complementary rather than merely antagonistic.
The same document also reports experiments with non-actionable features, runtime analyses, sparsity and plausibility analyses, and qualitative examples including a half-circle example and a California Housing case study (Matthews et al., 28 May 2026). These examples are used to illustrate that Euclidean distance alone can misjudge diversity inside non-convex DBSCAN clusters and that domain constraints can be incorporated by filtering feasible core points (Matthews et al., 28 May 2026).
6. Relation to the broader DBSCAN-family literature
ExDBSCAN belongs to a broader landscape of DBSCAN-family research, but its role in that landscape is unusual. Most DBSCAN extensions on arXiv address one of four themes: automatic parameter selection, multiscale or hierarchical density estimation, scalability, or dynamic updates. For example, “Density Based Algorithm With Automatic Parameters Generation” proposes automatic generation of multiple 8 pairs to address parameter sensitivity and varying density (Vijendra et al., 2016). “DBSCAN: Optimal Rates For Density Based Clustering” studies a tree-valued DBSCAN estimator and a modified KDE-based DBSCAN for density cluster trees (Wang et al., 2017). “Towards Metric DBSCAN: Exact, Approximate, and Streaming Algorithms” gives exact, approximate, and streaming algorithms for metric DBSCAN under low-intrinsic-dimension assumptions on inliers (Mo et al., 2024).
ExDBSCAN does not modify DBSCAN’s density rule, core-point criterion, reachability relation, or clustering objective. It instead takes a completed DBSCAN result and explains it through counterfactual reasoning (Matthews et al., 28 May 2026). This makes it neither a scalability extension nor a parameter-generalization method in the usual sense. A plausible implication is that ExDBSCAN is best understood as an interpretability layer for DBSCAN rather than as a replacement clustering algorithm.
The method’s main strengths, as stated in the additional material, are its DBSCAN-specific semantics, its validity guarantee, its ability to produce multiple diverse explanations, and its support for both noise-to-cluster and cluster-to-cluster transitions (Matthews et al., 28 May 2026). Its main limitation is equally explicit: validity is defined with respect to a fixed-clustering assignment rule rather than to a full re-execution of DBSCAN on the modified dataset (Matthews et al., 28 May 2026). The optimization problem is NP-hard, though the greedy approximation is empirically near-optimal (Matthews et al., 28 May 2026). The method also depends on the DBSCAN parameters 9 and 0, because the explanations inherit whatever clustering those parameters induce (Matthews et al., 28 May 2026).
In that sense, ExDBSCAN extends the DBSCAN literature in a different direction from most prior work. Earlier research asks how DBSCAN should be tuned, accelerated, generalized to hierarchies, or maintained dynamically (Vijendra et al., 2016, Wang et al., 2017, Mo et al., 2024). ExDBSCAN asks how a DBSCAN decision can be explained once the clustering has already been fixed (Matthews et al., 28 May 2026).