Generalization Across Devices, Sites, and Geographies
The technical and clinical dimensions of generalization failure. Domain shift, dataset bias toward specific scanners or institutions, and strategies for building robust models.
We have already covered generalization twice. 1.6 What AI Cannot Do has the well-known failures, and 2.6 Multi-Site and Multi-Device Data covers how to build and test a dataset so the model has a chance of working elsewhere. If you haven't read 2.6, it's probably the better place to start.
This article looks at the same problem as a fairness problem. Models are built where the data, the money and the engineers are. The places that had no part in the building get a model that works less well for them, and they are frequently the places with the fewest radiologists to catch its mistakes. So we'll go through the kinds of shift, who ends up on the wrong side of each, and how to measure and report it.
Three kinds of shift
"Distribution shift" covers several different things, and it helps to separate them because they call for different responses.
The inputs change. The patients, scanners or protocols at the new site produce images that look different from the training images, while the relationship between an image and its diagnosis stays the same. Statisticians call this covariate shift. A new detector, thicker slices, a different stain, or a population with a different range of body habitus are all examples. The model is being asked about a part of the input space it saw little of.
The prevalence changes. The disease is more or less common at the new site. Sensitivity and specificity may hold up, but predictive values move, and any probability the model reports is off (see 2.4 Class Imbalance). A model developed in a referral clinic where a third of patients have the disease, then used for screening where one in a hundred do, will produce mostly false alarms without anything being wrong with the model.
The meaning of the label changes. This one is easy to overlook. Two hospitals may use different thresholds for calling a finding, different grading systems, or different guidelines. Diagnostic criteria get revised over time. If "positive" at the training site meant something slightly different from "positive" at the new site, the model is being scored against a definition it never learned. This is called concept shift, and more data from the original site doesn't help with it.
Most real moves between sites involve all three at once.
Devices
Device differences are covered in detail in 2.6, so here we'll only make the fairness point. Equipment isn't distributed evenly. Large academic centers replace scanners on a schedule and buy from the top of the range. Smaller and poorer hospitals keep older machines longer, use more portable and hand-held devices, and may have fewer protocol options. Training datasets come overwhelmingly from the first kind of institution.
So a model's weakness on older or cheaper equipment is also a weakness on the patients of hospitals with less money. In the United States that tends to mean rural and safety-net hospitals. If your subgroup analysis by race or income shows a gap, it's worth checking whether equipment explains part of it, because the remedy is different.
Hand-held ultrasound and smartphone-based imaging are a special case. They are being promoted for exactly the settings that lack specialists, and the people operating them are often not sonographers. A model trained on images acquired by experts on cart-based machines has seen neither the device nor the kind of image a novice produces.
Sites
Beyond equipment, sites differ in who the patients are and in how care is organized.
Case mix is the big one. A tertiary center sees advanced disease, rare disease and patients who have already been worked up elsewhere. A community hospital sees earlier and milder disease, along with a great many patients who turn out to have nothing. A model trained on florid cases may do poorly on subtle ones, which are the ones where help would be most useful.
Workflow is the other one. Which patients get imaged at all, which views are taken, how long after symptom onset, whether a prior study is available. The Epic sepsis model described in 1.6 is a case where much of the gap between the developer's figures and the external evaluation came from how and when the model was used.
Alice Yu and colleagues reviewed external validation studies of deep learning algorithms for radiologic diagnosis in 2022. Of the 86 algorithms they found with both internal and external results, about four in five did worse externally, and about a quarter did substantially worse. So a drop at a new site is the expected result. The open question each time is how big.
Geographies
The widest gap is between countries. Most public medical imaging datasets come from the United States, Europe and China. Within the US, as noted in 7.1 Sources of Bias in Medical AI, most cohorts in published studies come from three states.
A model moved to a different part of the world meets a different population, different disease patterns and different co-existing conditions. A chest X-ray model trained where tuberculosis is rare will have seen few examples of it and of the scarring it leaves behind, and in a high-burden country both are everywhere. Dermatology models trained mostly on lighter skin do worse on darker skin. Reference ranges for bone age, growth and body composition were built on particular populations.
Then there is infrastructure. The diabetic retinopathy deployment in Thailand, described in 1.6, is the standard example: the model was accurate on gradable images, and the clinics' lighting and connectivity meant a large share of images were not gradable. Nothing about that would have shown up in a retrospective test on curated images.
There's an uncomfortable asymmetry in this. AI tools are often presented as a way to bring specialist-level reading to places with no specialists. Those are the places least represented in training data, and the places with nobody on hand to notice when the tool is wrong. We think that claim needs local evidence before anybody relies on it.
Hidden subgroups
A model can also fail on a subgroup that nobody thought to label. In 2020 Luke Oakden-Rayner and colleagues named this hidden stratification. Their example was the pneumothorax classifier mentioned in 1.6: overall performance was good, performance on pneumothoraces without a chest drain was much worse, and the dataset had no field for "drain present." You only find these by looking through the errors by hand, or by clustering the model's mistakes and seeing what the clusters have in common.
When a model moves, the mix of these hidden subgroups changes. A site that sees more untreated presentations will get worse results than the original test set predicted, without any change in scanner or demographics.
Test accuracy doesn't predict behaviour under shift
A 2020 paper from a large Google team led by Alexander D'Amour described what they called underspecification. They trained the same model several times on the same data, changing nothing but the random starting point. The resulting models had nearly identical scores on the ordinary test set, and quite different performance on shifted data, such as retinal images from a different camera or skin images of a different skin type.
The consequence for us is that an internal test set can't distinguish between a model that will travel and one that won't. Two models that look the same on your hospital's data may behave very differently at the next hospital, and the only way to find out is to test there.
Measuring it
The basic design is in 2.6 and in 5.4 Multi-Site External Validation: hold out whole sites, and report each one. For a fairness view we'd add the following.
Report by site, by scanner manufacturer and model, by care setting and by country if you have more than one. Give each stratum its own row with a confidence interval. An average over sites weighted by case count mostly describes the largest site.
Report the worst stratum prominently. A reader deciding whether the tool is safe for their hospital wants to know how bad it gets, and "sensitivity ranged from 78% to 94% across seven sites" is more useful than "mean sensitivity 89%."
Describe the sites well enough that a reader can tell which one theirs resembles: academic or community, urban or rural, patient demographics, equipment, prevalence.
Check calibration at each site. Discrimination often survives a move better than calibration does, so a model can rank patients correctly at a new site while its probabilities are well off (see 4.4 Calibration).
Combine site with demographics where numbers allow. A gap between demographic groups that appears at one site and not at another tells you something about its cause.
Say where the model has not been tested. If every site was a university hospital in one country, that is a limit on the claim, and the intended use should reflect it.
At the receiving end
If you are the one adopting a model built elsewhere, the published results are about somebody else's patients. Samuel Finlayson and colleagues made this argument to clinicians in a 2021 New England Journal of Medicine article on dataset shift, and their recommendation was that hospitals treat shift as something to watch for routinely.
Before relying on a tool, run it on a sample of your own recent cases with known outcomes. A few hundred is often enough to see a large problem. Compare your equipment and population with the ones in the validation study. Ask the vendor for performance on your scanner model.
After adoption, keep watching. A scanner replacement, a software upgrade, a new referral pattern or a change in guidelines are all shifts, and they happen at a single site over time (see 8.6 Monitoring AI Performance in Production). If local performance is poor, recalibrating or fine-tuning on local data can help, though for a regulated product that has to happen within what the manufacturer's clearance allows (see 6.8 Predetermined Change Control Plans).
Key takeaways
- Shift comes in three kinds: the inputs change, the prevalence changes, or the meaning of the label changes. Most site moves involve all of them.
- Training data comes mostly from well-resourced academic centers in a few countries. Weak generalization therefore falls hardest on smaller hospitals, older equipment and under-represented regions.
- External performance is usually lower than internal performance. Plan for a drop and measure its size.
- Models with identical internal test scores can behave very differently under shift, so internal results can't certify that a model will travel.
- Report results per site, per device and per setting with intervals, show the worst stratum, check calibration at each site, and state where the model was never tested.
- A site adopting a model should test it on local cases first and monitor it afterwards.
What to read next
- 2.6 Multi-Site and Multi-Device Data: The Generalization Challenge: building and testing the dataset
- 5.4 Multi-Site External Validation: designing the external study
- 7.2 Demographic Fairness: Performance Across Populations: the same breakdown by patient group
- 8.6 Monitoring AI Performance in Production: watching for shift over time
- 6.12 Post-Market Surveillance and Real-World Monitoring: what a manufacturer has to track
This article is part of the AI in Clinical Research Knowledge Base.