Conformalized Quantile Regression

Summary

CQR (Romano, Patterson & Candès, NeurIPS 2019) fits lower and upper conditional quantile functions on a training fold, then uses a calibration fold to compute a single additive correction that widens (or narrows) the plug-in band so that in finite samples for any distribution and any quantile learner. It inherits adaptivity to heteroscedasticity from quantile regression and distribution-free validity from conformal prediction. Across 11 benchmark datasets CQR intervals averaged length – versus – for locally adaptive conformal and – for standard split conformal, all at ~90% coverage.

Overview

Two desiderata for a prediction interval (Sec. 1): (i) valid coverage in finite samples without strong distributional assumptions; (ii) intervals as short as possible at each point of the input space, which under heteroscedasticity means lengths that track local variability.

  • Standard split conformal with absolute residuals satisfies (i) but gives , of fixed length independent of . Lei et al. observe that full conformal bands also vary only slightly when the regression algorithm is moderately stable.
  • Plain quantile regression satisfies (ii): estimate the 5% and 95% conditional quantiles and report . But validity “is guaranteed only for specific models, under certain regularity and asymptotic conditions”, and the authors’ experiments show quantile neural networks can substantially under-cover.

CQR conformalizes the quantile band. Where the econometric treatment in Quantile Regression (Koenker–Bassett) targets inference on coefficients of a linear quantile model, CQR is agnostic about the learner — quantile random forests, quantile neural nets, gradient boosting with pinball loss — and targets predictive coverage.

Main Content

Conditional quantile function and oracle interval ^def-cond-quantile

With , the -th conditional quantile is . For , , the oracle interval satisfies conditional coverage , and its length adapts to .

Pinball (check) loss ^def-pinball

Quantile regression solves with

At this is half the absolute error and targets the conditional median. Any learner can be converted to a quantile learner by swapping MSE for the pinball loss (A&B Sec. 2.2).

Split conformal quantile regression (Romano et al., Algorithm 1) ^alg-cqr

Input: data , level , quantile regression algorithm .

  1. Randomly split into disjoint (proper training) and (calibration).
  2. Fit .
  3. For compute the conformity score
  1. Let be the -th empirical quantile of .
  2. Output: .

Reading the score. is a signed distance to the nearest band edge. If is below the lower estimate, ; if above the upper, ; if inside, is the (negative) distance to the closer edge. The score therefore “accounts for both undercoverage and overcoverage”: when the plug-in band is too wide, most are negative, , and conformalization shrinks the band. This is one reason CQR beats un-conformalized quantile forests in the experiments despite using half the data for training.

CQR coverage (Romano et al., Theorem 1) ^thm-cqr

If , , are exchangeable, then the split-CQR interval satisfies

If moreover the scores are almost surely distinct,

Proof. . Conditional on the proper training set the scores are exchangeable, so the inflated-quantile lemma (quantile lemma) gives both bounds; take expectations over .

Asymmetric (two-tailed) CQR (Romano et al., Theorem 2) ^thm-cqr-asym

Calibrate the tails separately: let be the -th empirical quantile of and that of , and set . Under exchangeability each one-sided bound holds with probability and respectively, hence for .

The symmetric version lets miscoverage be “spread arbitrarily over the left and right tails”; the asymmetric version controls each tail, at the price of longer intervals (average length for CQR neural nets, for CQR random forests).

Practical guidance from the paper (Sec. 4, 6.2)

  1. Tune the nominal quantiles. Quantile forests are often too conservative, quantile nets occasionally so. Treat of the base learner as hyper-parameters chosen by cross-validation to minimise average interval length; “this tuning does not invalidate the coverage guarantee”. In the experiments CQR selected quantiles below the nominal level.
  2. Share parameters. Use one network with a two-dimensional output for the lower and upper quantiles instead of two networks.
  3. Quantile crossing () is rare for 5%/95% but can affect neural nets; a rearrangement post-processing step reduced CQR-NN length from to .
  4. Ties break the upper bound only: CQR random forests were over-conservative on the two Facebook datasets because of ties among scores.
  5. A full-conformal (no-split) variant exists (footnote 2).

Empirical results (Table 1; ; 11 datasets 20 splits = 2,200 experiments)

MethodAvg. lengthAvg. coverage (%)
Ridge (split conformal)3.0690.03
Ridge Local2.9490.13
Random Forests2.2489.99
Random Forests Local1.8289.95
Neural Net2.1689.92
Neural Net Local1.8189.95
CQR Random Forests1.4190.33
CQR Neural Net1.4090.05
Quantile Random Forests (no guarantee)2.2392.62
Quantile Neural Net (no guarantee)1.4988.51

Responses were rescaled by their mean absolute value; 80/20 train-test, with the training portion halved into . Every conformal method attains ~90%; un-conformalized quantile nets under-cover (88.5%) and quantile forests over-cover (92.6%). CQR was shortest on 10 of 11 datasets. On the simulated heteroscedastic-with-outliers example (Figure 2): split 2.91, locally adaptive 2.86, CQR 1.99 average length.

Why locally adaptive conformal loses is discussed in Conformity Scores and Adaptive Prediction Sets: its is trained on optimistically biased training residuals.

Examples

import numpy as np
from sklearn.ensemble import GradientBoostingRegressor as GBR
 
def cqr(X_tr, y_tr, X_cal, y_cal, X_new, alpha=0.1):
    lo = GBR(loss="quantile", alpha=alpha / 2).fit(X_tr, y_tr)
    hi = GBR(loss="quantile", alpha=1 - alpha / 2).fit(X_tr, y_tr)
    E = np.maximum(lo.predict(X_cal) - y_cal, y_cal - hi.predict(X_cal))   # signed scores
    n = len(y_cal)
    Q = np.quantile(E, min(1.0, (1 - alpha) * (1 + 1 / n)), method="higher")
    return lo.predict(X_new) - Q, hi.predict(X_new) + Q                    # Q may be negative

Applied sketch. Weekly store-level sales forecasting with promotional covariates: variance scales with store size and spikes in promo weeks. A constant-width split-conformal band is too wide for small stores and too narrow for promo weeks of large ones, although it is 90% valid on average. CQR’s band widens where the fitted quantiles diverge. Two cautions: (a) stores-within-week may be treated as exchangeable, weeks-within-store generally not (see the drift result in Conformal Prediction - Overview); (b) if the scoring population differs from the calibration population, use the weighted variant in Conformal Prediction Under Covariate Shift.

Connections

See Also