arXiv:2609.10778cs.LGSep 2026

Manuscript Offprint

arXiv:2609.10778

Counterfactual Marginalisation: Framework for Evaluating Robustness to Nuisance Variables

Yasin Ibrahim, Hermione Warr, Robin J. Evans, Konstantinos Kamnitsas

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Yasin Ibrahim 1^{1}, Hermione Warr 1^{1}, Robin J. Evans 2^{2}, and Konstantinos Kamnitsas 1^{1}

1^{1} Department of Engineering Science, University of Oxford, Oxford, UK

{firstname.lastname}@eng.ox.ac.uk

2^{2} Department of Statistics, University of Oxford, Oxford, UK

Abstract. Machine learning models can achieve strong test performance while relying on demographic or acquisition-related shortcuts. We propose counterfactual (CF) marginalisation as a test-time evaluation procedure for assessing robustness of classification models to such variables. Given a CF image generator, we intervene on nuisance parent variables such as age or sex, generate CF versions of each test image, and average predictions over a target intervention distribution. This produces intervention-aware predictions that marginalise demographic effects while preserving patient-specific latent information. We use these predictions to define metrics for CF risk, calibration, stability and worst-case sensitivity. We demonstrate this framework's utility for quantitative robustness evaluation.

Keywords: Model Evaluation · Generative Models · Counterfactuals.

1 Introduction

Deep learning models have achieved strong performance in medical image analysis, but high accuracy on held-out data does not guarantee clinically appropriate decision rules. In practice, models may rely on demographic, acquisition-related, or site-specific shortcuts rather than pathology-relevant evidence [12]. Causal modelling provides a principled way to study these issues by asking, for example, how a prediction would change if a patient's demographic attributes were intervened upon while other patient-specific factors were held fixed [21]. Recent work has used Structural Causal Model (SCM)-based generative models to produce medical image CFs for explanation, auditing and augmentation [20, 22, 4, 9]. Here, instead, we use CFs at test time to define evaluation metrics for medical image classifiers. Given an SCM-based CF generator, we intervene on nuisance parent variables such as age or sex, and generate CF versions of each test image [9]. We then develop a range of metrics that use these CFs to measure the sensitivity, stability and performance of a predictor. This setting is closely related to work on fairness and robustness in medical imaging [12, 16], where prior studies have shown that models can exhibit demographic disparities and can recover sensitive attributes directly from images [28, 2]. Our contributions are as follows:

Y. Ibrahim et al.

– We formulate counterfactual marginalisation over variables as a test-time evaluation procedure for medical image classifiers.

– We introduce intervention-aware evaluation metrics, including counterfactual marginal risk, interventional expected risk, counterfactual stability, and worst-case counterfactual risk. This extends counterfactuals from explanation and augmentation to principled robustness evaluation.

– We demonstrate that our approach exposes biases in predictors better than traditional metrics and also enables measuring sensitivity to nuisance variables without requiring disease labels.

References (27)