Counterfactual Explanation via Search in Gaussian Mixture Distributed Latent Space

Xuan Zhao, Klaus Broelemann, Gjergji Kasneci

Abstract

Counterfactual Explanations (CEs) are an important tool in Algorithmic Recourse for addressing two questions:

  1. What are the crucial factors that led to an automated prediction/decision?
  2. How can these factors be changed to achieve a more favorable outcome from a user's perspective? Thus, guiding the user's interaction with AI systems by proposing easy-to-understand explanations and easy-to-attain feasible changes is essential for the trustworthy adoption and long-term acceptance of AI systems. In the literature, various methods have been proposed to generate CEs, and different quality measures have been suggested to evaluate these methods. However, the generation of CEs is usually computationally expensive, and the resulting suggestions are unrealistic and thus non-actionable. In this paper, we introduce a new method to generate CEs for a pre-trained binary classifier by first shaping the latent space of an autoencoder to be a mixture of Gaussian distributions. CEs are then generated in latent space by linear interpolation between the query sample and the centroid of the target class. We show that our method maintains the characteristics of the input sample during the counterfactual search. In various experiments, we show that the proposed method is competitive based on different quality measures on image and tabular datasets -- efficiently returns results that are closer to the original data manifold compared to three state-of-the-art methods, which are essential for realistic high-dimensional machine learning applications.

Introduction

In the field of algorithmic recourse, counterfactual explanations (CEs) aim to identify the minimal changes required to an input to alter a model's prediction. For instance, a user denied a loan might be told, "If your income were $5,000 higher, your loan would be approved." Despite their utility, current methods for generating CEs suffer from high computational costs due to iterative optimization, the production of unrealistic or "adversarial" samples that lie outside the data distribution, and the loss of the user's "identity" (e.g., changing features that should remain constant).

Methodology

The proposed framework addresses these challenges by structuring the latent space of an autoencoder and utilizing simple interpolation for search.

Shaping the Latent Space

The architecture consists of a dual-branch encoder system designed to disentangle label-relevant information from idiosyncratic sample characteristics:

  1. Label Relevant Branch: This branch maps inputs to a latent space $z$ constrained to follow a Gaussian Mixture Distribution. Each class is associated with a specific cluster centroid, facilitating structured transitions between classes.
  2. Label Irrelevant Branch: An adversarial classifier is employed to ensure that this branch ($z_u$) captures only label-agnostic features, such as the "style" or "slant" of a handwritten digit.
Overview of the training and generation process. The training phase shapes the latent space into a GMM, while the generation phase uses linear interpolation for rapid counterfactual search.

Search via Interpolation

Rather than performing expensive gradient-based optimization for every query, the method generates CEs through linear interpolation in the latent space. By moving from the query point toward the target class centroid and decoding the intermediate points, the system efficiently identifies the decision boundary while preserving the original sample's identity through the label-irrelevant features.

Experimental Evaluation

The method was evaluated on MNIST, Adult Income, and Lending Club datasets. Key findings include:

  • Efficiency: On MNIST, the proposed method generated CEs in 0.007 seconds, representing a massive speedup over baselines like GDL (1.568s) and Prototype (1.345s).
  • Validity and Realism: The method achieved high validity (~90%) and lower reconstruction loss, indicating that the generated counterfactuals are more realistic and closer to the actual data manifold.
  • Identity Preservation: Visual results on MNIST demonstrate that the method successfully preserves the unique style of the original input while changing its class.
Visual comparison of counterfactual explanations on the MNIST dataset. The proposed method (Ours) produces realistic '7's that retain the slant and style of the original '1's, outperforming baselines in realism and identity preservation.

Conclusion

By combining Gaussian Mixture latent space shaping with disentangled representations, this approach provides a fast and effective way to generate realistic counterfactual explanations. While the method prioritizes realism over extreme sparsity in feature changes, its speed and ability to stay "in-distribution" make it highly suitable for high-dimensional applications. Future work will explore extensions to multi-class scenarios and further optimization of the latent representations.

Summary updated

BibTeX
@misc{zhao2023counterfactual,
  author = {Xuan Zhao and Klaus Broelemann and Gjergji Kasneci},
  title = {{Counterfactual Explanation via Search in Gaussian Mixture Distributed Latent Space}},
  year = {2023},
  eprint = {2307.13390},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.13390},
}
Figure