Paper deep dive
FlowCF: Sparse Counterfactual Explanations for Mixed-Type Tabular Data using Flow Matching
Emmanouil Panagiotou, Eirini Ntoutsi
Intelligence
Status: not_run | Model: - | Prompt: - | Confidence: 0%
Entities (0)
Relation Signals (0)
No relation signals yet.
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
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.
Tags
Links
- Source: https://arxiv.org/abs/2610.08537v1
- Canonical: https://arxiv.org/abs/2610.08537v1
Trouble viewing inline? Open PDF directly →
Full Text
38,911 characters extracted from source content.
Expand or collapse full text
Geometric Distributional Deep Learning FlowCF: Sparse Counterfactual Explanations for Mixed-Type Tabular Data using Flow Matching Emmanouil Panagiotou Affiliation: Freie Universität Berlin Email: emmanouil.panagiotou@fu-berlin.de Eirini Ntoutsi Affiliation: University of the Bundeswehr Munich Email: eirini.ntoutsi@unibw.de 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%29\% of the numerical features where the best baseline changes 89%89\%, at 70%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 [19] 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. 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). Table 1: Desired properties of existing counterfactual methods compared to FlowCF. model- agnostic amortised exact numerical sparsity no black-box queries at inference Wachter ✗ ✗ ✗ ✗ DiCE ✗ ✗ ✗ ✗ TABCF ✗ ✗ ✗ ✗ REVISE ✗ ✗ ✗ ✗ CCHVAE ✓ ✗ ✗ ✗ DiCoFlex ✓ ✓ ✗ ✗ FlowCF ✓ ✓ ✓ ✓ 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. 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; i) 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. 2 Related work The literature on counterfactual explanations is extensive [23, 18]. We cover the works closest to ours: counterfactual generation for tabular data, and flow-based transport. Counterfactual explanations for tabular data. Wachter et al. [24] first framed CF search as an optimisation problem in input space, minimising the distance to the original instance subject to a label flip. This inspired methods that assume a differentiable black box and take gradient steps, either in input space like DiCE [16], or in the latent space of a generative model like REVISE [8] and TABCF [17]. Sparsity can enter their objective, through an L1L_1 term or a post-hoc pruning step, but at the cost of a separate optimisation run per instance and gradient access to the model being explained. A second family avoids per-instance optimisation. CCHVAE [19] performs a growing-sphere search in the latent space of a conditional VAE, and DiCoFlex [6] trains a conditional normalising flow that emits multiple diverse counterfactuals in a single forward pass, with constraint control applied at inference time. Both are model-agnostic, requiring no gradients through the black box, and DiCoFlex additionally amortises generation. Both methods, however, produce dense counterfactuals, especially for numerical features. DiCoFlex targets sparsity only through its nearest-neighbour selection, preferring target-class neighbours that differ in fewer features, which encourages small changes but never exactly freezes a feature (see Figure 1). Flow-based generation. Flow-based methods are generative models that learn to map one, usually continuous, distribution onto another. Normalising flows [21] do so through an invertible transformation of the base density, giving exact likelihoods at the cost of an architecture restricted to invertible maps with a tractable Jacobian, and of learning a density rather than a movement between distributions. Flow matching [11] lifts both restrictions by prescribing an interpolant between the two distributions and regressing a velocity field along it, removing the need for invertibility and for simulating an ODE during training. Since a convex interpolant is undefined for discrete variables, the formulation has been extended to categorical data through the probability simplex [22]. Building on this, rectified flows [12] take the straight-line interpolant between two observed distributions, and show that straightening the paths lets a single Euler step replace integrating the ODE. Normalising flows have been used for counterfactual generation [4, 6], focusing on plausibility and diversity. We propose a mixed flow matching operator that transports between the two class-conditional distributions in a single step, using the resulting geometry to optimise for exact sparsity, proximity, and validity. 3 FlowCF: sparse flow-matching counterfactual explanations Following prior model-agnostic work [6], we consider a binary black-box classifier f:→y∈0,1f:X→ y∈\0,1\. We observe only its predicted labels, without access to gradients, model parameters, probabilities, or logits. Each input x=[xnum,xcat]x=[x^num,x^cat] contains |N||N| numerical and |C||C| categorical features. Let π0 _0 and π1 _1 denote the empirical distributions of instances assigned to the factual and target classes, respectively. We define the sparse transport problem as learning a map T that moves an instance x∼π0x _0, with f(x)=0f(x)=0, toward π1 _1, producing a valid counterfactual x′=(x)x =T(x) with f(x′)=1f(x )=1 while changing as few features as possible. Flow matching is a natural fit for this problem because it learns a transport between distributions from paired samples. Like other generative counterfactual methods [6], it amortises generation and avoids a separate optimisation for each counterfactual. However, standard flow matching does not account for CF desiderata like sparsity and proximity, and therefore produces dense displacements. To address this limitation, we introduce FlowCF. Our method is comprised of two models and is trained in three steps. The first model is a mixed flow operator FθF_θ, designed to support mixed-type data and move factual instances toward the target class. The second model is a gate operator GψG_ψ that determines which feature changes are applied to each instance. At inference, the gates are binarised so that inactive features remain exactly unchanged. Step 1. Transport (Section 3.1). We train FθF_θ on pairs of factual and target-class instances to learn target-directed feature changes. Step 2. Sparsity (Section 3.2). We freeze FθF_θ and train GψG_ψ to remove unnecessary feature changes while maintaining validity. Step 3. Joint (Section 3.3). We freeze GψG_ψ and fine-tune FθF_θ through the learned gates to improve proximity while maintaining validity and staying close to the transport learned in Step 1. Figure 2 illustrates the effect of each training step on the same four factual instances. Figure 2: FlowCF’s three training steps on samples from the 2D two-moons dataset. Green marks a learned displacement that changed one feature, red both. Step 1 produces valid CFs but changes both features. Step 2 achieves better sparsity making three of the four CFs axis-aligned. Step 3 further improves proximity while preserving validity and sparsity. 3.1 Step 1: Transport The first step learns a transport from π0 _0 to π1 _1. Since a factual instance can be paired with several target-class instances, this pairing directly affects the proximity and sparsity of the resulting counterfactual. We pair each x0x_0 with its K nearest neighbours in the target class, using L1L_1 distance on the numerical block and Hamming distance on the categorical block, following [6]. This keeps the transport short and ensures that each path ends at an observed target-class instance. We learn the transport between these pairs with flow matching [12, 11]. For the numerical block, we take the interpolant xtnum=(1−t)x0num+tx1num,t∼[0,1]x^num_t=(1-t)\,x^num_0+t\,x^num_1,\ t [0,1]\ and train a velocity field vθv_θ to predict the displacement from the intermediate point. However, this does not extend to categorical features, since a convex combination of two one-hot vectors is not a valid category. Following the categorical flow method [22], we represent each categorical column in the probability simplex and predict an endpoint distribution μθ _θ rather than a velocity. The two parameterisations are equivalent along a straight-line interpolant [22], while the endpoint form keeps categorical predictions admissible. Our mixed flow operator ℱθF_θ supports both output feature types present in the data. It moves the numerical block by a displacement, and replaces the categorical block with a predicted endpoint: ℱθ(x,t):xnum⟼xnum+vθ(x,t)⏟numerical displacement,xcat⟼μθ(x,t)⏟categorical endpoint,F_θ(x,t): x^num\; \;x^num+ v_θ(x,t)_ numerical displacement, x^cat\; \; _θ(x,t)_ categorical endpoint, (1) We optimise ℱθF_θ using the following loss: ℒflow= _flow= [‖vθ(xt,t)−(x1num−x0num)‖22+λcatCE(μθ(xt,t),x1cat)]+λvalℒval(ℱθ(x)), [ \|v_θ(x_t,t)-(x^num_1-x^num_0) \|_2^2+ _cat\,CE ( _θ(x_t,t),x^cat_1 ) ]+ _val\,L_val (F_θ(x) ), whereℒval(ℱθ(x))=[hinge_loss(S(ℱθ(x)),y=1)]. _val (F_θ(x) )=E [hinge\_loss (S(F_θ(x)),y=1 ) ]. (2) The first term learns the numerical and categorical mappings. The numerical velocity is trained by squared error, while CECE is the cross-entropy between the predicted and paired target categories, summed over categorical columns using the mean-field factorisation of [22]. The weight λcat _cat balances the two feature types. The second term provides a direct validity signal. Since f is a black-box classifier, we train a surrogate S to reproduce its predictions on D and freeze it. We then define ℒvalL_val using the hinge loss of [16], with λval _val controlling its contribution. The hinge loss stops penalising a counterfactual once it reaches the target margin, avoiding unnecessary movement deeper into the target class. We generate using a single Euler step from t=0t=0, i.e. a one-step map ℱθ(x):=ℱθ(x,0)F_θ(x):=F_θ(x,0). We find this sufficient for tabular data, and consistent with prior work showing that rectified flows can be distilled into accurate one-step models for fast inference even in high-dimensional domains [12]. 3.2 Step 2: Sparsity The learned flow of Step 1 changes every feature, without taking the sparsity desideratum into account. To address this, we freeze the transport ℱθF_θ and introduce a gating network, trained to zero out as many feature changes as possible while preserving validity. What we want is a binary mask over features, selecting the ones the flow may change, but such a mask cannot be directly learned by gradient descent, as neither the mask nor the L0L_0 count is differentiable. Following L0L_0-style gating [13, 1], we relax it to a continuous gate g, produced by a network aψa_ψ with one output per feature. Our counterfactual operator θ,ψT_θ,ψ then applies the flow to each feature in proportion to its gate: θ,ψ(x)=(1−g)⊙x⏟keep the factual+g⊙ℱθ(x)⏟apply the flow,g=ψ(x)=σ(aψ(x)/T),T_θ,ψ(x)\;=\; (1-g) x_keep the factual\;+\; g _θ(x)_apply the flow, g\;=\;G_ψ(x)\;=\;σ\! (a_ψ(x)/T ), (3) with σ the logistic sigmoid and T a temperature controlling the hardness of the relaxation. We keep the gate deterministic, so that training and inference remain consistent. A gate of 00 keeps a feature at exactly its factual value and a gate of 11 applies the flow in full, while intermediate values scale the displacement of a numerical feature or interpolate a categorical one towards the predicted endpoint. Our gate also naturally guarantees the actionability desideratum: setting gc≡0g_c≡ 0 for immutable features strictly enforces the constraint, rather than soft-penalizing it, forcing the transport to reach the target class through actionable features alone. We train the gate ψG_ψ with three terms, one per desideratum, optimising the composed map θ,ψT_θ,ψ of Equation 3 with the transport ℱθF_θ frozen: ℒgate=ℒval(θ,ψ(x))⏟validity+λsparseℒsparse⏟sparsity+λproxℒprox⏟proximity,L_gate\;=\; L_val(T_θ,ψ(x))_validity\;+\; _sparse L_sparse_sparsity\;+\; _prox L_prox_proximity, (4) whereℒsparse=[∑c∈N∪Cgc],ℒprox=[∑c∈N|gcvθc|+∑c∈Cgcpc].where _sparse\;=\;E [ _c∈ N∪ Cg_c ], _prox\;=\;E [ _c∈ N|g_c\,v^c_θ|\;+\; _c∈ Cg_c\,p_c ]. (5) We use the same validity term as in Step 1, now evaluated on the gated counterfactual rather than on the raw endpoint of the transport. Gating a feature the label flip depends on is therefore penalised; without this signal, the gate would optimise sparsity and proximity alone, and simply keep the features that change least. The sparsity term is the differentiable surrogate for the L0L_0 count of the sparsity metric in Section 4.4, charging for every feature the gate leaves open. Its weight λsparse _sparse controls how sparse the edit is, closing more features as it increases, until validity begins to suffer. The proximity term charges the scale of the displacement identically for both feature types, using the flow’s displacement vθcv^c_θ for numerical features, and for categorical ones the probability mass pcp_c that the predicted endpoint places outside the original category. 3.3 Step 3: Joint In the final step we unfreeze the transport ℱθF_θ and freeze the gate ψG_ψ, optimising the composed map θ,ψT_θ,ψ of Equation 3 against the same validity and proximity terms. The flow is therefore re-fit through the gate, so that only the features the gate left open can carry the label flip. To avoid unstable training, a third term ℒdriftL_drift keeps ℱθF_θ close to its Step 1 solution ℱθ′F_θ . ℒjoint=ℒval(θ,ψ(x))+λproxℒprox+λdriftℒdrift,ℒdrift=[‖ℱθ(x)−ℱθ′(x)‖22].L_joint\;=\;L_val(T_θ,ψ(x))\;+\; _prox\,L_prox\;+\; _drift\,L_drift, _drift=E [\,\|F_θ(x)-F_θ (x)\|_2^2\, ]. (6) This joint training step improves proximity by shortening the displacement within the features the gate kept open, while preserving sparsity and validity. We visualise the effect in the second and third panels of Figure 2. Inference. Our final counterfactual model is the composed map θ,ψT_θ,ψ, given by the transport ℱθF_θ of Step 3 and the gate ψG_ψ of Step 2. Explaining an instance requires one forward pass of each: we evaluate ℱθF_θ and the binarised gate ψG_ψ, and apply Equation 3. Open categorical features take the arg-max of the predicted endpoint, snapping it back to a vertex of the simplex, while closed features keep the factual value exactly. The black-box model is never called. 4 Experimental evaluation This section presents the setup, datasets, baselines, and metrics of our quantitative evaluation. 4.1 Experimental setup Following the literature on CF evaluation [17, 18], all methods run through a single evaluation pipeline, so that factual selection, black-box training and metric computation are identical across methods. For each dataset we train one shared black box, a single 10001000 hidden layer MLP. Every method explains the same n=1000n=1000 previously unseen instances assigned to the undesired class. A valid CF is not guaranteed for every instance [17], and every metric other than validity is computed over the valid counterfactuals only. For FlowCF we tune the hyperparameters manually and use the resulting configuration for all datasets, with no per-dataset tuning, dS=256×4\d_S=256× 4, dF=128×3d_F=128× 3, K=10K=10, λcat=1.0 _cat=1.0, λval=2.0 _val=2.0, λsparse=0.3 _sparse=0.3, λprox=0.375 _prox=0.375, λdrift=0.05 _drift=0.05, T=0.2T=0.2\, where dSd_S and dFd_F denote the width and depth of the surrogate and flow networks. All experiments use a single 16 GB RTX 3080 Ti GPU. FlowCF completes training and inference in under 35 seconds per dataset, substantially faster than several optimisation-based baselines. 4.2 Datasets We evaluate on six binary classification datasets, listed in Table 2. Four are mixed-type: Adult, Bank marketing, Credit default and Lending Club [5, 7], all standard in the tabular counterfactual literature [17, 18]. Two datasets are continuous-only: MAGIC [5] and HTRU2 [14], with only floating-point features. They are deliberately included to showcase the importance of the exact numerical sparsity FlowCF achieves. Table 2: Dataset characteristics. Dataset Training size #Features (/)(Num/Cat) Classification task Adult 32,561 4 / 8 Income above or below $50K Bank marketing 20,002 7 / 9 Subscription to a term deposit Credit default 27,000 14 / 9 Default on the next payment Lending Club 50,000 8 / 4 Loan fully paid or charged off MAGIC 9,510 10 / 0 Gamma versus hadron air shower HTRU2 8,949 8 / 0 Pulsar versus spurious candidate We further perform a qualitative visual experiment by encoding the CelebA-HQ [9] dataset, using VecGAN++ [2], which factorises the latent space into six continuous, interpretable feature axes (bangs, glasses, hair, young, male, smile). A counterfactual image is a decoded displacement along these axes. For evaluation, a binary image-space black-box classifier scores the celebrity images for a target attribute (e.g. male or young). 4.3 Baselines We compare against six methods, using CARLA reference implementations [18] for the first four and author implementations for the rest, evaluated against the same black box and factual instances. Wachter [24] minimizes distance to the original instance subject to a label flip via input-space gradient descent, perturbing numerical features only. DiCE [16] optimizes in input space with a regularization term to normalize categorical one-hot blocks and project categories via arg-max, using a post-hoc pass to restore unnecessary numerical edits. REVISE [8] optimizes the same objective in a VAE latent space, decoding at each step to measure input-space distance. CCHVAE [19] searches the latent space of a conditional VAE with a growing-sphere procedure until a decoded sample flips the model, avoiding gradients but requiring many queries. TABCF [17] optimizes in the latent space of a transformer-based VAE using a Gumbel-Softmax detokenizer to reconstruct categorical features without post-hoc rounding. DiCoFlex [6] is the closest baseline to our method, using a conditional normalizing flow to generate multiple candidates in one forward pass (amortized), selecting CFs from up to 100 generated candidates per sample based on validity. While DiCoFlex targets sparsity through low-p neighbour selection, it does so only softly via numerical ϵε-sparsity. In contrast, FlowCF achieves exact numerical sparsity: our hard-thresholding gate optimally freezes features during generation, keeping unedited numerical features identical to the factual instance. 4.4 Metrics We evaluate along the desiderata of Section 1, and in line with literature [18], computing every metric directly in the input space so that all methods are scored identically. Validity. The share of explained instances whose counterfactual flips the black box: Validity (↑)=nvaln=1n∑i=1n(f(xi′)=1).Validity ( )\;=\; n_valn\;=\; 1n _i=1^nI (f(x _i)=1 ). Sparsity. The fraction of features changed, reported separately per feature type: Sparsity Cat (↓) Cat ( ) =1nval∑i=1nval‖x0cat−x′cat‖0|C|, = 1n_val _i=1^n_val \|x_0^cat-x \,cat\|_0|C|, Sparsity Num (↓) Num ( ) =1nval∑i=1nval‖x0num−x′num‖0|N|. = 1n_val _i=1^n_val \|x_0^num-x \,num\|_0|N|. Proximity. The distance between the counterfactual and the factual instance, measuring how close the explanation remains to the original input rather than how many features it modifies. We standard-normalize the numerical features and average the absolute displacement over |N||N|: Prox Num (↓)=1nval∑i=1nval‖x0num−x′num‖1|N|.Prox Num ( )\;=\; 1n_val _i=1^n_val \|x_0^num-x \,num \|_1|N|. Here, ∥⋅∥0\|·\|_0 and ∥⋅∥1\|·\|_1 denote the L0L_0 (count) and L1L_1 distance, respectively. 5 Results This section presents our quantitative results on all tabular datasets (Section 5.1), followed by our visual qualitative results on CelebA-HQ (Section 5.2). 5.1 Results for all baselines on all tabular datasets We report the results averaged over all datasets in Table 3, and the per-dataset breakdown in Table 4. Table 3: Results averaged over all datasets. Top 2 counts best or runner-up finishes in Table 4. Validity (%) ↑ Sparsity (%) ↓ Proximity ↓ Top 2 ↑ Cat Num Num Wachter 0.863 - 1.000 1.113 0 DiCE 1.000 0.145 0.893 0.957 15 REVISE 0.717 0.172 0.990 0.819 6 CCHVAE 0.900 0.196 1.000 0.763 6 TABCF 0.926 0.458 0.898 1.164 6 DiCoFlex 1.000 0.411 0.953 0.824 6 FlowCF (us) 0.939 0.394 0.287 0.226 15 On average, FlowCF achieves the best numerical sparsity and the best numerical proximity of all methods: we change 29%29\% of the numerical features where the best baseline changes 89%89\%, and we change them by 0.2260.226 against 0.7630.763, a 70%70\% smaller displacement. We are also essentially the only method that achieves numerical sparsity at all, as every baseline sits between 89%89\% and 100%100\%, changing almost every numerical feature of almost every instance. DiCoFlex is the only competitor that targets numerical sparsity directly, but does so softly, encouraging small changes rather than freezing features, as we do with our gating mechanism. Although we do not outperform on validity and categorical sparsity, FlowCF remains competitive on both. From the per-dataset results of Table 4 we observe that FlowCF is first on numerical sparsity and numerical proximity on all six datasets, with no exceptions. The effect is clearest on the two continuous-only datasets, where every competitor changes every numerical feature of every instance (Sparsity Num =100%=100\%), while FlowCF changes only 19%19\% on MAGIC and 41%41\% on HTRU2. Validity stays above 95%95\% on four of the six datasets, and drops only on Bank marketing and Credit default. Categorical sparsity is likewise comparable to the other amortised and latent-space methods, TABCF and DiCoFlex, on every dataset. Table 4: Detailed results on each dataset. Bold is best, underlined second best. Categorical sparsity does not apply to the continuous-only datasets MAGIC and HTRU2. Validity (%) ↑ Sparsity (%) ↓ Proximity ↓ Validity (%) ↑ Sparsity (%) ↓ Proximity ↓ Cat Num Num Cat Num Num Adult Bank marketing Wachter 0.948 - 1.000 0.778 0.803 - 1.000 1.953 DiCE 1.000 0.011 0.771 2.643 1.000 0.164 0.822 1.347 REVISE 0.879 0.196 0.993 0.965 0.418 0.177 0.945 1.032 CCHVAE 0.784 0.213 1.000 0.685 0.934 0.216 1.000 0.591 TABCF 1.000 0.402 0.513 1.106 1.000 0.400 0.961 2.955 DiCoFlex 1.000 0.457 0.876 1.019 1.000 0.317 0.908 1.081 FlowCF 0.986 0.489 0.250 0.048 0.888 0.399 0.164 0.052 Credit default Lending Club Wachter 0.961 - 1.000 1.654 0.830 - 1.000 0.771 DiCE 1.000 0.177 0.902 0.111 1.000 0.230 0.861 0.558 REVISE 0.221 0.225 1.000 0.226 0.783 0.092 1.000 0.646 CCHVAE 0.901 0.239 1.000 0.505 0.842 0.118 1.000 0.502 TABCF 0.999 0.466 0.999 0.717 1.000 0.565 0.915 0.692 DiCoFlex 1.000 0.437 0.972 0.582 1.000 0.434 0.961 0.874 FlowCF 0.841 0.278 0.214 0.050 0.970 0.410 0.500 0.268 MAGIC HTRU2 Wachter 0.658 1.000 0.536 0.977 1.000 0.987 DiCE 1.000 0.999 0.363 1.000 1.000 0.716 REVISE 1.000 1.000 0.775 0.999 1.000 1.269 CCHVAE 1.000 1.000 0.865 0.940 1.000 1.430 TABCF 0.943 1.000 0.883 0.615 1.000 0.634 DiCoFlex 1.000 1.000 0.593 1.000 1.000 0.791 FlowCF 0.950 0.190 0.358 0.997 0.406 0.580 5.2 Visual qualitative results on CelebA-HQ Figure 3 shows two visual examples from the CelebA-HQ dataset. On the left (in green) is the factual image, followed by the counterfactual images generated by all methods. As described in Section 4.2, each method operates on the six-dimensional VecGAN++ [2] latent features, rather than on the raw image, so a counterfactual is a displacement along the six feature axes, which we report on the right, and the resulting image is obtained via decoding [2]. For the first instance the binary classification target was chosen to be the male attribute and for the second the young attribute. Each face image is annotated with the probability the black-box assigns to the target class, and with the number of axes (features) the method changed. Every method flips the black-box decision on both targets, creating valid counterfactuals. FlowCF (hatched black bar) achieves sparsity by changing a single axis, and that axis is the correct one, identified without any prior knowledge of which feature the classifier depends on for each target setting. DiCE (blue bar) also achieves sparsity, but with worse proximity by making larger changes along that axis. This difference is visually apparent as our generated counterfactuals are more faithful to the original factual images. The bar plot shows what the remaining methods change instead, and the effect is equally visible in the decoded images. On the first instance, TABCF turns the hair from blonde to black, while REVISE and CCHVAE push the young axis and make the subject look older. Both are attributes correlated with the male target in this dataset, where blonde hair is rare among male faces and most males are older. The second instance shows the same effect in the opposite direction, where several methods push the male axis strongly towards the female direction, since youth is correlated with females in this dataset. Figure 3: Counterfactuals generated by all methods for two CelebA-HQ instances, targeting the male and young attributes. The factual image is marked in green, and each image is annotated with the black-box’s probability P of the target class and the number of changed axes |Δaxes|| _axes|. The bar plot gives the per-axis displacement in standard deviations, with our method FlowCF hatched. 6 Conclusion and future work This paper presents FlowCF, a method that frames counterfactual generation as a sparse transport map for mixed-type data. We solve the problem using flow matching between undesired and desired distributions, which gives a straight displacement vector towards the target class. We use this geometry to optimise for the sparsity and proximity desiderata: a gate restricts displacement to a few features per instance, and the flow is tuned through the gate to improve proximity. Our method FlowCF is model agnostic, and across six tabular datasets and six competing methods we produce the sparsest and most proximal numerical edits in one forward pass without querying the black box, and remain comparable on the other desiderata to competitors that assume far greater access (e.g. gradients, logits, etc.) to the model they explain. In future work we want to address further CF desiderata, in particular group and global counterfactuals [10, 20], which explain a set of instances rather than a single one. Our transport suits this well: changing the pairing of Step 1 from one-to-many to many-to-many would learn the flow at the group level, and the resulting displacement vectors would be shared across instances by construction. A second direction is interpretability: distilling the learned map into an explainable policy [3] would state not only what to change but why. References [1] F. Cenacchi (2026) Sparse-by-design cross-modality prediction: l0-gated representations for reliable and efficient learning. arXiv preprint arXiv:2603.26801. Cited by: §3.2. [2] Y. Dalva, H. Pehlivan, O. I. Hatipoglu, C. Moran, and A. Dundar (2023) Image-to-image translation with disentangled latent vectors for face editing. IEEE transactions on pattern analysis and machine intelligence 45 (12), p. 14777–14788. Cited by: §4.2, §5.2. [3] G. De Toni, B. Lepri, and A. Passerini (2023) Synthesizing explainable counterfactual policies for algorithmic recourse with program synthesis. Machine Learning 112 (4), p. 1389–1409. Cited by: §6. [4] T. D. Duong, Q. Li, and G. Xu (2023) Ceflow: a robust and efficient counterfactual explanation framework for tabular data using normalizing flows. In Pacific-Asia Conference on Knowledge Discovery and Data Mining, p. 133–144. Cited by: §2. [5] A. Frank (2010) UCI machine learning repository. http://archive. ics. uci. edu/ml. Cited by: §4.2. [6] O. Furman, U. Movsum-zada, P. Marszałek, M. Zieba, and M. Śmieja (2026) DiCoFlex: model-agnostic diverse counterfactuals with flexible control. Advances in Neural Information Processing Systems 38, p. 71592–71623. Cited by: §1, §2, §2, §3.1, §3, §3, §4.3. [7] J. Jagtiani and C. Lemieux (2019) The roles of alternative data and machine learning in fintech lending: evidence from the lendingclub consumer platform. Financial management 48 (4), p. 1009–1029. Cited by: §4.2. [8] S. Joshi, O. Koyejo, W. Vijitbenjaronk, B. Kim, and J. Ghosh (2019) Towards realistic individual recourse and actionable explanations in black-box decision making systems. arxiv. arXiv preprint arXiv:1907.09615. Cited by: §2, §4.3. [9] T. Karras, T. Aila, S. Laine, and J. Lehtinen (2017) Progressive growing of gans for improved quality, stability, and variation. arXiv preprint arXiv:1710.10196. Cited by: §4.2. [10] D. Ley, S. Mishra, and D. Magazzeni (2023) GLOBE-ce: a translation based approach for global counterfactual explanations. In International conference on machine learning, p. 19315–19342. Cited by: §6. [11] Y. Lipman, R. T. Chen, H. Ben-Hamu, M. Nickel, and M. Le (2022) Flow matching for generative modeling. arXiv preprint arXiv:2210.02747. Cited by: §2, §3.1. [12] X. Liu, C. Gong, and Q. Liu (2022) Flow straight and fast: learning to generate and transfer data with rectified flow. arXiv preprint arXiv:2209.03003. Cited by: §2, §3.1, §3.1. [13] C. Louizos, M. Welling, and D. P. Kingma (2017) Learning sparse neural networks through L_0L\_0 regularization. arXiv preprint arXiv:1712.01312. Cited by: §1, §3.2. [14] R. J. Lyon, B. W. Stappers, S. Cooper, J. M. Brooke, and J. D. Knowles (2016) Fifty years of pulsar candidate selection: from simple filters to a new principled real-time classification approach. Monthly Notices of the Royal Astronomical Society 459 (1), p. 1104–1123. Cited by: §4.2. [15] T. Miller (2019) Explanation in artificial intelligence: insights from the social sciences. Artificial intelligence 267, p. 1–38. Cited by: §1. [16] R. K. Mothilal, A. Sharma, and C. Tan (2020) Explaining machine learning classifiers through diverse counterfactual explanations. In Proceedings of the 2020 conference on fairness, accountability, and transparency, p. 607–617. Cited by: §1, §1, §2, §3.1, §4.3. [17] E. Panagiotou, M. Heurich, T. Landgraf, and E. Ntoutsi (2024) TABCF: counterfactual explanations for tabular data using a transformer-based vae. In Proceedings of the 5th ACM International Conference on AI in Finance, p. 274–282. Cited by: §1, §1, §2, §4.1, §4.2, §4.3. [18] M. Pawelczyk, S. Bielawski, J. v. d. Heuvel, T. Richter, and G. Kasneci (2021) Carla: a python library to benchmark algorithmic recourse and counterfactual explanation algorithms. arXiv preprint arXiv:2108.00783. Cited by: §2, §4.1, §4.2, §4.3, §4.4. [19] M. Pawelczyk, K. Broelemann, and G. Kasneci (2020) Learning model-agnostic counterfactual explanations for tabular data. In Proceedings of the web conference 2020, p. 3126–3132. Cited by: §1, §2, §4.3. [20] K. Rawal and H. Lakkaraju (2020) Beyond individualized recourse: interpretable and interactive summaries of actionable recourses. Advances in Neural Information Processing Systems 33, p. 12187–12198. Cited by: §6. [21] D. Rezende and S. Mohamed (2015) Variational inference with normalizing flows. In International conference on machine learning, p. 1530–1538. Cited by: §2. [22] D. Roos, O. Davis, F. Eijkelboom, M. Bronstein, M. Welling, I. I. Ceylan, L. Ambrogioni, and J. van de Meent (2026) Categorical flow maps. arXiv preprint arXiv:2602.12233. Cited by: §1, §2, §3.1, §3.1. [23] S. Verma, V. Boonsanong, M. Hoang, K. Hines, J. Dickerson, and C. Shah (2024) Counterfactual explanations and algorithmic recourses for machine learning: a review. ACM Computing Surveys 56 (12), p. 1–42. Cited by: §1, §2. [24] S. Wachter, B. Mittelstadt, and C. Russell (2017) Counterfactual explanations without opening the black box: automated decisions and the gdpr. Harv. JL & Tech. 31, p. 841. Cited by: §2, §4.3.