Counterfactual Reasoning for Fair Clinical Risk Prediction

Stephen Pfohl, Tony Duan, Daisy Yi Ding, Nigam H. Shah

Introduction

Machine learning models are increasingly deployed in clinical settings to predict patient outcomes such as mortality and length of stay. However, these models are often trained on Electronic Health Record (EHR) data that reflects historical biases and systemic inequalities. While traditional fairness metrics focus on group-level statistics (e.g., ensuring equal error rates across demographic groups), these can overlook significant disparities at the individual level. This research introduces a framework for Individual Equalized Counterfactual Odds, aiming to ensure that clinical AI models treat individual patients fairly by considering "counterfactual" scenarios—asking how a prediction might change if a patient's sensitive attributes, such as race or gender, were different.

Methodology

The core of this approach is the combination of Equalized Odds and Counterfactual Fairness. The proposed criterion requires that a model’s prediction for an individual remains consistent with their counterfactual "twin" only if the actual clinical outcome would have remained the same in both scenarios. This ensures that the model only ignores sensitive attributes when they do not causally contribute to the outcome.

To operationalize this, the researchers utilized a Causal Effect Variational Autoencoder (CE-VAE). The CE-VAE learns latent factors ($U$) that represent a patient's underlying health state, separate from their sensitive attributes ($A$). By manipulating $A$ while keeping $U$ constant, the model generates synthetic counterfactual twins.

Causal graph illustrating the relationships between sensitive attributes (A), observed features (X), latent variables (U), and the outcome (Y).

The training process incorporates Counterfactual Logit Pairing (CLP). This adds a penalty to the loss function whenever the model's predictions for a factual patient and their counterfactual twin diverge (provided the outcome $Y$ is identical). This forces the network to rely on features that are invariant to sensitive attributes.

Data and Tasks

The framework was evaluated using data from the Stanford Medicine Research Data Repository, comprising approximately 130,000 unique inpatient admissions from 2010 to 2018. The models were tasked with predicting two primary outcomes:

  1. Inpatient Mortality
  2. Prolonged Length of Stay (7+ days)

The features included over 368,000 clinical concepts (diagnoses, medications, lab results), while race, ethnicity, gender, and age were treated as sensitive attributes.

Results

The study demonstrates that individual-level bias can be significantly mitigated with minimal impact on predictive performance.

  • Bias Mitigation: In the "Length of Stay" task, increasing the fairness penalty ($\lambda_{CLP}$) successfully reduced the mean paired difference between factual and counterfactual predictions toward zero.
  • Performance Stability: For length-of-stay predictions, the model achieved near-perfect individual counterfactual fairness with only a slight decrease in AUC-ROC (from ~0.85 to ~0.84).
  • Mortality Challenges: The trade-off was more pronounced for mortality prediction. As mortality is a relatively rare event, the model faced greater difficulty maintaining high accuracy while satisfying strict fairness constraints.

Discussion and Limitations

A key insight of this work is the "outcome-invariant" nuance: if a sensitive attribute truly causes a different health outcome due to biological or systemic factors, the model should reflect that. By conditioning on the outcome, the researchers avoid penalizing "justified" differences in risk.

However, the effectiveness of this approach relies heavily on the accuracy of the assumed Causal Graph. If the underlying structure of how variables interact is specified incorrectly, the resulting fairness may be illusory. Furthermore, mathematical fairness is only one component of clinical equity; the deployment of these models must be accompanied by careful consideration of the broader clinical policies they inform. Future research will focus on sensitivity analysis to test the robustness of these causal assumptions.

Summary updated

BibTeX
@inproceedings{pfohl2019counterfactual,
  author = {Stephen Pfohl and Tony Duan and Daisy Yi Ding and Nigam H. Shah},
  title = {{Counterfactual Reasoning for Fair Clinical Risk Prediction}},
  booktitle = {MLHC},
  year = {2019},
  url = {https://openreview.net/forum?id=qmgO_hYNLuF},
}
Figure