Skip to main content
QUICK REVIEW

[Paper Review] MACE: An Efficient Model-Agnostic Framework for Counterfactual Explanation

Wenzhuo Yang, Jia Li|arXiv (Cornell University)|May 31, 2022
Explainable Artificial Intelligence (XAI)Computer Science7 citations
TL;DR

MACE is a model-agnostic framework for counterfactual explanation that uses reinforcement learning for feature optimization and gradientless descent for proximity improvement, enabling efficient, high-quality counterfactual generation on non-differentiable models and categorical features with many values. It achieves faster inference and better sparsity and proximity than prior methods like DiCE and CERTIFAI.

ABSTRACT

Counterfactual explanation is an important Explainable AI technique to explain machine learning predictions. Despite being studied actively, existing optimization-based methods often assume that the underlying machine-learning model is differentiable and treat categorical attributes as continuous ones, which restricts their real-world applications when categorical attributes have many different values or the model is non-differentiable. To make counterfactual explanation suitable for real-world applications, we propose a novel framework of Model-Agnostic Counterfactual Explanation (MACE), which adopts a newly designed pipeline that can efficiently handle non-differentiable machine-learning models on a large number of feature values. in our MACE approach, we propose a novel RL-based method for finding good counterfactual examples and a gradient-less descent method for improving proximity. Experiments on public datasets validate the effectiveness with better validity, sparsity and proximity.

Motivation & Objective

  • To address the limitations of existing optimization-based counterfactual methods that assume differentiable models and treat categorical features as continuous, which hinders real-world deployment.
  • To enable efficient counterfactual generation on non-differentiable models such as XGBoost and models with high-cardinality categorical features.
  • To improve counterfactual quality by optimizing for validity, sparsity, and proximity while maintaining computational efficiency.
  • To develop a practical, easy-to-use toolkit for real-world adoption of counterfactual explanations in production environments.

Proposed method

  • MACE employs a four-stage pipeline: counterfactual feature selection, counterfactual feature optimization via a REINFORCE-based RL agent, counterfactual example selection, and continuous feature fine-tuning.
  • The RL-based optimization method learns a policy to select minimal, actionable feature changes that yield the desired model output.
  • A gradientless descent method (MACE-GLD) is used to refine continuous features and improve proximity to the original instance.
  • Categorical features are handled without one-hot encoding, avoiding the introduction of new continuous variables and preserving sparsity.
  • The framework is model-agnostic and supports both tabular and time-series data by substituting relevant time series features in the optimization process.
  • The method avoids gradient computation on the underlying model, enabling application to non-differentiable models like XGBoost.

Experimental results

Research questions

  • RQ1Can a model-agnostic counterfactual explanation framework efficiently handle non-differentiable models such as XGBoost?
  • RQ2How can counterfactual explanations be generated efficiently when categorical features have high cardinality without one-hot encoding?
  • RQ3Can reinforcement learning be effectively used to optimize counterfactual feature selection while maintaining sparsity and proximity?
  • RQ4How does the proposed gradientless descent method compare to gradient-based methods in improving proximity for continuous features?
  • RQ5Can the framework scale to high-dimensional time-series data while maintaining efficiency and counterfactual quality?

Key findings

  • MACE-RL and MACE-GLD achieved significantly faster inference times—over 10 times faster than Greedy on time-series data—while maintaining comparable sparsity.
  • On the Adult and Titanic datasets, MACE generated counterfactual examples with higher validity, better sparsity, and improved proximity compared to DiCE and CERTIFAI.
  • The framework reduced running time per query to under 2 seconds on most datasets, making it practical for real-world deployment.
  • For time-series classification on the Taxonomist dataset, MACE-GLD and MACE-RL achieved sparsity scores within 1–2 units of Greedy but in 1.8 seconds per query, versus 19–32 seconds for Greedy.
  • The RL-based policy learned actionable, plausible counterfactuals such as 'increased education' or 'higher income' leading to better outcomes, reflecting real-world correlations in the data.
  • The toolkit developed based on MACE enables practical integration into internal AI workflows, demonstrating real-world applicability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.