Uncertainty Estimation and Out-of-Distribution Detection for Counterfactual Explanations: Pitfalls and Solutions

Eoin Delaney, Derek Greene, Mark T. KeanearXiv 2021

Abstract

Counterfactual explanations (CFEs) provide actionable recourse by suggesting minimal input changes to alter a model's prediction. However, these explanations often suffer from overconfidence or lack of grounding in the training data distribution. This paper investigates the use of Trust Scores and Monte Carlo (MC) Dropout to quantify uncertainty and detect out-of-distribution (OOD) counterfactuals. By evaluating popular CFE algorithms like NUN-CF, W-CF, and Proto-CF on MNIST and FashionMNIST datasets, the authors demonstrate that Trust Scores are a practical, model-agnostic tool for identifying unreliable recourse, while highlighting the inherent trade-offs between explanation proximity and trustworthiness.

Introduction

In the field of Explainable AI (XAI), counterfactual explanations have emerged as a primary method for providing "actionable recourse." For instance, if a financial model denies a loan application, a counterfactual might state: "If your annual income were $10,000 higher, the loan would be approved." While mathematically sound within the model's logic, such explanations often ignore the underlying data distribution. Black-box models, particularly deep neural networks, are notoriously overconfident and may suggest counterfactuals that are physically impossible or entirely unlike real-world data (Out-of-Distribution). This research addresses the critical need for uncertainty quantification and grounding in the generation of counterfactual recourse.

Methodology: Quantifying Trust

The authors evaluate two primary strategies to measure the reliability of a generated counterfactual:

  1. Trust Scores: A model-agnostic metric that compares the distance from a sample to its predicted class versus the distance to the nearest different class in the training set. A high score suggests the explanation is well-supported by the training data.
  2. Monte Carlo (MC) Dropout: A Bayesian technique that keeps "dropout" active during inference. By performing multiple passes, researchers can measure prediction variance to estimate epistemic uncertainty—essentially measuring how much the model "knows" about a specific region of the feature space.

Counterfactual Generation Algorithms

The study compares three distinct approaches to generating recourse:

  • NUN-CF (Nearest Unlike Neighbor): Identifies the closest existing instance in the training data belonging to a different class.
  • W-CF (Wachter et al.): A perturbation-based method that finds the "closest possible world" by making minimal gradient-based changes to the input.
  • Proto-CF (Klaise et al.): Utilizes class prototypes and auto-encoders to guide the counterfactual toward more plausible, data-like regions.
Visual comparison of counterfactual explanations generated by different algorithms for an MNIST query.

Experimental Evaluation

To simulate distributional shifts, the researchers utilized MNIST (handwritten digits) as In-Distribution (ID) data and FashionMNIST (clothing items) as Out-of-Distribution (OOD) data. By training a model on digits and querying it with clothing images, they could evaluate how effectively uncertainty metrics flagged "nonsense" predictions.

Key Insights

  • The Overconfidence Trap: Standard neural networks are "deterministically overconfident." The study found models were often ~99% certain that a shirt image was a digit. This confirms that raw softmax probabilities are insufficient for judging explanation quality.
  • Trust Scores as a Practical Proxy: A strong monotonic relationship ($r \approx 0.78$) was found between Trust Scores and MC-Dropout mean. This is significant because Trust Scores are computationally cheaper and do not require specific model architectures.
  • The Realism vs. Proximity Trade-off:
    • NUN-CF yielded the most trustworthy explanations because they are real training samples, though they often required larger changes (lower proximity).
  • W-CF frequently produced "adversarial" explanations—changes so minute they are invisible to humans but flip the model's label. These instances exhibited high uncertainty when validated with MC-Dropout.
  • Proto-CF often generated ambiguous or "blurry" images that resulted in inconsistent model classifications.

Results and Discussion

Trust Scores proved highly effective for OOD detection. As shown in the distribution below, FashionMNIST instances (OOD) had significantly lower trust scores compared to MNIST instances (ID).

Distribution of Trust Scores for in-distribution (MNIST) and out-of-distribution (Fashion-MNIST) samples.

In head-to-head algorithm tests on MNIST misclassifications, NUN-CF achieved the highest certainty (MC-Mean of 0.931) and highest Trust Score (1.180), whereas Proto-CF was the most uncertain (MC-Mean of 0.667). These results emphasize that perturbation-based methods like W-CF are prone to generating misleading recourse without independent uncertainty checks.

Conclusion

This research highlights the dangers of relying on raw model outputs for actionable recourse. By integrating Trust Scores and MC-Dropout, practitioners can better identify when a counterfactual explanation is unreliable. Future work should extend these findings to high-dimensional tabular data and complex color images, while incorporating user studies to determine if human experts find low-uncertainty counterfactuals more useful in high-stakes decision-making.

Summary updated

BibTeX
@misc{delaney2021uncertainty,
  author = {Eoin Delaney and Derek Greene and Mark T. Keane},
  title = {{Uncertainty Estimation and Out-of-Distribution Detection for Counterfactual Explanations: Pitfalls and Solutions}},
  year = {2021},
  eprint = {2107.09734},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.09734},
}
Figure