Tabular Diffusion Counterfactual Explanations

Wei Zhang, Brian Barr, John Paisley

TL;DR

Generating counterfactual explanations—the minimal changes needed to flip a machine learning model's prediction—is notoriously difficult for tabular data due to discrete categorical features. This paper introduces Tabular Diffusion Counterfactual Explanations (TDCE), a novel framework that uses Gumbel-softmax relaxation to enable smooth gradient backpropagation through categorical variables in a diffusion model. The result is a model-agnostic method that generates highly realistic, valid counterfactuals significantly faster than traditional search-based algorithms.

What Problem Does This Paper Address?

Imagine a machine learning model denies your loan application. A counterfactual explanation (CE) answers the question: "What is the minimum change I can make to my profile (e.g., increasing income, reducing debt) to get the loan approved?"

While diffusion models have recently excelled at generating high-fidelity counterfactuals for images, extending them to tabular data introduces a major roadblock: categorical features (like marital status or employment type). Standard diffusion guidance relies on calculating gradients through the classifier. However, categorical features are discrete, making direct gradient calculation mathematically infeasible without evaluating a combinatorial explosion of all feature combinations ($O(\prod K_i)$).

Existing methods either ignore this discrete nature, map categories to a black-box latent space (which can lead to unrealistic data points), or rely on slow, iterative graph searches.

Methods

The authors propose TDCE, which bridges the gap between discrete tabular features and continuous diffusion guidance using three key techniques:

  1. Gumbel-Softmax Relaxation: Instead of treating categorical variables as discrete one-hot vectors, TDCE applies a Gumbel-softmax re-parameterization. This transforms discrete categories into continuous, differentiable softmax representations governed by a temperature parameter ($\tau$).
  2. Log-Density Approximation: To make classifier guidance computationally efficient, the authors introduce a tight mathematical approximation of the Gumbel-softmax log-density. This allows them to use a first-order Taylor expansion, yielding an elegant, closed-form update step that mirrors standard Gaussian diffusion guidance.
  3. Blended Diffusion for Immutable Features: Real-world data contains immutable features (e.g., age or location) that shouldn't change in an explanation. TDCE handles this by blending a noisy version of the original immutable features with the guided mutable features at each step of the reverse diffusion process, ensuring the final output remains on the realistic data manifold.

Datasets

The authors evaluated their method on four large-scale, publicly available tabular datasets featuring mixed continuous and categorical variables:

  • Lending Club Dataset (LCD): 10,000 training samples, 5 numerical features, 1 categorical feature (Credit lending decisions).
  • Give Me Some Credit (GMC): 15,000 training samples, 9 numerical features, 1 categorical feature (Credit lending decisions).
  • Adult: 47,842 training samples, 9 numerical features, 2 categorical features (Predicts whether annual income exceeds \$50k).
  • LAW: 5,502 training samples, 8 numerical features, 3 categorical features (Predicts pass/fail on a law school test).

Key Insights and Ideas

  • The Temperature ($\tau$) Dilemma: The temperature parameter in the Gumbel-softmax distribution controls a crucial trade-off. As $\tau \to 0$, the representation perfectly mimics a realistic one-hot vector, but it causes vanishing gradients. Higher temperatures allow smooth gradient flow but pull the model away from the true discrete distribution. TDCE solves this by starting with a "warmer" temperature and gradually cooling it down during the reverse process.
  • Ambient Space vs. Latent Space: Unlike VAE-based counterfactual methods that search within a compressed latent space—often generating data points that fall off the real data manifold—TDCE operates directly in the ambient feature space while still leveraging the powerful generative priors of diffusion models.
  • Feature Fairness: In datasets like LCD, dominant features like FICO scores often cause baseline models to completely ignore less significant categorical features. TDCE distributes its attention more evenly across features, creating less discrepancy between the generated counterfactuals and the target class distribution.

Key Results

TDCE was benchmarked against six popular baseline methods (including Wachter, CCHVAE, CLUE, FACE, and CounterNet) across several metrics:

  • High Validity: TDCE achieved a near-perfect validity score of 99% across almost all datasets, meaning it consistently succeeded in flipping the classifier's label to the target class.
  • Superior Realism (Interpretability): It scored the lowest (best) in IM1 and IM2 metrics, proving that the generated counterfactuals look highly plausible and closely align with the true distribution of the target class.
  • Impressive Speed: Aside from CounterNet (which is fast but limited by being model-dependent), TDCE was drastically faster than all other search-based algorithms, generating 100 counterfactual samples in just 0.3 to 0.5 seconds.

Limitations and Future Work

While TDCE demonstrates exceptional performance, the authors note a few areas for improvement:

  • Proximity Trade-off: TDCE occasionally sacrifices strict $L_2$ proximity (making slightly larger feature changes) to prioritize validity and realism. However, the authors note this can be adjusted by adding an explicit regularization term to the guidance step.
  • Temperature Tuning: The performance remains sensitive to the scheduling of the temperature parameter $\tau$, which currently requires empirical searching (ranging from 0.1 to 5) for each specific dataset. Future work could explore automated or adaptive temperature scheduling.

Summary updated

BibTeX
@misc{zhang2025tabular,
  author = {Wei Zhang and Brian Barr and John Paisley},
  title = {{Tabular Diffusion Counterfactual Explanations}},
  year = {2025},
  eprint = {2509.00876},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.00876},
}
Figure