State which part of the input–outcome distribution changed
Use covariate, label-prior, and conditional-outcome assumptions carefully, and recognize what unlabeled observations cannot identify.
On this page
The question for today
What you’ll understand
- Define covariate shift and label shift by their preserved conditional distributions.
- Calculate target risk under supported covariate reweighting.
- Explain why an input alert does not identify a shift mechanism or an automatic correction.
Distribution shift is a statement about the joint distribution of inputs and outcomes. Different assumptions about that joint distribution justify different corrections. Changing customer mix, changing class prevalence, and changing outcomes for the same recorded inputs need not have the same cause or remedy. Use the shift vocabulary to declare assumptions that can be examined, rather than assigning a diagnosis from one feature histogram or treating every performance decline as a request for more training.
Factor the joint distribution in two useful ways
Covariate shift means the input distribution changes while the conditional outcome distribution given the recorded input remains the same. Label shift, also called prior-probability shift, instead preserves the input distribution conditional on the class while class prevalence changes. Concept shift here means a change in the conditional outcome distribution given inputs. This last definition is broad: label shift can change the posterior outcome probability too. These descriptions are therefore assumptions about factorizations, not three mutually exclusive bins into which every incident must fit.
The recorded input representation matters. A change that looks like conditional-outcome drift after dropping a relevant variable may look like a changed mixture after including it. Likewise, a changed label definition creates a different target rather than merely harder examples for the old target. Preserve schema, target, population, and measurement contracts when comparing distributions. State whether a claimed conditional equality is a modeling assumption or has been checked on sufficiently mature labeled data. Finite observations can support or challenge that assumption without proving equality everywhere.
A correction inherits the assumptions of its derivation
Under covariate shift, target risk can be expressed as a weighted source expectation when the target input support is covered by the source. The weight is the target-to-source input density ratio. This equality does not make estimated weights reliable: sparse regions and large ratios increase estimator variability. A target population with input regions absent from the source cannot be evaluated by this identity using source outcomes alone. Weight clipping can stabilize an estimator, but it changes the estimand or introduces bias that must be assessed.
Under label shift, a fixed classifier's class-conditional prediction rates can connect observed predicted-class frequencies to target class prevalence. For a binary classifier, an invertible confusion matrix is required to recover the two prevalences uniquely by this method. A classifier that predicts positive equally often for both true classes supplies no such information. Even an invertible estimate may be unstable when those rates are close. The label-shift assumption must be justified independently; a changed prediction rate alone cannot distinguish a new prior from changed class-conditional inputs or a pipeline defect.
Inputs alone cannot settle conditional-outcome changes
Consider two populations with identical input distributions but opposite binary labels at each input. Every input-only test sees the same population, while a fixed predictor can go from correct to incorrect. Conversely, a large input shift can occur entirely in dimensions irrelevant to a good predictor. Use distribution alerts as leads and connect them to outcome evidence, mechanism knowledge, or a carefully scoped assumption. If labels are delayed, explicitly carry that uncertainty into the response instead of calling a convenient unsupervised statistic a performance estimate.
The probability instrument helps separate a class proportion from an outcome relationship. Reset, set p=0.25 and n=20, predict mean count five, then Play or Step. Separately Reset, set p=0.50 and n=20, predict mean count ten, then Play or Step. Its exact binomial bars illustrate a changed marginal prevalence under independent trials. They contain no inputs, classifier, confusion matrix, or conditional labels, so they cannot establish label shift rather than another mechanism. The missing conditional information is precisely what a production diagnosis must supply.
Work it through
A population mix changes risk without changing conditional errors
A fixed classifier has error rates 0.10 in input group A and 0.30 in group B. These rates are unchanged between populations. The source mix is 75% A and 25% B; the target mix is 25% A and 75% B. Both groups have source support. Compute source risk, target risk, and the two importance weights.
Source error risk is 0.75×0.10+0.25×0.30=0.15. Target error risk is 0.25×0.10+0.75×0.30=0.25, even though neither conditional error rate changed.
The group weights are w(A)=0.25/0.75=1/3 and w(B)=0.75/0.25=3. Each weight compares the same group's target and source probability.
The weighted source expectation is 0.75×(1/3)×0.10+0.25×3×0.30=0.025+0.225=0.25. It matches target risk under the stated unchanged-conditional assumption.
A ten-percentage-point aggregate error increase is explained here by the changed input mix. Real data still need support and conditional-stability checks.
The living notebook
Explore the model
Interactive lab · probability
Prevalence is only one part of the joint distribution
Reset, set p=0.25 and n=20, predict mean count 5, then Play or Step. Separately Reset, set p=0.50 and n=20, predict mean count 10, then Play or Step. The exact independent binomial model changes a marginal class proportion; it has no inputs or conditional-outcome mechanism and cannot diagnose the kind of shift.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA marginal change does not establish which conditional assumptions remain valid.
Pause & reason
Check your understanding
Your turn
Try it yourself
Assume exact label shift and a fixed classifier with true-positive rate 0.80 and false-positive rate 0.20. The target positive-prediction probability is 0.50. Solve for target positive-class prevalence π, and identify the failure if both rates were 0.50 instead.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use total probability: 0.50=0.80π+0.20(1−π).
Compare with the solution
Rearranging gives 0.30=0.60π, hence π=0.50. If both class-conditional positive-prediction rates equal 0.50, the observed prediction probability is 0.50 for every π. The confusion matrix is singular and cannot identify prevalence. The calculation also requires the label-shift assumption; unlabeled prediction counts do not prove it.
Keep the idea
Take it with you
- Shift definitions specify which conditional distribution is assumed stable.
- Reweighting requires support and can amplify estimation variability.
- Unlabeled observations cannot generally identify conditional-outcome changes or justify a correction.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.