Under covariate shift, how do you derive the importance-weighted loss and estimate using a domain classifier? Given training points and unlabelled test points, four training examples receive calibrated domain probabilities and per-example losses : what are their importance weights, the weighted loss, and the ESS (effective sample size), and why does this fail under concept drift?
ML systems and evaluation, Distribution shift
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can derive importance-weighted risk estimation and training under covariate shift, estimate density ratios with a domain classifier, diagnose variance via ESS (effective sample size), and recognise when the assumption breaks.
Key idea
Covariate shift assumes the input density changes from to while the conditional label distribution stays fixed. Multiplying and dividing the test expectation by yields with , letting you evaluate or retrain a model on labelled training data as if it were drawn from the test distribution.
Steps
- Derive the identity: let be the loss of predictor on input and label . Assuming wherever and , rewrite the test expected loss as with importance weight .
- Estimate with a domain classifier: pool the training inputs (label ) and unlabelled test inputs (label ), giving prior ratio . By Bayes' rule on and ,
- Compute the weights on the example: here and . Thus , , , and .
- Compute the weighted loss and ESS: the unweighted mean loss is . With , the self-normalised weighted loss is . Since , the effective sample size is out of .
- Control variance with weight clipping: one example with carries of the total weight, inflating variance for both evaluation and reweighted training. Clipping weights at a cap (for instance gives , raising ESS to and weighted loss to ) trades a small bias for much steadier estimates.
- Explain why fixed matters: the derivation relies on . Under concept drift, where itself changes between training and deployment, reweighting cannot correct shifted labels, so you need fresh target labels to evaluate or retrain.
Common mistakes
- Forgetting the sample-size ratio when the domain classifier is trained on unequal counts of training and test points.
- Plugging an uncalibrated domain classifier into the odds ratio; probabilities pushed near create huge weights that collapse the ESS.
- Using importance weighting when the test distribution places mass where ; reweighting existing training points cannot cover an unrepresented region.
How long your answer should be
3–4 minutes: short derivation, domain-classifier formula, weights and ESS arithmetic, and two sentences on clipping and concept drift.
Read this
Previous in ML systems and evaluation: In online A/B testing, CUPED reduces metric variance by replacing the outcome with , where is a pre-experiment covariate unaffected by treatment. How do you show that (unbiasedness), derive the variance-minimising , and prove that the minimum variance is where ?
Next in ML systems and evaluation: How do you use the two-sample KS (Kolmogorov–Smirnov) test to detect drift in a model's prediction scores? Suppose 6 reference scores are and 6 live scores are : what are the empirical CDFs (cumulative distribution functions), the KS statistic , and the comparison against the large-sample critical value, and why do production teams alert on effect size rather than p-values?