Source-linked AI summary

Preserving Causal Constraints in Counterfactual Explanations for Machine Learning Classifiers

Divyat Mahajan, Chenhao Tan, Amit Sharma

arXiv:1912.03277v3cs.LGcs.AIstat.ML

TL;DR

Counterfactual explanations need feature changes that are feasible in the real world, not merely consistent with a classifier. The paper uses structural causal models, partial causal knowledge, and user feedback to generate feasible counterfactuals, which outperform methods without causal assumptions or feedback on feasibility measures.

  • Problem

    Counterfactual explanations are useful in critical domains only when their input perturbations are feasible, but statistical constraints may not preserve causal relationships or user-specific feasibility.

  • Method

    The paper adds SCM-derived causal proximity losses, including partial-structure and domain-constraint approximations, and proposes a feedback-trained VAE when feasibility constraints are unavailable.

  • Results

    The proposed methods generate more feasible counterfactual examples than models without causal assumptions or user feedback on Adult-Income and synthetic Bayesian-network datasets.

  • Takeaways & Limitations

    Feasibility is treated as a causal property requiring global structural constraints and, for individual users, additional context- or preference-based constraints.

  • Takeaways & Limitations

    The standard counterfactual objective may change features independently, while the causal proximity approach assumes access to at least partial causal structure or domain constraints.

Abstract

from arXiv · show

To construct interpretable explanations that are consistent with the original ML model, counterfactual examples---showing how the model's output changes with small perturbations to the input---have been proposed. This paper extends the work in counterfactual explanations by addressing the challenge of feasibility of such examples. For explanations of ML models in critical domains such as healthcare and finance, counterfactual examples are useful for an end-user only to the extent that perturbation of feature inputs is feasible in the real world. We formulate the problem of feasibility as preserving causal relationships among input features and present a method that uses (partial) structural causal models to generate actionable counterfactuals. When feasibility constraints cannot be easily expressed, we consider an alternative mechanism where people can label generated CF examples on feasibility: whether it is feasible to intervene and realize the candidate CF example from the original input. To learn from this labelled feasibility data, we propose a modified variational auto encoder loss for generating CF examples that optimizes for feasibility as people interact with its output. Our experiments on Bayesian networks and the widely used ''Adult-Income'' dataset show that our proposed methods can generate counterfactual explanations that better satisfy feasibility constraints than existing methods.. Code repository can be accessed here: \textit{https://github.com/divyat09/cf-feasibility}

1 Introduction

Counterfactual explanations remain useful only when their feature changes are feasible in the real world. The paper frames feasibility causally and proposes SCM-based and feedback-based methods for generating more feasible counterfactuals.

  • Motivation: Counterfactual explanations describe feature perturbations that could change a model’s prediction while remaining consistent with the original model.They can present what-if scenarios such as increasing income to obtain loan approval.
  • The feasibility gap: Feasibility requires counterfactual changes to respect natural laws and interactions between features, which statistical constraints may not capture.Examples include age not decreasing and education changes depending on age.
  • Core contribution: The paper defines feasibility as a causal concept based on constraints entailed by an underlying structural causal model.It distinguishes global feasibility from local feasibility tied to an end-user’s context or preferences.
  • Methods: A causal proximity regularizer replaces standard ℓ1 or ℓ2 proximity terms and can use partial SCMs or domain constraints.The regularizer is designed to preserve causal relationships while generating counterfactuals.
  • Results: Experiments on Adult-Income and synthetic Bayesian networks produce counterfactuals that are more feasible than methods lacking causal assumptions or user feedback.The proposed generative model is also reported to be much faster than existing approaches.

2 A Causal View of Feasibility of CF Explanations

The paper formalizes counterfactual generation as finding a target-class example close to the original input, then identifies why this formulation does not ensure feasibility. It introduces global and local causal feasibility definitions and SCM- or constraint-based proximity losses.

  • Standard counterfactual generation: Counterfactual generation searches for an example close to the original input that changes the classifier’s output to a desired class.The standard objective combines classification loss with a distance term.
  • Limitations: The standard formulation can change input features independently and requires a new optimization problem for every input.The paper addresses these limitations with feasibility definitions and a generative model.
  • Causal foundations: A causal model consists of exogenous variables, endogenous variables, and functions determining endogenous values from model variables and noise.This structure supplies the relationships used to assess feasible changes.
  • Global feasibility: Global feasibility requires target-class validity, satisfaction of causal-model constraints, and exogenous variables within the input domain.Domain constraints can be learned from independently and identically distributed data, whereas causal constraints may require additional information.
  • Local feasibility: Local feasibility requires global feasibility plus user-level constraints arising from context or personal preferences.For example, family constraints may make changing a user’s city infeasible.
  • Causal proximity: The feasibility-compatible distance measures proximity through causal relationships, not only Euclidean distance from the original sample.Exogenous features use standard proximity, while endogenous features are evaluated against their parent-conditioned generating mechanisms.
  • Practical causal constraints: Model-based CF uses known partial causal structure, while approximate variants optimize domain-derived unary and binary constraints when exact mechanisms are unavailable.Unary constraints encode permitted directions of change; binary constraints capture relationships such as monotonicity.

3 Example-Based Generation of Feasible CF explanations

Example-Based CF uses a VAE to generate counterfactuals and then learns feasibility from oracle feedback when complex constraints are difficult to express directly.

  • 3.1 Base VAE generator for CF explanations: Example-Based CF uses an encoder-decoder VAE to generate counterfactuals conditioned on an input and desired class.The encoder maps x and y′ to a latent representation, while the decoder generates xcf from that representation.
  • 3.1 Base VAE generator for CF explanations: The base generator optimizes validity, proximity to the original input, and latent-space regularization through a combined loss.The hinge loss encourages the target class, the distance term preserves proximity, and KL divergence regularizes the latent representation.
  • 3.2 Learning feasibility constraints through user feedback: User feedback supplies binary feasibility labels for generated counterfactuals, enabling the model to learn which outputs resemble feasible examples.An oracle labels each input-counterfactual pair as feasible or infeasible, and the model increases similarity to feasible queries while decreasing similarity to infeasible ones.
  • 3.2 Learning feasibility constraints through user feedback: The algorithm first trains a base VAE and generates query counterfactuals, then fine-tunes the VAE using labelled feasibility queries.The fine-tuning loss includes a hyperparameter λ that trades off validity and proximity against feasibility.
  • 3.2 Learning feasibility constraints through user feedback: Oracle feedback can encode positive individual treatment effects and personalized, user-specific feasibility constraints.Different users can be represented by different oracles that label counterfactuals as feasible or infeasible.

4 Empirical Evaluation

The evaluation tests causal-feasibility methods on Adult and simulated Bayesian-network datasets using validity, proximity, constraint-feasibility, and causal-edge metrics. Methods preserving feasibility outperform CEM on constraint feasibility, with the strongest method varying by dataset and labelled feedback improving Example-Based CF.

  • Evaluation Setup: The evaluation uses Adult and simulated Bayesian-network datasets, with feasibility constraints inferred from causal models or domain knowledge.The classifier uses neural networks, and methods are evaluated under assumed constraints that completely capture counterfactual feasibility.
  • Evaluation Metrics: Constraint Feasibility Score combines two monotonic subconstraints for Simple-BN and Sangiovese, while Adult reports C1 and C2 separately.Causal-Edge Score measures generated-counterfactual log likelihood under the known causal-edge distribution.
  • Feasibility Results: Example-Based CF leads Simple-BN, Model-based CF leads Sangiovese, and Model-approx CF leads Adult on Constraint Feasibility Score.Figure 2 averages the results over 10 runs.
  • Feasibility Results: All methods achieve perfect Target-Class Validity, while feasibility-preserving methods outperform CEM on Constraint-Feasibility Score across all three datasets.CEM scores zero on Simple-BN and around 40% on Sangiovese and Adult.
  • Feasibility Results: CEM’s poor feasibility reflects that observed data likelihood alone does not ensure causal feasibility, as illustrated by Adult’s age constraint.Adult feasibility requires Age to increase despite a dataset correlation between low Age and High Income.
  • Causal-Edge Results: Model-Based CF has the highest Simple-BN Causal-Edge score, all methods are comparable on Sangiovese, and CEM has the lowest score.Example-Based CF can learn constraints from examples despite lacking explicit constraint knowledge.
  • Labelled Feedback: Example-Based CF’s global Constraint-Feasibility Score rises with labelled examples, reaching nearly 80% with 100 labels in Adult.Additional validity and proximity metrics change little as labels increase from 25 to 100.

5 Related Work

Related work develops counterfactual explanations within explainable ML and explores statistical and generative approaches to feasibility. These approaches constrain counterfactuals using data distributions, target-class distributions, intermediate-point likelihoods, mutable-feature specifications, or semantically meaningful spaces.

  • Counterfactual Explanations: Counterfactual-generation methods commonly optimize separately for each input using original features, latent representations, or generative adversarial networks.The paper also builds on foundational work on counterfactuals and explainable ML.
  • Feasibility Approaches: Prior feasibility notions rely on training-distribution adherence, target-class distributions, intermediate-point likelihoods, mutable-feature specifications, or GAN-based semantic restrictions.The related literature also includes criticism that feasibility cannot be learned only from training-data distributions.

6 Conclusion

The paper concludes that counterfactual feasibility is difficult to quantify and presents a generative model plus two methods for modeling causal constraints. Future work will integrate domain knowledge and available data to learn causal constraints.

  • Feasibility in counterfactual explanations is hard to quantify.
  • The work provides a generative model and two methods for modeling causal constraints.
  • Future work will explore integrating domain knowledge and available data to learn causal constraints.

A Supplementary Materials: Theorem 1 Proof

The section derives a variational objective for generating valid, proximate counterfactuals while modeling feasibility through causal relationships among features.

  • The CF generator seeks counterfactuals that remain close to the input and achieve a desired target class.
  • An SCM captures downstream changes caused by perturbing features and supports a causal proximity distance.
  • House rent cannot exceed optionally perturbed income because income is its causal parent in the illustrated SCM.
  • The modified intervention preserves effects from causes on perturbed features, unlike standard interventions that cut incoming edges.
  • The causal distance compares actual feature changes with SCM-predicted changes, using conditional expected values and averaging across inputs.

C.1.1 ML Model Architecture

The experiments use neural-network classifiers with two hidden layers and standardized feature representations across the evaluated datasets.

  • Each classifier has two hidden layers, using ReLU activation on the first hidden layer.
  • Classifiers are trained for 100 epochs with batch size 32, learning rate 10^-3, Adam, and cross-entropy loss.
  • The hidden layers map data-size to hidden-dim and then hidden-dim to the number of classes.
  • The hidden dimension is 10 and the number of classes is 2 for the binary classification tasks.

C.1.2 BaseVAE Architecture

The supplementary setup specifies the BaseVAE architecture, training choices, hyperparameter selection, and metrics used to evaluate counterfactual quality and feasibility.

  • BaseVAE Architecture: The encoder estimates posterior mean and variance, while the decoder reconstructs counterfactuals using neural networks with nonlinear activations.
  • BaseVAE Architecture: Both encoder and decoder are conditioned on the target counterfactual class, and the latent dimension is 10.
  • Training: The methods use SGD with learning rate 10^-3 for 50 epochs, with dataset-specific batch sizes of 64, 512, and 2048.
  • Hyperparameter tuning: Hyperparameters are selected for maximum feasibility while maintaining more than 90% target-class validity and a minimum proximity threshold τ.
  • Evaluation Metrics: Evaluation includes target-class validity, continuous and categorical proximity, constraint feasibility, causal-edge score, and interpretability score.
  • Constraint Modelling: Model-approx CF represents Adult education levels with ranked continuous scores so hinge loss penalizes counterfactuals that decrease education.

C.2 Evaluation Results on Additional Metrics

The additional evaluations show that proposed methods preserve feasibility while retaining strong validity, with trade-offs involving proximity and interpretability; generative methods are also computationally efficient.

  • Validity: All methods achieve near-perfect target-class validity across datasets.
  • Continuous Proximity: Higher feasibility can reduce continuous proximity on Sangiovese, where Model-based CF, Model-approx CF, and Example-Based CF underperform CEM.
  • Categorical Proximity: CEM achieves higher categorical proximity, while its counterfactuals preserve fewer causal constraints than Model-approx CF and Example-Based CF.
  • Interpretability: Model-based CF and Model-approx CF consistently outperform CEM on IM1, whose lower score indicates better interpretability.
  • Computational Efficiency: Example-Based CF requires initial training but has negligible generation time for new inputs, making it faster per example as the number of inputs increases.
  • Labelled Feasibility Feedback: Increasing labelled feasibility examples from 25 to 100 substantially improves feasibility while leaving validity and proximity metrics largely unchanged.

E.1 Results

The experiments evaluate counterfactual quality on MNIST using interpretability metrics and compare generation speed. BaseVAE reports stronger IM1 and IM2 scores, while its generation time is substantially lower under repeated use.

  • Adult dataset: Figure 7 tracks target-class validity, continuous proximity, and categorical proximity as Example-Based CF receives more labelled Adult examples.
  • Generation time: After about 40 inputs, Example-Based CF generates counterfactuals faster than the baseline CEM method.
  • MNIST results: BaseVAE achieves better IM1 and IM2 scores than approaches using autoencoder or prototype losses.The comparison uses the same ML model and AutoEncoder architecture as prior work, with BaseVAE results averaged over 10 runs.
  • Metric interpretation: IM2 performance depends strongly on the counterfactual norm in its denominator, limiting direct interpretation of the metric.The reported improvement may reflect either a smaller reconstruction-error difference or larger-norm counterfactuals.
  • Generation time: BaseVAE generation time is an order of magnitude lower than other approaches, despite a fixed training time of 172.81 ± 3.97 seconds.This favors deployments that train once and generate counterfactuals for multiple inputs.

E.2.1 ML Model Architecture

The explained ML model is a convolutional classifier trained with Adam and cross-entropy loss. Its architecture uses a 256-unit hidden layer with dropout and ReLU, followed by a 10-unit softmax output.

  • Training setup: The classifier is trained for 50 epochs with batch size 32, learning rate 10^-4, Adam, and cross-entropy loss.The dataset split is 80% training, 10% validation, and 10% test.
  • Network architecture: The classifier architecture includes Hidden Layer 1 with 256 units, dropout 0.5, and ReLU activation.
  • Network architecture: Hidden Layer 2 has 10 units and uses a softmax activation for the model output.
  • Encoder architecture: The BaseVAE encoder estimates posterior mean and variance using two networks with shared architecture, adding sigmoid activation to the variance network.The sigmoid ensures the estimated variance is positive.
  • Encoder architecture: The encoder concatenates the output of submodel M1 with the counterfactual target class before passing the result to submodel M2.The embedding size is 10, and the convoluted size is 22 ∗22.
Loading 1912.03277v3…