Manuscript Offprint

arXiv:2610.08537

FlowCF: Sparse Counterfactual Explanations for Mixed-Type Tabular Data using Flow Matching

Emmanouil Panagiotou, Eirini Ntoutsi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

In the field of Explainable AI (XAI), counterfactual (CF) explanations interpret a model's decision by suggesting the changes to the input that would lead to a more favourable outcome. To be useful in practice, such an explanation should change few features and change them as little as possible, properties known as sparsity and proximity. We observe that existing methods remain limited in this respect, especially for numerical features, whether they are model-agnostic and amortised, or gradient-based with full access to the model. In this paper, we propose FlowCF, a model-agnostic generative method that frames CF generation as sparse transport from the factual to the target class. We solve this transport with flow matching, which we extend to mixed feature types with a novel mixed flow operator, and exploit the resulting geometry to optimise for sparsity through a gating network that minimises the number of features the transport changes. Extensive experiments on six benchmark datasets demonstrate that FlowCF produces the best numerical sparsity and proximity, changing 29% of the numerical features where the best baseline changes 89%, at 70% smaller displacement, while remaining comparable on the other desiderata.

1 Introduction

Given a model’s decision on an instance, a counterfactual (CF) explanation suggests the changes to the input that would lead to a more favourable outcome. This answers a what-if question about that instance, which makes CFs directly actionable, and a common choice in domains where decisions affect individuals, such as credit, hiring, and medicine, where the data is typically tabular, with both numerical and categorical features [17].

A useful CF has to satisfy several, partly conflicting, properties, which the literature refers to as desiderata [23]. The most common are validity (the prediction changes), proximity (the CF stays close to the factual instance), sparsity (few features change), and actionability (it respects what the user is able to change), while many more have been proposed, such as plausibility, diversity, and amortised inference, with each method typically targeting a different subset of them. Notably, sparsity and proximity determine how easy a CF is to understand and act on, since explanations are more effective when they involve few features [15], and smaller changes are more realistic to implement [23, 16].

Existing methods approach CF explanation generation in different ways and assume different access to the model they explain, but all solve the same underlying task: moving an instance from one class (decision) to a targeted other. Optimisation-based methods such as DiCE [16] and TABCF [17] search for counterfactuals using gradient descent, in the input space or latent space, which requires access to gradients through the model and one optimisation run per explanation. Generative methods such as CCHVAE [18] and DiCoFlex [6] instead learn the structure of the data with a variational autoencoder or a normalising flow, and can amortise generation into a single forward pass.

40th Conference on Neural Information Processing Systems (NeurIPS 2026). Workshop: Geometric Distributional Deep Learning.

Table 1: Desired properties of existing counterfactual methods compared to FlowCF.

model-agnosticamortisedexact numerical sparsityno black-box queries at inference
Wachter✕✕✕✕
DiCE✕✕✕✕
TABCF✕✕✕✕
REVISE✕✕✕✕
CCHVAE✓✕✕✕
DiCoFlex✓✓✕✕
FlowCF✓✓✓✓

Figure

Figure

Figure 1: Counterfactuals generated by our method FlowCF vs DiCoFlex, the closest baseline method, on the two-moons dataset. FlowCF achieves exact numerical sparsity, changing a single feature when possible, while all counterfactuals sampled by DiCoFlex change both features.

In this work, we observe that existing methods fall short on sparsity and proximity, especially for numerical features. Exact numerical sparsity is difficult to optimise for by construction, since it is defined as the L0L_{0} count of changed features, which is non-differentiable and therefore not directly optimisable by gradient descent [13]. Existing methods approximate it with an L1L_{1} term or heuristics such as post-hoc pruning, neither of which leaves a feature exactly unchanged (see Figure 1). To address these limitations, we introduce FlowCF, a generative method that frames CF generation as sparse transport from the factual class to the target class. Flow matching is a natural fit for this setting, as it learns a velocity field that moves samples from one continuous distribution to another. Since classical flow matching is defined for continuous data only, we extend it to mixed feature types with a mixed flow operator, following categorical flow maps [22]. The operator takes a single step along a straight path, so that each instance is explained by one displacement vector over its features, and we exploit this geometry to optimise for sparsity. Sparsity is achieved via a gating network that minimises the number of features the transport changes, and proximity by minimising the flow vectors. As summarized in Table 1, FlowCF is the only method that is simultaneously model-agnostic and amortised, requires no model access at explanation time, and achieves exact numerical sparsity. We perform a quantitative evaluation against state-of-the-art baselines on six binary classification datasets (Section 5), showing that FlowCF produces the sparsest and most proximal numerical counterfactuals on every dataset, while remaining comparable on the other desiderata.

Our contributions are: i) identifying the limitation of existing CF methods in achieving exact numerical sparsity; ii) introducing FlowCF, a novel method using a gated, mixed flow-matching transport for generating sparse and proximal counterfactual explanations. The code for reproducing our experiments is included in the supplementary material.

References (22)