On Generating Plausible Counterfactual and Semi-Factual Explanations for Deep Learning

Eoin M. Kenny, Mark T. Keane

As deep learning models become increasingly integrated into high-stakes domains like medicine and law, the "black box" problem becomes a critical liability. We know these models are accurate, but we often don't know why they make specific decisions.

A new paper by Kenny and Keane, "On Generating Plausible Counterfactual and Semi-Factual Explanations for Deep Learning," introduces a novel framework to bridge this gap. By mimicking the way humans naturally reason, their method—dubbed PIECE—generates visual explanations that are not only technically sound but also human-plausible.

TL;DR

The authors introduce PIECE, a method that generates counterfactual ("If X changed, the outcome would change") and semi-factual ("Even if X changed, the outcome would stay the same") explanations for image classifiers. By identifying and normalizing "exceptional" latent features, PIECE produces explanations that are more realistic and grounded in training data than existing state-of-the-art methods.

What Problem Does This Paper Address?

Explainable AI (XAI) often relies on counterfactuals. For a rejected loan applicant, a counterfactual might be: "If your income were $5,000 higher, you would have been approved."

However, applying this to images is difficult. Images are high-dimensional and continuous. Traditional methods often result in "adversarial" explanations—tiny, invisible pixel tweaks that change the model's prediction but mean nothing to a human—or "implausible" images that look like static and don't resemble real data.

Furthermore, the AI community has largely ignored semi-factuals. These are "even if" explanations (e.g., "Even if you had a slightly higher income, you still would have been rejected"). Semi-factuals are psychologically powerful because they show a decision is robust and "incontestable," which is particularly useful when delivering bad news.

Figure 1: PIECE: A test image is shown next to a nearest neighbor from the training data (i.e., a factual explanation simply for context here), alongside a synthetic semi-factual and counterfactual explanation generated for the test image by PIECE.

Methods

The authors propose PIECE (PlausIble Exceptionality-based Contrastive Explanations). The core idea is inspired by the "exceptionality effect" in psychology: when humans imagine how things could have been different, they tend to change unusual (exceptional) events back to their normal state.

The PIECE algorithm operates in three main steps:

  1. Identify Exceptional Features: Using a pre-trained CNN and a GAN, PIECE analyzes the latent features of a test image. It uses a "hurdle model" (a combination of a Bernoulli trial and a probability density function like Gaussian or Gamma) to determine which features are statistically "exceptional" for a target class.
  2. Modify to the Expected: It changes these exceptional features to their "normal" or expected values for the target class.
  3. Visualize via GAN: The modified latent representation is passed through the GAN’s generator to produce a new, plausible image in pixel space.

To generate semi-factuals, the algorithm follows the same path but stops the modifications just before the image crosses the model's decision boundary.

Figure 3: The PIECE pipeline, identifying exceptional features in the CNN latent space and using a GAN to visualize the resulting explanation.

Datasets

The researchers evaluated PIECE using two standard computer vision benchmarks:

  • MNIST: The classic dataset of handwritten digits (0-9).
  • CIFAR-10: A more complex dataset of color images across 10 categories (e.g., airplanes, dogs, ships).

Key Insights and Ideas

  • Exceptionality as a Heuristic: By focusing on features that are statistically rare for a class, PIECE naturally targets the most "informative" parts of an image for an explanation, such as the specific curve that turns a '3' into an '8'.
  • Plausibility requires Grounding: The authors argue that a good explanation must lie on the "data manifold"—it must look like a real piece of data. By using GANs and statistical modeling of the training set, PIECE ensures its explanations are "grounded."
  • The Power of "Even If": This is the first work to formally bring semi-factual explanations to deep learning for images. They show that semi-factuals can demonstrate the "stability" of a model's prediction by showing how much a feature can change without changing the outcome.

Key Results

PIECE was compared against several baselines, including Min-Edit and Proto-CF.

  • Plausibility: PIECE significantly outperformed all other methods on plausibility metrics. On MNIST, it achieved a Substitutability score of 69.32% (a measure of how well generated images can train a new classifier), compared to just ~43% for the next best method.
  • Realism: Quantitative measures like MC-Dropout (measuring model uncertainty) showed that PIECE generates images that the model is much more "certain" about, indicating they look more like real training data.
  • Semi-Factual Quality: In the first-ever quantitative test for image semi-factuals, PIECE produced explanations with significantly higher $L_1$ pixel-space changes than minimal-edit methods, meaning it provides more "substantive" explanations of the model's decision boundaries.
Figure 2: Visual comparison of PIECE's explanations. Note how the counterfactual for the '8' (misclassified as '3') adds a plausible cursive stroke, whereas the Min-Edit version is barely human-interpretable.

Limitations and Future Work

While PIECE is a significant step forward, it has a few dependencies:

  • GAN Requirement: The method requires a GAN to be trained on the same dataset as the CNN. As GANs can be difficult to train for very complex, high-resolution datasets, this may limit immediate scalability to "in-the-wild" images.
  • Simple Datasets: The current evaluation is limited to MNIST and CIFAR-10. The authors acknowledge the need to extend this to more complex image datasets.
  • Future Directions: The authors suggest that the "exceptionality" framework could be applied to other domains, such as Natural Language Processing (NLP), by utilizing recent advances in generative text models.

Summary updated

Abstract

There is a growing concern that the recent progress made in AI, especially regarding the predictive competence of deep learning models, will be undermined by a failure to properly explain their operation and outputs. In response to this disquiet counterfactual explanations have become massively popular in eXplainable AI (XAI) due to their proposed computational psychological, and legal benefits. In contrast however, semifactuals, which are a similar way humans commonly explain their reasoning, have surprisingly received no attention. Most counterfactual methods address tabular rather than image data, partly due to the nondiscrete nature of the latter making good counterfactuals difficult to define. Additionally generating plausible looking explanations which lie on the data manifold is another issue which hampers progress. This paper advances a novel method for generating plausible counterfactuals (and semifactuals) for black box CNN classifiers doing computer vision. The present method, called PlausIble Exceptionality-based Contrastive Explanations (PIECE), modifies all exceptional features in a test image to be normal from the perspective of the counterfactual class (hence concretely defining a counterfactual). Two controlled experiments compare this method to others in the literature, showing that PIECE not only generates the most plausible counterfactuals on several measures, but also the best semifactuals.
BibTeX
@inproceedings{kenny2021generating,
  author = {Eoin M. Kenny and Mark T. Keane},
  title = {{On Generating Plausible Counterfactual and Semi-Factual Explanations for Deep Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i13.17377},
}
Figure