Distribution shift

Distribution shift is any difference between the data a model was trained on and the data it meets in use, the main reason models that score well in testing can fail in the real world.

Machine learning rests on an assumption that is rarely stated: the data a model sees in use will look like the data it learned from. When that holds, accuracy measured on a test set predicts accuracy in the field. When it does not, the model is being asked about a world it never saw. Distribution shift is the general name for that mismatch, and data that falls outside what a model was trained on is described as out-of-distribution.

Researchers distinguish several kinds. In covariate shift, the inputs change but their relationship to the answer does not: a spam filter trained on one person's email meets another person's quite different inbox, yet spam is still spam. In label shift, or prior shift, the proportions of the answers change: a classifier of hair colour trained on photos from Italy is used on photos from Norway. In concept shift, the relationship itself changes, as when the same symptoms point to different diseases in different populations. When these changes happen gradually after deployment, practitioners call them data drift and concept drift.

The effect can be large. The WILDS benchmark, first posted by Pang Wei Koh, Shiori Sagawa and colleagues in December 2020, gathers ten datasets with real shifts: tumour identification across hospitals, wildlife monitoring across camera traps, and satellite imaging and poverty mapping across time and places. On every dataset, standard training gave substantially lower performance out of distribution than in distribution, and methods designed for shift did not close the gap.

That is why a model's published accuracy says less than it seems. A medical imaging model validated at one hospital may stumble at another with different scanners and patients. Remedies include training on more varied data, reweighting training examples to match the new setting, adapting the model with some data from the target domain, and monitoring after deployment. None makes a model immune; the practical safeguard is to test on data that looks like the place the model will actually be used.

Common questions

What is distribution shift in machine learning?

It is a difference between the distribution of the training data and the data a model encounters when used. Because models learn patterns from their training data, a shift can make those patterns unreliable and reduce accuracy, sometimes sharply.

What is the difference between covariate shift and concept shift?

In covariate shift the inputs change but the rule linking inputs to answers stays the same. In concept shift the rule itself changes, so the same inputs should now lead to a different answer. Covariate shift can sometimes be corrected by reweighting data; concept shift needs new labelled examples.

What does out-of-distribution mean?

Out-of-distribution data is data unlike anything in a model's training set, such as images from a new kind of camera or questions about a topic the model never saw. Models often perform worse on it and may not signal that they are uncertain.

How is distribution shift related to data drift?

Data drift and concept drift are distribution shifts that happen over time after a model is deployed. Distribution shift is the broader term and also covers differences that exist from the start, such as using a model in a different country or hospital from where it was trained.

Finding more

Search for "distribution shift", "dataset shift", "covariate shift", "domain adaptation" and "out-of-distribution generalisation". The WILDS benchmark paper and surveys of domain adaptation on arXiv are good starting points, and textbooks on transfer learning give the theory. When a product claims high accuracy, look for whether it was tested on data from settings like yours.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.