Interactive demo · Probabilistic Machine Learning: Advanced Topics · Chapter 19

Covariate shift, importance weights and the model

The inputs of the training set (source) come from p(x) = N(0, 1); the test inputs (target) come from q(x) = N(m, s²); the regression function f is the same in both. A polynomial is fitted by least squares to the source points (pink) and, with weights w(x) = q(x)/p(x), by weighted least squares (teal). The dashed white curve is the best polynomial for the target (what weighting reaches with infinitely many points). If the model can represent f exactly, the shift is harmless; if it cannot, the source fit is wrong where the target lives. Weighting cures the bias but raises the variance: the effective sample size says by how much.

True function

Model: polynomial of degree

Weights

Target mean m

Target sd s

Source points N

Try these

The "population" rows are exact (numerical integration on a fine grid); the "this run" rows use one random sample of N source points (and N unlabelled target points for the classifier weights) and the target error is integrated exactly over q; the "200 runs" row repeats the whole experiment. Errors are mean squared errors about f and exclude the noise variance 0.0625.

In the lecture notes