DiCoFlex: Model-agnostic diverse counterfactuals with flexible control

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

Read DiCoFlex: Model-agnostic diverse counterfactuals with flexible control by Oleksii Furman, Ulvi Movsum-zada, Patryk Marszalek, Maciej Zięba, Marek Śmieja (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2505-23700.txt.

Introduction

Oleksii Furman and co-authors present DiCoFlex, a generator of counterfactual explanations for machine learning decisions, in a 2025 paper. A counterfactual shows the smallest change that would flip a model's answer, such as what a loan applicant could alter to be approved. Older generators need constant access to the model, grind through slow optimization for each case, and cannot accept new user constraints without retraining.

DiCoFlex learns from labeled data alone, using a flow-based generative model, and produces many varied counterfactuals in a single pass. Users can dial constraints like sparsity or which features may change at run time. On standard benchmarks it beat rival methods on validity, diversity, closeness to the original case, and respect for the constraints. The authors aim it at sensitive decision settings.

Catalog record

CREATOROleksii Furman, Ulvi Movsum-zada, Patryk Marszalek, Maciej Zięba, Marek Śmieja
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE75 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2505-23700

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

DiCoFlex: Model-agnostic diverse counterfactuals with flexible control Oleksii Furman, Ulvi Movsum-zada, Patryk Marszalek, Maciej Zięba, Marek Śmieja 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. 1 Introduction Counterfactual explanations (CFs) have become an integral part of explainable artificial intelligence (XAI) by providing human-interpretable insights into complex machine learning models [ 14 ] . CFs answer critical "what-if" questions by suggesting minimal and meaningful changes to input data that could alter the outcome of a predictive model [ 44 ] . Such explanations have valuable applications across sensitive domains, including finance, healthcare, and legal decisions, where understanding the predictions of the model and potential alternative outcomes is paramount [ 48 , 11 ] . (a) Unconstrained (b) Sparsity constraints (c) Actionability constraints 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. According to Guidotti [14] , an ideal counterfactual explanation should satisfy several key properties. First, it must demonstrate validity by successfully changing the model’s prediction. Second, it should maintain proximity by remaining as close as possible to the original input, minimizing the amount of change. Third, it should exhibit sparsity by modifying only the smallest possible set of features. Fourth, it must ensure plausibility by remaining within the realm of realistic, observed data. Finally, it should guarantee actionability by suggesting changes that are feasible for the stakeholder to implement. In practice, however, these criteria often conflict. For instance, the smallest possible change may result in samples outside the realistic data distribution. To address this, Mothilal et al. [22] and Laugel et al. [20] argue that, rather than producing a single “best” counterfactual explanation, a diverse set of CFs should be generated. Presenting multiple realistic alternatives allows users to see different ways to achieve the desired outcome, explore trade-offs between minimal change and realism, and gain deeper insight into the model’s decision boundaries. This diversity, in turn, empowers stakeholders to make more informed, feasible decisions. Current approaches to diverse counterfactual generation face significant limitations. Optimization-based methods like DiCE [ 22 ] and multi-objective frameworks [ 7 ] incorporate diversity directly into their cost functions but require solving complex, separate optimizations for each explanation. This results in high computational costs and latency, making them impractical for real-time applications. Meanwhile, generative approaches such as those by Pawelczyk et al. [28] and Panagiotou et al. [25] offer efficiency improvements but frequently produce redundant explanations, require access to model gradients, and lack flexibility for adapting to user-defined constraints without extensive retraining. To address these limitations, we introduce DiCoFlex, a novel conditional generative framework capable of generating multiple diverse CFs in a single forward pass. DiCoFlex is model-agnostic and does not require constant access to the underlying predictive model at any stage, relying solely on a dataset labeled by a classification model. Our approach leverages conditional normalizing flows to learn the distribution of counterfactual explanations that inherently satisfy user-specified constraints. In contrast to existing methods, DiCoFlex incorporates customizable constraints such as sparsity and actionability directly at inference time, eliminating the need for retraining when constraints change. During inference, DiCoFlex achieves computational efficiency by generating multiple diverse CFs through a single forward pass, thus avoiding the computational burden inherent in methods that require separate optimization procedures for each counterfactual. As illustrated in Figure 1 , our method can operate under different constraints. DiCoFlex generates diverse and plausible counterfactual explanations without any restrictions imposed on sparsity or actionability (as shown in Figure 1(a) ). Sparsity, controlled by the user-defined exponent p in L_{p} norm, ensures minimal modifications in input features (as demonstrated in Figure 1(b) ), while actionability constraints allow users to specify immutable features through a mask, guiding the generation towards practically feasible explanations (shown in Figure 1(c) ). These parameters can be dynamically adjusted at inference time, providing unprecedented flexibility in generating counterfactual explanations that satisfy domain-specific constraints while maintaining a balance between diversity and validity without requiring explicit diversity penalties. The main contributions of our work are summarized as follows: • We propose DiCoFlex, a classifier-agnostic, conditional generative framework that generates multiple counterfactuals efficiently in a single forward pass, without the need for model retraining or optimization per query instance. • Our method enables real-time customization of constraints including sparsity and actionability, providing practical, user-centric control over counterfactual generation. • We extensively evaluate DiCoFlex on benchmark datasets, demonstrating superior performance in terms of validity, proximity, diversity, and constraint compliance compared to existing state-of-the-art approaches. 2 Related Work Counterfactual explanations (CFs) have become integral to explainable AI by providing intuitive alternatives that elucidate model decisions [ 44 ] . Optimization-based methods formulate CF generation as minimizing distance between instances while ensuring prediction changes, using implementations including gradient-based approaches [ 44 ] , integer programming [ 41 ] , genetic algorithms [ 7 ] , and satisfiability problems [ 18 ] . Instance-based methods like FACE [ 29 ] select examples yielding desired predictions from existing data, while CBCE [ 19 ] merges features from paired contrasting instances. Model-specific approaches such as decision tree methods [ 13 , 38 ] leverage model structure by traversing alternative paths. Diverse Counterfactual Explanations Generating multiple diverse counterfactuals offers significant advantages over single explanations by providing alternative paths for recourse and better illustrating decision boundaries [ 20 , 22 ] . DiCE [ 22 ] directly incorporates diversity into its loss function but requires separate optimization for each explanation, increasing computational costs. Other approaches achieve diversity through various strategies: DiVE [ 33 ] employs determinantal point processes, while methods like [ 39 , 35 , 5 ] partition the feature space. Multi-objective approaches like MOC [ 7 ] generate solutions representing different trade-offs between properties such as proximity and sparsity, while CARE [ 30 ] and OrdCE [ 17 ] incorporate user preferences into the generation process. Generative Models for Counterfactuals Generative models have gained popularity for counterfactual generation due to their ability to produce more plausible explanations that remain on the data manifold. VAE-based approaches include ReViSE [ 16 ] , C-CHVAE [ 28 ] , CLUE [ 2 ] , and CRUDS [ 10 ] , which learn latent representations of

Read the complete text