[Paper Review] Model-agnostic and Scalable Counterfactual Explanations via Reinforcement Learning
This paper proposes a model-agnostic, reinforcement learning-based framework for generating sparse, in-distribution counterfactual explanations in a single forward pass, enabling batch processing, target and feature conditioning, and support for both tabular and image data. The method achieves competitive performance with state-of-the-art baselines while eliminating iterative optimization per instance.
Counterfactual instances are a powerful tool to obtain valuable insights into automated decision processes, describing the necessary minimal changes in the input space to alter the prediction towards a desired target. Most previous approaches require a separate, computationally expensive optimization procedure per instance, making them impractical for both large amounts of data and high-dimensional data. Moreover, these methods are often restricted to certain subclasses of machine learning models (e.g. differentiable or tree-based models). In this work, we propose a deep reinforcement learning approach that transforms the optimization procedure into an end-to-end learnable process, allowing us to generate batches of counterfactual instances in a single forward pass. Our experiments on real-world data show that our method i) is model-agnostic (does not assume differentiability), relying only on feedback from model predictions; ii) allows for generating target-conditional counterfactual instances; iii) allows for flexible feature range constraints for numerical and categorical attributes, including the immutability of protected features (e.g. gender, race); iv) is easily extended to other data modalities such as images.
Motivation & Objective
- To address the computational inefficiency of existing counterfactual generation methods that require per-instance iterative optimization.
- To develop a model-agnostic framework that operates solely on model prediction feedback, without requiring gradients or model-specific modifications.
- To enable target-conditional and feature-constrained counterfactual generation, including immutable or range-restricted features (e.g., gender, age, education level).
- To extend the approach to high-dimensional data modalities such as images with minimal architectural changes.
- To achieve fast, scalable counterfactual generation without sacrificing validity or in-distribution quality.
Proposed method
- A deep reinforcement learning agent is trained to generate counterfactual instances by acting on input features to minimize a reward function combining sparsity, validity, and in-distribution objectives.
- The agent uses a conditional vector to guide generation toward a desired target prediction, enabling target-conditional counterfactuals.
- Feature constraints—such as immutable features or value ranges—are enforced via a masked action space during inference, with constrained values sampled during generation.
- The method employs a pre-trained autoencoder to reconstruct and evaluate in-distribution quality, with a consistency loss to stabilize training.
- The training pipeline is entirely model-agnostic, relying only on black-box model predictions for reward feedback, not gradients.
- The framework supports both tabular and image data by adapting the autoencoder and observation space, with minimal architectural changes.
Experimental results
Research questions
- RQ1Can counterfactual generation be made scalable and efficient by replacing iterative optimization with a learnable, end-to-end reinforcement learning process?
- RQ2To what extent can a model-agnostic method generate valid, sparse, and in-distribution counterfactuals without requiring model gradients or architectural assumptions?
- RQ3How well does the method perform under feature constraints such as immutability or value ranges in real-world datasets?
- RQ4Can the framework be extended to high-dimensional data modalities like images with minimal adaptation?
- RQ5How does the method compare in validity, sparsity, and in-distribution quality to existing state-of-the-art counterfactual generation methods?
Key findings
- The method generates counterfactual instances in a single forward pass, eliminating the need for per-instance iterative optimization and enabling batch inference.
- On tabular datasets, the method achieves competitive validity and in-distribution performance compared to state-of-the-art methods like DiCE and MO, with lower MMD scores on overlapping class distributions.
- The method maintains high validity while generating diverse counterfactuals by sampling from constrained conditional vectors, with only a minor drop in performance.
- The framework successfully generates valid, in-distribution counterfactuals for image data (MNIST and CelebA), demonstrating generalization beyond tabular data.
- The approach is robust and stable during training, requiring minimal hyperparameter tuning and showing consistent performance across multiple datasets and model types.
- The method outperforms or matches baselines in key metrics: it achieves high validity, low sparsity, and favorable MMD scores, particularly in scenarios with overlapping class distributions.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.