ExDBSCAN: Explaining DBSCAN with Counterfactual Reasoning -- Additional Material

Pernille Matthews, Lena Krieger, Tommaso Amico, Artur Zimek, Thomas Seidl, Ira Assent

TL;DR

ExDBSCAN introduces the first post-hoc counterfactual explanation method tailored specifically for density-based clustering (DBSCAN). By modeling cluster structures as density-connected graphs and using a physics-inspired optimization system, it generates diverse, proximal, and theoretically guaranteed valid explanations for why data points are assigned to specific clusters or classified as noise.

What Problem Does This Paper Address?

While explainable AI (XAI) has made massive strides in supervised learning, unsupervised clustering remains largely a black box. This interpretability gap is especially glaring in DBSCAN (Density-Based Spatial Clustering of Applications with Noise). DBSCAN is exceptionally popular because it can discover clusters of arbitrary, non-convex shapes and filter out outliers as "noise." However, it provides no native way to explain why a point belongs to a specific cluster, or what minimal changes would turn a noise point into a valid cluster member.

Existing counterfactual explanation (CE) methods fail here for two reasons:

  1. No Gradients or Probabilities: Supervised CE methods rely on model gradients or continuous class probabilities to guide their search. DBSCAN only outputs discrete, hard assignments (core, border, or noise).
  2. The Euclidean Distance Trap: Standard methods use straight-line Euclidean distance to find the "closest" explanation. But in density-based clustering, two points might be close in a straight line while being separated by a massive low-density void, making a straight-line transition completely unrealistic.

Methods

To resolve these challenges, the authors introduce ExDBSCAN, which models counterfactual generation as a physical energy-minimization problem over a graph representation of the data:

  • Density-Aware Graph: ExDBSCAN constructs an undirected weighted graph where vertices are the cluster's core points, and edges connect points that are directly density-reachable. Distance is computed as the shortest path along this graph, ensuring any explanation respects the actual density topology of the cluster.
  • Physics-Inspired Optimization: To find the best counterfactuals, the algorithm balances two competing goals using physical laws:
  • Proximity (Hooke's Law): Virtual springs pull candidate counterfactuals toward the original point, ensuring the suggested changes are as minimal and realistic as possible.
  • Diversity (Coulomb's Law): Candidates are treated as like-charged particles that electrostatically repel one another, forcing the algorithm to find multiple, distinct alternative paths into the target cluster.
  • Theoretical Validity: The authors prove mathematically that by placing counterfactuals within the $\epsilon$-neighborhood of the selected core points, ExDBSCAN guarantees 100% validity—meaning every generated explanation is guaranteed to land inside the true target cluster.
  • Actionability Constraints: The method natively handles non-actionable features (e.g., immutable attributes like age or medical history) by filtering the core-point graph to ensure only reachable regions of the feature space are explored.
Visualizing how ExDBSCAN balances diversity and proximity using physics-inspired forces on a toy dataset.

Datasets

The authors evaluated ExDBSCAN across a robust suite of benchmarks:

  • 30 Tabular Datasets: Sourced from OpenML, covering diverse domains (e.g., autoPrice, blood-transfusion, diabetes, iris, ecoli).
  • Spatial/Geographical Datasets: The California Housing dataset, UrbanGB (urban road accident coordinates), and a GPS trajectories dataset.

Key Insights and Ideas

  • Surrogate Models are Unreliable for DBSCAN: A common workaround for explaining non-differentiable models is training a smooth "surrogate" classifier to mimic them. The authors show this fails miserably for DBSCAN because surrogates smooth out the sharp, discrete density boundaries, leading to highly invalid explanations.
  • The "Anchored Initialization" Phenomenon: Surprisingly, combining attraction (proximity) and repulsion (diversity) yields better aggregate diversity than using a repulsion-only strategy. The attraction term anchors the greedy search to a stable, highly central starting point, allowing the repulsion forces to distribute subsequent counterfactuals more evenly across the cluster space.

Key Results

ExDBSCAN was benchmarked against seven baseline variants (including adaptations of popular frameworks like DiCE, BayCon, and Growing Spheres):

  • Perfect Validity: ExDBSCAN achieved 100% validity across all 30 tabular datasets. In comparison, surrogate-based methods and black-box Bayesian optimizers frequently dropped below 50% validity because they couldn't navigate DBSCAN's discrete landscape.
  • Closer and More Diverse Explanations: ExDBSCAN consistently found counterfactuals that were significantly closer to the original points (lower proximity error) while simultaneously being 5× to 20× more diverse than model-agnostic methods.
Figure 2: Validity/proximity. Cumulative percentage of successful queries (x-axis) vs. proximity (y-axis, ↓lower is better). ExDBSCAN achieves perfect validity with superior proximity. ExDBSCAN Random and GS-Direct show worse proximity. Surrogate-based methods and BayCon show poor validity (< 50%) due to lack of alignment with DBSCAN model.
Figure 3: Diversity. Cumulative percentage of successful queries (x-axis) vs. diversity (y-axis, higher is better). ExDBSCAN achieves highest diversity while maintaining perfect validity, balancing proximity and diversity in its physics-inspired approach.
  • Computational Efficiency: Despite solving an NP-hard optimization problem under the hood, ExDBSCAN's greedy approximation proved highly efficient, running orders of magnitude faster than heavy optimization frameworks like DiCE.

Limitations and Future Work

While the greedy approximation is fast and matches the exact mathematical optimum in roughly 90% of cases, it remains a heuristic solution to an NP-hard problem. The authors note that exploring more sophisticated optimization strategies could further refine explanation quality.

Additionally, the current framework operates post-hoc on static data. The authors point to incremental or streaming data scenarios—such as real-time fraud detection or continuous monitoring systems where clusters evolve dynamically over time—as an exciting frontier for future work.

Summary updated

BibTeX
@misc{matthews2026exdbscan,
  author = {Pernille Matthews and Lena Krieger and Tommaso Amico and Artur Zimek and Thomas Seidl and Ira Assent},
  title = {{ExDBSCAN: Explaining DBSCAN with Counterfactual Reasoning -- Additional Material}},
  year = {2026},
  eprint = {2605.30225},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.30225},
}
Figure