Table of Contents
Fetching ...

DiCoFlex: Model-agnostic diverse counterfactuals with flexible control

Oleksii Furman, Ulvi Movsum-zada, Patryk Marszalek, Maciej Zięba, Marek Śmieja

TL;DR

DiCoFlex addresses the challenge of generating multiple diverse counterfactual explanations without requiring constant access to the predictive model or retraining. It leverages a conditional normalizing flow (MAF) trained on labeled data to approximate $p_{ heta}(oldsymbol{x}'|oldsymbol{x}, y')$, enabling a single forward pass to produce several counterfactuals while allowing inference-time control over sparsity via the $L_p$ norm and actionability via a feature mask. Training relies on sampling training counterfactuals from a $K$-nearest neighbors distribution $\\hat{q}(oldsymbol{x}'|oldsymbol{x}, y', d)$ and optimizing a KL-based objective that aligns the flow with this distribution, guaranteeing validity by construction. Empirical results on five benchmark tabular datasets show DiCoFlex achieves superior diversity, plausibility, and proximity, with real-time generation and flexible constraint handling, making it a practical tool for sensitive decision domains where stakeholder-guided recourse is important.

Abstract

Counterfactual explanations play a pivotal role in explainable artificial intelligence (XAI) by offering intuitive, human-understandable alternatives that elucidate machine learning model decisions. Despite their significance, existing methods for generating counterfactuals often require constant access to the predictive model, involve computationally intensive optimization for each instance and lack the flexibility to adapt to new user-defined constraints without retraining. In this paper, we propose DiCoFlex, a novel model-agnostic, conditional generative framework that produces multiple diverse counterfactuals in a single forward pass. Leveraging conditional normalizing flows trained solely on labeled data, DiCoFlex addresses key limitations by enabling real-time user-driven customization of constraints such as sparsity and actionability at inference time. Extensive experiments on standard benchmark datasets show that DiCoFlex outperforms existing methods in terms of validity, diversity, proximity, and constraint adherence, making it a practical and scalable solution for counterfactual generation in sensitive decision-making domains.

DiCoFlex: Model-agnostic diverse counterfactuals with flexible control

TL;DR

DiCoFlex addresses the challenge of generating multiple diverse counterfactual explanations without requiring constant access to the predictive model or retraining. It leverages a conditional normalizing flow (MAF) trained on labeled data to approximate , enabling a single forward pass to produce several counterfactuals while allowing inference-time control over sparsity via the norm and actionability via a feature mask. Training relies on sampling training counterfactuals from a -nearest neighbors distribution and optimizing a KL-based objective that aligns the flow with this distribution, guaranteeing validity by construction. Empirical results on five benchmark tabular datasets show DiCoFlex achieves superior diversity, plausibility, and proximity, with real-time generation and flexible constraint handling, making it a practical tool for sensitive decision domains where stakeholder-guided recourse is important.

Abstract

Counterfactual explanations play a pivotal role in explainable artificial intelligence (XAI) by offering intuitive, human-understandable alternatives that elucidate machine learning model decisions. Despite their significance, existing methods for generating counterfactuals often require constant access to the predictive model, involve computationally intensive optimization for each instance and lack the flexibility to adapt to new user-defined constraints without retraining. In this paper, we propose DiCoFlex, a novel model-agnostic, conditional generative framework that produces multiple diverse counterfactuals in a single forward pass. Leveraging conditional normalizing flows trained solely on labeled data, DiCoFlex addresses key limitations by enabling real-time user-driven customization of constraints such as sparsity and actionability at inference time. Extensive experiments on standard benchmark datasets show that DiCoFlex outperforms existing methods in terms of validity, diversity, proximity, and constraint adherence, making it a practical and scalable solution for counterfactual generation in sensitive decision-making domains.

Paper Structure

This paper contains 58 sections, 5 theorems, 26 equations, 3 figures, 8 tables, 1 algorithm.

Key Result

Lemma A.1

Let $p$ and $q$ be two distributions over the same finite set $\mathcal{X}$, and let the total variation distance be defined as $\|p - q\|_{\text{TV}} = \frac{1}{2}\sum_{x \in \mathcal{X}} |p(x) - q(x)|$. For any function $f: \mathcal{X} \to \mathbb{R}$, we have:

Figures (3)

  • Figure 1: Visualization of diverse counterfactual explanations generated by DiCoFlex for a single instance using an artificial two-class moon-shaped dataset. Each subfigure demonstrates different constraint scenarios: (a) no constraints applied, showing natural diversity; (b) sparsity constraints enforced through the $p$-norm parameter, resulting in minimal feature modifications; and (c) actionability constraints applied via feature masks, restricting which features can be modified.
  • Figure 2: Average runtime (log scale).
  • Figure 3: Visualization of runtime of DiCoFlex method and other baseline methods.

Theorems & Definitions (10)

  • Lemma A.1: Upper bound on difference of expected values
  • proof
  • Theorem A.2: Diversity Preservation in DiCoFlex
  • proof
  • Proposition A.3: Validity
  • proof
  • Proposition A.4: Proximity Upper Bound
  • proof
  • Proposition A.5: In-Distribution Guarantee
  • proof