Abstract
Counterfactual explanation is one branch of interpretable machine learning that produces a perturbation sample to change the model's original decision. The generated samples can act as a recommendation for end-users to achieve their desired outputs. Most of the current counterfactual explanation approaches are the gradient-based method, which can only optimize the differentiable loss functions with continuous variables. Accordingly, the gradient-free methods are proposed to handle the categorical variables, which however have several major limitations: 1) causal relationships among features are typically ignored when generating the counterfactuals, possibly resulting in impractical guidelines for decision-makers; 2) the counterfactual explanation algorithm requires a great deal of effort into parameter tuning for determining the optimal weight for each loss functions which must be conducted repeatedly for different datasets and settings. In this work, to address the above limitations, we propose a prototype-based counterfactual explanation framework (ProCE). ProCE is capable of preserving the causal relationship underlying the features of the counterfactual data. In addition, we design a novel gradient-free optimization based on the multi-objective genetic algorithm that generates the counterfactual explanations for the mixed-type of continuous and categorical features. Numerical experiments demonstrate that our method compares favorably with state-of-the-art methods and therefore is applicable to existing prediction models.
Introduction
Counterfactual Explanations (CEs) are a cornerstone of interpretable machine learning, providing "what-if" scenarios to help users understand model decisions. For instance, if a loan is rejected, a CE might suggest: "If your income were $10,000 higher, you would have been approved." However, current methods often produce infeasible advice, such as suggesting a user decrease their age. This highlights three major hurdles in the field:
- Causal Neglect: Algorithms often treat features as independent, ignoring that changing one (e.g., Education Level) necessitates changing another (e.g., Job Title). This leads to "infeasible" samples.
- Categorical Complexity: Gradient-based methods struggle with non-continuous data like marital status or zip codes.
- Hyperparameter Sensitivity: Balancing multiple objectives (proximity to original data vs. changing the outcome) typically requires manual weight tuning, which is inefficient and dataset-dependent.
To address these, we introduce ProCE (Prototype-based Counterfactual Explanation), a framework designed to ensure explanations are both mathematically sound and practically actionable.
Methodology
The ProCE framework integrates several innovative components to generate high-quality counterfactuals by respecting real-world constraints.
Causality-Preserving Loss
ProCE integrates Structural Causal Models (SCM) to ensure feasibility. By using the LiNGAM (Linear Non-Gaussian Acyclic Model) algorithm, the framework discovers the underlying causal graph of the data. This ensures that if feature A causes feature B, any suggested change in A correctly propagates to B, preventing "impossible" recommendations.
Prototype-Guided Search
Rather than searching the entire feature space blindly, ProCE utilizes an auto-encoder to map data into a latent representation. It then leverages "class prototypes"—the average representation of successful candidates in the target class—to guide the search toward realistic outcomes. This latent space approach allows the model to capture relationships between categorical variables more effectively than simple numerical encoding.
Multi-Objective Optimization
Instead of a single weighted loss function, ProCE employs the NSGA-II genetic algorithm. This allows the simultaneous optimization of prediction accuracy, proximity, and causality. By finding a "Pareto front" of optimal trade-offs, ProCE eliminates the need for manual hyperparameter tuning and provides a variety of diverse, high-quality explanations.
Experimental Evaluation
The framework was evaluated on four datasets:
- Simple-BN: A synthetic set with clear causal links.
- Sangiovese: An agronomic dataset regarding the quality of Tuscan grapes.
- Adult: A real-world income prediction dataset with mixed feature types.
- Law: A dataset for predicting law school program acceptance.
For real-world data, "sanity check" constraints were enforced, such as ensuring age only increases in counterfactual scenarios.
Results and Discussion
ProCE was compared against standard methods like Wachter and DiCE. Key findings include:
- Causal Validity: ProCE achieved a 95.64% Causal-constraint validity (%Ccv) on the Adult dataset, significantly outperforming the standard Wachter method (~70%).
- Interpretability: Metrics IM1 and IM2, which measure how well a counterfactual fits the target class distribution, showed that ProCE consistently produces more "natural" samples than baselines.
- Efficiency: Despite using a genetic algorithm, ProCE was significantly faster than other non-gradient methods like FACE or CERTIFAI on the Adult dataset, thanks to prototype guidance narrowing the search space.
Conclusion
ProCE represents a significant step toward realistic AI explanations by prioritizing causality and eliminating the "weighting game" of optimization. While it currently relies on reliable causal models, future work will explore handling imperfect causal graphs and utilizing Reinforcement Learning for even greater efficiency in massive datasets.
Summary updated