- The paper presents ExDBSCAN, a novel counterfactual explanation framework that generates valid actionable explanations for DBSCAN clustering.
- It introduces a physics-inspired optimization balancing proximity and diversity, ensuring generated counterfactuals strictly adhere to DBSCAN's density-connectivity.
- Experimental results across 30 OpenML datasets demonstrate ExDBSCAN’s superior performance in achieving perfect validity and robust counterfactual recourse.
ExDBSCAN: Counterfactual Explanations for Density-Based Clustering
Introduction
The paper "ExDBSCAN: Explaining DBSCAN with Counterfactual Reasoning -- Additional Material" (2605.30225) addresses the challenge of local explainability in density-based clustering, with a specific focus on DBSCAN. Unlike supervised learners, DBSCAN assigns points to clusters or labels them as noise based on density-connectivity, posing unique obstacles for existing counterfactual explanation (CE) frameworks, which generally rely on gradients, probabilities, or global prototypes. The absence of differentiable decision boundaries and continuous probabilities in DBSCAN precludes the direct use of most supervised CE methods for actionable interpretability.
Density-Connected Counterfactual Generation in DBSCAN
The core contribution is ExDBSCAN, a model-agnostic post-hoc explanation framework built to be inherently density-aware and valid by design with respect to DBSCAN cluster assignments. For a point of interest, ExDBSCAN generates a set of valid counterfactuals (CFs), each effecting a transition to a user-specified target cluster, either from another cluster or from the noise partition. These CFs strictly follow the DBSCAN density-connectivity structure, offering direct operational insight into the minimal changes necessary for membership transition.
ExDBSCAN’s cost function incorporates two competing terms: proximity (minimizing the change required, emphasizing plausibility and minimal intervention) and diversity (maximizing coverage and uniqueness among the returned CFs). Proximity is defined in terms of Euclidean distance (or the metric DBSCAN was fit on); diversity, in contrast, is computed via the weighted shortest-path—a measure reflective of density-reachability in the cluster core graph, capturing the topological and nonconvex geometry of density-based clusters.
Figure 1: Manipulating the energy-based tradeoff between counterfactual proximity and diversity in cluster space.
A notable theoretical result is the validity guarantee: every generated CF lies within the ε-neighborhood of a core point in the target cluster, assuring its assignment is aligned with DBSCAN's connectivity and partitioning definition.
ExDBSCAN formalizes multi-counterfactual selection as a discrete energy minimization problem over the cluster’s core-point graph. The selected CFs are associated with reference core points, and the selection balances an attraction force (proximity to the explained sample, modelled as springs) and a repulsion force (pairwise diversity among selected reference cores, modelled as electrostatics). This approach leads to an NP-hard combinatorial optimization, approximated via a greedy iterative process that is nearly optimal as per the presented empirical results.
The energy functional for selecting k CFs associated with core points C′ is:
EC′​=i<j∑​D(Vi​,Vj​)1​+i∑​d2(p,Vi​)
where D(Vi​,Vj​) is the graph-based shortest-path (density-connected) distance, and d(p,Vi​) is the Euclidean (or other DBSCAN-selected metric) distance from the explained instance to each reference core.
The evaluation spans 30 OpenML tabular datasets with DBSCAN hyperparameters optimized per dataset. Baselines include model-agnostic Bayesian and genetic CE generators (BayCon), Direct/Surrogate-based DiCE and Growing Spheres, as well as a core-random selection method isolating the optimization’s effect. When surrogate models are involved, DBSCAN labels are taken as pseudo-classes due to the absence of inherent cluster probabilities.
Key metrics used are validity, proximity, and diversity:
ExDBSCAN achieves 100% validity across all datasets and queries, while all surrogate-based or non-density-connected algorithms fail to reach 50% on most benchmarks. In proximity, ExDBSCAN consistently produces CFs closer to the original sample than baseline and random methods, indicating successful optimization of the tradeoff.
Figure 3: ExDBSCAN maximizes diversity while retaining perfect validity; alternative approaches lack cluster-structural awareness.
Diversity analysis shows ExDBSCAN's physics-inspired repulsion yields higher nonredundant coverage of the target cluster than all alternatives, and random selection demonstrates that diversity without structural optimization deteriorates proximity.
Robustness to Actionability and Constraints
ExDBSCAN readily accommodates non-actionable feature constraints by restricting movement across non-actionable subspaces or by core selection filtering. Empirical results with random subsets of non-actionable features reproduce the core findings: ExDBSCAN maintains perfect validity, proximity optimality, and substantially higher diversity, outperforming all baselines.
Figure 4: Proximity/validity with non-actionable features—ExDBSCAN maintains perfect validity and low proximity.
Figure 5: Diversity is maximized by ExDBSCAN despite restricted actionable feature space.
The construction strategy for CFs in constrained subspaces assures continued validity, demonstrating practical utility in real-world decision and recourse applications, e.g., clinical or economic domains with immutable covariates.
Runtime and Complexity
While the energy minimization is NP-hard, empirical runtime is tractable for typical k values (3–10), with ExDBSCAN showing competitive runtimes relative to alternatives except purely random core sampling methods. Greedy selection achieves near-optimal solutions, as supported by local search and mixed-integer programming verifications presented in the supplementary material.
Figure 6: Runtime scales sub-quadratically with feature dimensionality and remains practical for high-dimensional settings.
Figure 7: Cumulative runtime distribution demonstrates ExDBSCAN’s efficiency.
Implications and Theoretical Advances
ExDBSCAN enables, for the first time, guaranteed valid actionable counterfactuals for DBSCAN and, by extension, for density-based algorithms lacking probabilities, distances to prototypes, or gradient structure. By adopting density-connected graph distances for diversity and cluster membership, it advances a framework equipped to handle the non-Euclidean, nonconvex geometry of density-based partitioning.
Figure 8: Density-connected distances reveal crucial counterfactual diversity overlooked by Euclidean metrics in complex clusters.
Ablation studies confirm the complementarity of proximity and diversity, as well as the necessity of structure-aware (graph-based) distances in capturing true alternative explanations.
Figure 9: Ablation shows ExDBSCAN and the nearest-core strategy yield optimal proximity.
Figure 10: Ablation further confirms best-in-class diversity for ExDBSCAN, particularly in aggregate queries.
Conclusion
ExDBSCAN introduces a theoretically-backed, structure-aware counterfactual explanation method for density-based clustering, with broad implications for the explainability of unsupervised learning. It achieves perfect validity, proximity, and diversity simultaneously, without relying on surrogate objectives or information not accessible in density-based models. The method is robust to domain constraints on actionability, scalable, and interpretable, and forms a model-agnostic template for future developments in explainable clustering. As unsupervised applications permeate high-stakes domains (anomaly detection, fraud, bioinformatics), ExDBSCAN provides vital operational recourse by bridging discrete, geometry-based reasoning with actionable explanations.
Future investigations may extend ExDBSCAN’s optimization with metaheuristic techniques, adapt it for online or streaming clustering, or generalize to other clustering paradigms with latent geometric assignment rules. The work delineates foundational principles for trustworthy, actionable unsupervised machine learning.