Table of Contents
Fetching ...

LeapFactual: Reliable Visual Counterfactual Explanation Using Conditional Flow Matching

Zhuo Cao, Xuan Zhao, Lena Krieger, Hanno Scharr, Ira Assent

TL;DR

This work addresses the need for reliable, interpretable counterfactual explanations in high-stakes settings by introducing LeapFactual, a model-agnostic CE method based on conditional flow matching. It formalizes the CE-CFM objective to disentangle class-related information from residual content, enabling information replacement, blending, and injection along learned transport maps even when true and learned decision boundaries differ. Across Morpho-MNIST, Galaxy10 DECaLS, and FFHQ/StyleGAN3 benchmarks, LeapFactual and its injection-enhanced variant produce accurate, in-distribution counterfactuals that improve robustness and can augment training data, while remaining applicable to non-differentiable human-in-the-loop systems. The approach promises broad impact for scientific discovery and non-expert interpretability, with scalability and potential extensions to more efficient transport maps such as OT-CFM as future work.

Abstract

The growing integration of machine learning (ML) and artificial intelligence (AI) models into high-stakes domains such as healthcare and scientific research calls for models that are not only accurate but also interpretable. Among the existing explainable methods, counterfactual explanations offer interpretability by identifying minimal changes to inputs that would alter a model's prediction, thus providing deeper insights. However, current counterfactual generation methods suffer from critical limitations, including gradient vanishing, discontinuous latent spaces, and an overreliance on the alignment between learned and true decision boundaries. To overcome these limitations, we propose LeapFactual, a novel counterfactual explanation algorithm based on conditional flow matching. LeapFactual generates reliable and informative counterfactuals, even when true and learned decision boundaries diverge. Following a model-agnostic approach, LeapFactual is not limited to models with differentiable loss functions. It can even handle human-in-the-loop systems, expanding the scope of counterfactual explanations to domains that require the participation of human annotators, such as citizen science. We provide extensive experiments on benchmark and real-world datasets showing that LeapFactual generates accurate and in-distribution counterfactual explanations that offer actionable insights. We observe, for instance, that our reliable counterfactual samples with labels aligning to ground truth can be beneficially used as new training data to enhance the model. The proposed method is broadly applicable and enhances both scientific knowledge discovery and non-expert interpretability.

LeapFactual: Reliable Visual Counterfactual Explanation Using Conditional Flow Matching

TL;DR

This work addresses the need for reliable, interpretable counterfactual explanations in high-stakes settings by introducing LeapFactual, a model-agnostic CE method based on conditional flow matching. It formalizes the CE-CFM objective to disentangle class-related information from residual content, enabling information replacement, blending, and injection along learned transport maps even when true and learned decision boundaries differ. Across Morpho-MNIST, Galaxy10 DECaLS, and FFHQ/StyleGAN3 benchmarks, LeapFactual and its injection-enhanced variant produce accurate, in-distribution counterfactuals that improve robustness and can augment training data, while remaining applicable to non-differentiable human-in-the-loop systems. The approach promises broad impact for scientific discovery and non-expert interpretability, with scalability and potential extensions to more efficient transport maps such as OT-CFM as future work.

Abstract

The growing integration of machine learning (ML) and artificial intelligence (AI) models into high-stakes domains such as healthcare and scientific research calls for models that are not only accurate but also interpretable. Among the existing explainable methods, counterfactual explanations offer interpretability by identifying minimal changes to inputs that would alter a model's prediction, thus providing deeper insights. However, current counterfactual generation methods suffer from critical limitations, including gradient vanishing, discontinuous latent spaces, and an overreliance on the alignment between learned and true decision boundaries. To overcome these limitations, we propose LeapFactual, a novel counterfactual explanation algorithm based on conditional flow matching. LeapFactual generates reliable and informative counterfactuals, even when true and learned decision boundaries diverge. Following a model-agnostic approach, LeapFactual is not limited to models with differentiable loss functions. It can even handle human-in-the-loop systems, expanding the scope of counterfactual explanations to domains that require the participation of human annotators, such as citizen science. We provide extensive experiments on benchmark and real-world datasets showing that LeapFactual generates accurate and in-distribution counterfactual explanations that offer actionable insights. We observe, for instance, that our reliable counterfactual samples with labels aligning to ground truth can be beneficially used as new training data to enhance the model. The proposed method is broadly applicable and enhances both scientific knowledge discovery and non-expert interpretability.
Paper Structure (47 sections, 1 theorem, 11 equations, 10 figures, 6 tables, 2 algorithms)

This paper contains 47 sections, 1 theorem, 11 equations, 10 figures, 6 tables, 2 algorithms.

Key Result

Theorem 1

Let $Z_1$ denote the original representation and $Z_0$ its counterpart obtained via flow matching conditioned on class information $C$. Then, $Z_0$ is a compressed representation of $Z_1$, and the optimized information loss incurred through this transformation corresponds exactly to the class-relate

Figures (10)

  • Figure 1: (Left) Conceptual illustration of 1D data embedded in 2D space. Blue and red circles denote data of two MNIST classes (8 and 6, resp.), with the dotted line representing the data manifold. The true decision boundary is , while the solid line is the learned boundary. The background color indicates the output of the binary classifier. Adversarial attack , CGM-generated CE , and Opt-based CE examples originate from the starting point . (Right) Conceptual multi-class 3D example. Each color represents an MNIST digit class. A sample from the blue cluster is transported along the olive path to reach the red cluster, forming a CE. The purple line shows the large distance between CE and the source, highlighting gradient vanishing issues. More details can be found in \ref{['sec: method_preliminary']}.
  • Figure 2: Overview of architectures - Opt-based models, CGM-based models and LeapFactual. Trapezoids represent generative models. Opt-based and CGM-based methods employ only flattened or structured representation (see \ref{['sec: method_preliminary']}), while LeapFactual combines both.
  • Figure 3: (Left) Flattened latent representation, (Middle) structured latent representation, and (Right) proposed latent representation, where $X$, $Z$, $C$, and $R$ represent input, the corresponding latent variable, class-related information, and residual information. The distributions connected by flow matching are $Z_0$ and $Z_1$.
  • Figure 4: Toy experiments illustrating lifting and landing transports. The vertical axis represents $t$. Hollow circles denote source points; filled circles or triangles indicate transported points. (a) Blue source points are lifted to $t=0$, removing center position information, which is replaced by the red class during landing. (b) Center information from green, blue, and yellow sources is overwritten by the red class. (c) Transported points blend center information from source (green, blue, red) and target (red); dashed lines show interpolation. (d) Target information is injected even when source and target are both red; dashed lines show interpolation. (e) At $t=1$: filled circles mark blended points, triangles mark injected ones; dashed and dotted lines denote blending and injection interpolations.
  • Figure 5: Qualitative comparison of counterfactual samples across different methods (rows) and target labels (columns). The first two rows are randomly sampled target labels and inputs, followed by the reconstructed images.
  • ...and 5 more figures

Theorems & Definitions (4)

  • Theorem 1
  • proof
  • proof
  • proof