Learning Counterfactually Fair Models via Improved Generation with Neural Causal Models

Krishn Vishwas Kher, Aditya Varun V, Shantanu Das, Saketha Nath JagarlapudiarXiv 2025 · DOI

Abstract

Counterfactual fairness (CF) ensures that a model's prediction for an individual remains unchanged across hypothetical scenarios where sensitive attributes differ. However, practical implementation is hindered by unfaithful counterfactual generation and weak fairness metrics. We propose a framework using Neural Causal Models (NCMs) with a kernel-based loss to enforce $L_3$ consistency and a Maximum Mean Discrepancy (MMD) regularizer for distribution-aware fairness. Our approach demonstrates superior performance-fairness trade-offs on synthetic and real-world datasets.

Introduction

Machine learning models often perpetuate biases found in training data. Counterfactual fairness offers a robust solution by requiring that a prediction $h(x)$ for an individual with sensitive attribute $A=a$ be the same as if $A=a'$, holding all other causal factors constant.

Causal graph illustrating the relationships between sensitive attributes (A), unobserved confounders (U), features (X), and outcomes (Y).

Implementing CF requires addressing two primary challenges:

  1. Faithful Generation: Accurately "abducting" unobserved confounders ($U$) to generate counterfactuals that adhere to the causal graph, achieving what is known as $L_3$ consistency.
  2. Strong Fairness Metrics: Moving beyond simple mean-matching proxies (like MSE) which fail to capture differences in the tails of distributions.

Methodology

The proposed framework consists of a two-stage approach to build a fair predictor:

1. Improved Counterfactual Generation

We utilize Neural Causal Models (NCMs) where neural networks parameterize causal mechanisms. To ensure $L_3$ consistency, we introduce:

  • Kernel Least Squares for Abduction: A non-parametric approach to estimate the posterior of $U$ given evidence, avoiding restrictive invertibility assumptions.
  • Explicit $L_3$ Loss ($\ell_{ctf}$): A novel loss term that acts as a causal guardrail, ensuring generated counterfactuals remain consistent with the model's marginal distributions even under finite sample errors.

2. Distribution-Aware Fairness Finetuning

To train the predictor $h_\phi$, we replace weak proxies with a Maximum Mean Discrepancy (MMD) regularizer ($\ell_{fair}$). MMD measures the distance between entire probability distributions in a Reproducing Kernel Hilbert Space (RKHS). By minimizing MMD, we ensure that the full distributions of factual and counterfactual predictions are identical, satisfying the formal definition of CF.

Experimental Results

The model was evaluated on a Synthetic Insurance Dataset and the Crimes Dataset, a high-dimensional real-world benchmark.

Trade-off between predictive performance (Explained Variance) and fairness (MMD) across different regularization strengths.

Key findings include:

  • Superior Trade-offs: Our method achieves a higher Area Under the Curve (AUC) in performance-fairness plots compared to state-of-the-art baselines like [Grari et al., 2022].
  • The "Mean" Trap: We empirically confirm that matching means (MSE) is insufficient for fairness; MMD provides a more rigorous guarantee by aligning entire distributions.
  • Ablation Success: The inclusion of the $\ell_{ctf}$ loss significantly improves the fidelity of the generated counterfactual samples, making them more representative of the true causal world.

Conclusion

This work advances counterfactual fairness by integrating NCMs with kernel-based consistency losses and distribution-aware regularization. While future work should explore broader categorical data and the computational scaling of MMD, this framework provides a mathematically grounded path toward truly fair automated decision-making.

Summary updated

BibTeX
@misc{kher2025learning,
  author = {Krishn Vishwas Kher and Aditya Varun V and Shantanu Das and Saketha Nath Jagarlapudi},
  title = {{Learning Counterfactually Fair Models via Improved Generation with Neural Causal Models}},
  year = {2025},
  eprint = {2502.12796},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.12796},
}
Figure