Conformal Prediction Under Covariate Shift

Summary

Tibshirani, Barber, Candès & Ramdas (NeurIPS 2019) extend conformal prediction beyond exchangeability. Under covariate shift — training , test with the same conditional law — replacing the empirical distribution of calibration scores by a likelihood-ratio-weighted one, with weights , restores exactly. The general principle is weighted exchangeability. When is unknown it can be estimated as the odds of a train-vs-test classifier. On the airfoil data, unweighted split conformal drops to 82.2% coverage under an exponential tilt; oracle weights restore 90.8%, and logistic-regression or random-forest estimated weights give 91.0%.

Overview

The marginal guarantee in Split Conformal Prediction and the Coverage Guarantee averages over . If deployment covariates follow , that average is over the wrong population. Because conformal sets generally lack conditional coverage, heteroscedastic regions that are up-weighted under can drag coverage far below nominal. A&B’s examples (Sec. 4.5): calibrating a diagnostic on 50% infants / 50% adults but deploying on 5% / 95%; calibrating a vision system in the morning and deploying in the afternoon.

The remedy parallels importance weighting and inverse-propensity weighting elsewhere in statistics: up-weight calibration points that look like the test population. The likelihood ratio “also plays a critical role in much of the literature on covariate shift” (Remark 4); the paper’s novelty is correcting distribution-free prediction intervals rather than estimators or model selection.

Main Content

Covariate shift model (Tibshirani et al. Eq. 6)

The conditional distribution of is identical in training and test; only the covariate marginal moves. must be absolutely continuous with respect to (overlap).

Weighted conformal probabilities (Eq. 7)

With ,

The ordinary case gives . Only ratios matter, so need be known only up to a normalising constant (Remark 3).

Weighted conformal coverage under covariate shift (Corollary 1)

Under the model above, for any score function and any define

Then .

Weighted split conformal (Eq. 10)

  1. Fit on a preliminary fold; compute calibration scores .
  2. Obtain (known design, or estimated — below) and evaluate and .
  3. Form and ; compute .
  4. Output .

Differences from the unweighted case: the threshold now depends on the test point through , and a test point with very large can push the quantile onto the atom at , yielding an infinite (honest) interval. Any score works — e.g. the CQR score, as in Conformal Inference for Counterfactuals and ITEs.

Why it works: weighted exchangeability (Sec. 3)

The authors re-prove the quantile lemma by conditioning on the unordered set of scores and asking which value took. Exchangeability gives : uniform. This “isolates the role of exchangeability” and shows what must change otherwise.

Weighted exchangeability (Definition 1)

are weighted exchangeable with weight functions if their joint density factorises as

with invariant to permutations of its arguments. Lemma 2: independent draws with are weighted exchangeable with , .

Weighted quantile lemma and general theorem (Lemma 3, Theorem 2)

For weighted exchangeable and , define

Then , because . The general weights are “combinatorially hard”, but under covariate shift ( for , ) the sums over permutations collapse to .

No matching upper bound is available without conditions on the weights (Remark 5): the largest jump of the conditional CDF is , which can be large, whereas it is always unweighted. Lei & Candès later supply one: with coverage is at most , and with estimated weights coverage is at least where .

Estimating the weights (Sec. 2.3)

Given unlabeled test covariates , label training points and test points and fit any probabilistic classifier . Since

the odds estimate up to the irrelevant constant (Eq. 12). This “probabilistic classification” approach is one family of density-ratio estimators (others: moment matching, -divergence minimisation; Sugiyama et al. 2012). It is exactly a propensity-score odds, with “membership in the test sample” as the treatment — the bridge to Propensity Score and the Balancing Property and Bayesian Inverse Probability Weighting.

Effective sample size

Weighted quantiles use fewer effective points. The heuristic from the covariate-shift literature:

In the airfoil experiment, running unweighted conformal with only subsampled calibration points reproduces the dispersion of the oracle-weighted coverage histogram, so the extra variability “is fully explained by the reduced effective sample size”.

Airfoil experiment (, , 5000 random splits, )

Data split 25% pre-fit (linear ) / 25% calibration / 50% test; shifted test set drawn from the test set with probabilities , (an exponential tilt).

ProcedureTest populationAvg. coverage
Unweighted split conformalno shift90.2%
Unweighted split conformalshifted82.2%
Weighted, oracle shifted90.8%
Weighted, logistic-regression shifted91.0%
Weighted, random-forest shifted91.0%

Random-forest probabilities were clipped to because about 2% of cases otherwise produced and infinite weights; RF weights gave more variable and sometimes much longer intervals. With no actual shift, estimated-weight conformal behaves nearly identically to unweighted. Oracle-weighted intervals are longer than the equal- unweighted ones because itself was not adapted to the shift.

Other uses noted in the Discussion (Sec. 4)

  • Graphical structure with shift only in low-dimensional : , so only a low-dimensional ratio is needed.
  • Missing covariates with known summaries: a second site shares only the marginal of a sensitive .
  • Approximate local conditional coverage with kernel weights → Marginal vs Conditional Coverage.
  • Latent-variable and missing-data problems, later realised for counterfactuals in Conformal Inference for Counterfactuals and ITEs.

Examples

By hand. Calibration scores ; likelihood-ratio weights (the test population favours easy, low-score regions); test point . Total weight , so and on . Cumulative mass: . At the weighted -quantile is ; the unweighted rule takes the th score, . Reverse the weights to and the cumulative mass is , so at and for any — the atom at infinity alone carries 20% of the mass. Effective sample size: of 4.

import numpy as np
 
def weighted_conformal_qhat(scores, w_cal, w_test, alpha=0.1):
    order = np.argsort(scores)
    s, w = scores[order], w_cal[order]
    cum = np.cumsum(w) / (w.sum() + w_test)          # mass w_test/(sum+w_test) sits at +inf
    idx = np.searchsorted(cum, 1 - alpha, side="left")
    return s[idx] if idx < len(s) else np.inf
 
# w from a domain classifier: p = clf.predict_proba(X)[:, 1]; w = p / (1 - p)  (clip p!)

Applied sketch. A conversion-propensity model calibrated on last quarter’s traffic mix (60% paid social) is deployed after a budget reallocation (30% paid social). If is stable, fit a classifier distinguishing old from new sessions, convert to odds, and use weighted conformal sets. If the conditional also moved (creative refresh, pricing), the covariate-shift assumption fails and only the drift bound in the overview applies.

Connections

See Also