NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Separating Prevalence from Acquisition Shift in Gradient-Based Performance Estimates for Medical Imaging

A deployed medical classifier can lose accuracy at a new hospital for two quite different reasons. The patients may be different, so the mix of diseases changes; this is called prevalence shift. Or the images may be different because of another scanner, stain batch or protocol; this is called covariate or acquisition shift. Hospitals usually have no labels at deployment, so they need a label-free estimate of how well the model is doing. The most promising recent estimators look inside the network at the gradients it would compute on its own pseudo-labels, rather than at its output confidence. These estimators fold both causes of shift into a single number. That matters because prevalence shift is the case where confidence-based estimators are known to break down, and real hospital transfers almost always mix both causes.

We propose to split the estimate into two parts. The first is a prevalence part that can be computed exactly once target disease rates are estimated. The second is a residual part, which we predict from class-conditional gradient scores of the frozen deployed model. These scores are computed in memory and never overwrite the validated weights. In two sentences: under pure prevalence shift, a model's accuracy follows directly from the new class mix and its per-class source accuracy, so internal signals should be spent only on predicting how much each class's accuracy drops from acquisition change. We test whether per-class gradient norms predict that drop better than per-class confidence, especially on the overconfident medical inputs where confidence is known to mislead.

Core Claim

Write $\pi_t(y)$ for the target prevalence of class $y$, $a_s(y)$ for the model's accuracy on class $y$ measured on labeled source validation data, and $\Delta_y$ for the fractional drop in class-$y$ accuracy caused by acquisition shift. Target accuracy then decomposes exactly as

$$\mathrm{acc}_t = \sum_y \pi_t(y)\, a_s(y)\,\bigl(1 - \Delta_y\bigr).$$

The same decomposition gives sensitivity and specificity directly in the binary case. Existing label-free estimators predict $\mathrm{acc}_t$ as a whole. Our claim is that estimating $\pi_t$ and each $\Delta_y$ separately is more accurate under the mixed shifts that real hospital transfers produce. We further claim that a class-conditional gradient score is a better predictor of $\Delta_y$ than class-conditional confidence. Concretely, the score is the final-layer gradient norm computed only over target samples pseudo-labeled as $y$, normalised by its source value.

The first claim is mostly bookkeeping, and the oracle-prevalence experiment below checks it. The second claim is the empirical bet. Neither has been tested.

Relation to Prior Work

Three papers supply the core mechanism. Predicting Out-of-Distribution Error with the Projection Norm fine-tunes a copy of the model on its own pseudo-labels for the target data and uses the resulting weight displacement as an error proxy. Online GNN Evaluation Under Test-time Graph Distribution Shifts does the same for graph networks, training a new model from scratch on pseudo-labeled test graphs. Leveraging Gradients for Unsupervised Accuracy Estimation under Distribution Shift replaces retraining with a single backward pass. It assigns random labels to low-confidence samples and takes the $L_{0.3}$-norm of the final-layer gradient. It reports results on Camelyon17 among 11 benchmarks. The file contains no isolated Camelyon17 number for it.

We reuse this one-pass gradient score. We differ in what we use it for. All three methods regress a single pooled score onto total accuracy. None of them examines what prevalence shift alone does to that score. A pooled gradient norm plausibly moves with the class mix even when nothing about the images has changed, because classes contribute gradients of different size. Our method removes that confound by construction.

Two medical papers motivate the split. Label-free estimation of clinically relevant performance metrics under distribution shifts extends confidence-based estimators to full confusion matrices on chest X-rays. Its authors report systematic failure of every method under simulated prevalence shift. Automatic Dataset Shift Identification to Support Safe Deployment of Medical Imaging AI detects and classifies shifts as prevalence, covariate or mixed. It uses output-distribution tests, tests on features from an external self-supervised encoder, and a prevalence estimator (CPMCN) followed by resampling. It returns hypothesis-test decisions, not performance estimates.

We borrow its resampling-by-estimated-prevalence idea. We go further by turning the decomposition into a quantitative estimate of accuracy, sensitivity and specificity. We also use the deployed model's own gradients instead of a second foundation model.

Two papers constrain the design. OpenMIBOOD: Open Medical Imaging Benchmarks for Out-Of-Distribution Detection documents extreme overconfidence on shifted medical inputs, including a 94% confident misclassification of a novel robotic arm. That is a direct threat to the confidence threshold that decides which samples receive random labels in the gradient score. Estimating Test Performance for AI Medical Devices under Distribution Shift with Conformal Prediction argues that regulated devices must be treated as frozen. Our gradients are computed in memory, and the deployed checkpoint is never updated.

Research Program

The estimator has three steps.

The first step estimates target prevalence $\hat\pi_t$ from the frozen model's predictions on the unlabeled target batch. We use confusion-matrix inversion against the source validation confusion matrix, with CPMCN as an alternative. This estimate is itself biased under covariate shift, because the confusion matrix changes. We will therefore also test a two-pass variant. In that variant, the class-conditional accuracy drops predicted in the third step are used to correct the confusion matrix, and the prevalence is then re-estimated.

The second step computes, for each pseudo-class $y$, the final-layer gradient score restricted to target samples predicted as $y$. We compare it with the same quantity on source validation data to get a ratio $r_y$.

The third step maps $r_y$ to $\hat\Delta_y$ with a monotone regression. We fit this regression on labeled shifted sets that never touch the test domain. On Camelyon17 these are held-out training hospitals; on chest X-ray they are synthetic acquisition perturbations of the source.

Because of the overconfidence result, we study the random-label threshold explicitly. We compare the published confidence-gated rule with a variant that assigns random labels to a fixed fraction of the least-confident samples in each class. The variant keeps working even when every sample is confident.

The analysis also asks a mechanistic question. Do prevalence-only shifts move the class-conditional ratios $r_y$? The decomposition assumes they do not. If they do, it must be corrected before it is trusted.

Baselines

The naive reference point assumes deployment accuracy equals source validation accuracy. It is run on the same target batches, and anything useful must beat it by a wide margin under mixed shift.

The prevalence-only estimator computes $\sum_y \hat\pi_t(y) a_s(y)$ with $\Delta_y = 0$. It is the strongest cheap competitor under pure prevalence shift and the ablation that isolates whether gradients add anything at all. We beat it only if mixed and covariate shifts show lower error with no loss under pure prevalence shift.

The strongest existing output-based method on chest X-ray is CM-ATC from Label-free estimation of clinically relevant performance metrics under distribution shifts. It reports out-of-distribution accuracy mean absolute error around 0.05 on CheXpertPlus, PadChest and ChestX-Ray8. We will run it with the same source validation set, the same target batches and the same threshold tuning budget. We will also run a prevalence-reweighted version, which applies our decomposition with class-conditional thresholded confidence in place of $r_y$. That version is the decisive control.

On Camelyon17, the strongest reported number we have is CPC-ACC at 8.8% ± 2.8% target accuracy estimation error, from Estimating Test Performance for AI Medical Devices under Distribution Shift with Conformal Prediction. We will reproduce it on our splits rather than compare against the published figure.

Pooled GdScore from Leveraging Gradients for Unsupervised Accuracy Estimation under Distribution Shift is run with its published threshold and regression protocol. It tests whether splitting the score by class and removing the prevalence part helps. The file has no isolated Camelyon17 result for it.

An oracle-prevalence version of our method, given true $\pi_t$, bounds how much error comes from prevalence estimation.

Why not just…?

Why not just reweight confidence-based estimators by the estimated prevalence? This is the real threat. If prevalence-reweighted CM-ATC matches our method, then gradients add nothing and the contribution reduces to the decomposition, which is still useful but modest. The case for gradients rests on overconfidence: when shifted inputs stay confident, thresholded confidence underestimates $\Delta_y$. OpenMIBOOD shows such confidence on medical inputs, and the Projection Norm paper shows logit methods predicting negative error under adversarial shift where weight-based signals still responded. Our stratified analysis of the most overconfident target subsets settles this question directly.

Why not just use the dual detector to label the shift type and then pick an estimator? Automatic Dataset Shift Identification to Support Safe Deployment of Medical Imaging AI identifies prevalence shifts at 85% with 500 images and acquisition shifts above 80% with 500 images. However, it returns a category, not an accuracy. Its hard decision leaves mixed shifts unresolved, and it needs a second large encoder. We will run the detect-then-estimate pipeline as a baseline. Our method should match or beat it on mixed shift without using that encoder.

Why not just measure feature distance in the deployed model's own penultimate layer, split by class? Class-conditional Mahalanobis or MMD distance is a fair substitute for $r_y$ in the third step, and OpenMIBOOD found feature methods strongest for detection. Distance, however, also flags appearance changes that leave accuracy intact, the "virtual drift" problem described by CheXstray. We will slot class-conditional feature distance into the same decomposition with the same calibration data. If it wins, we report that it does.

Proposed Experiments

On Camelyon17-WILDS, as defined by WILDS with ERM accuracy falling from about 93% to about 70% out of distribution, we create three kinds of test batch at sizes 100, 250, 500 and 1,000. Pure prevalence batches resample the tumor fraction within in-distribution hospitals. Pure acquisition batches use the held-out hospital at its native prevalence. Mixed batches resample the tumor fraction within the held-out hospital.

For chest X-ray, we follow the CheXpertPlus, PadChest and ChestX-Ray8 setup of the CM-ATC paper with the same three-way construction. Here we report sensitivity and specificity error per finding as well as accuracy. Fitzpatrick17K serves as a many-class stress test of whether per-class gradient scores remain stable when some classes have only a handful of pseudo-labeled samples.

The metrics are mean absolute error of accuracy, sensitivity and specificity estimates, and the rate at which a fixed clinical alarm threshold is crossed correctly. We also report compute, as backward-pass time per batch.

Three checks decide the outcome. First, under pure prevalence shift our method must match the prevalence-only estimator, and $r_y$ must stay near one; if $r_y$ moves, the decomposition is wrong. Second, under mixed shift our method must beat prevalence-reweighted CM-ATC, with the gap concentrated in the most overconfident target subsets; without that gap, the gradient claim fails. Third, the oracle-prevalence gap tells us whether remaining error comes from prevalence estimation or from $\hat\Delta_y$. That determines whether follow-up work should improve the prevalence estimator or the gradient score.