Songeun Kim

New Paradigms in Modern Statistics I

Fundamentals

Why a quantile of the nonconformity scores guarantees coverage, and what that guarantee does and does not promise.

Now, the question is: how can the conformal prediction algorithm guarantee coverage, i.e.,

P(Ynew∈C(Xnew))≥1−α ?\mathbb P\big(Y_{\text{new}} \in \mathcal C(X_{\text{new}})\big) \ge 1-\alpha \,?

The point of the theory is in choosing the threshold as a quantile of the nonconformity scores. The intuition is simple. Suppose the scores {s(Xi,Yi)}i=1n\{s(X_i, Y_i)\}_{i=1}^{n} and Snew=s(Xnew,Ynew)S_{\text{new}} = s(X_{\text{new}}, Y_{\text{new}}) are exchangeable. Then we can think of the real line split into n+1n+1 slots by the nn calibration scores. With exchangeability, the probability that the new score SnewS_{\text{new}} lands in each slot is equal. Written mathematically:

Quantile Lemma

Let S(k)S_{(k)} denote the kk-th smallest of the calibration scores. Then for any k∈{1,…,n}k \in \{1, \dots, n\} we have

P(Snew≤S(k))≥kn+1,\mathbb P\big(S_{\text{new}} \le S_{(k)}\big) \ge \frac{k}{n+1},

with equality if the scores have no ties.

Choosing k=⌈(n+1)(1−α)⌉k = \lceil (n+1)(1-\alpha) \rceil gives exactly the q^=S(k)\hat q = S_{(k)} from the algorithm, and since Ynew∈C(Xnew)  ⟺  Snew≤q^Y_{\text{new}} \in \mathcal C(X_{\text{new}}) \iff S_{\text{new}} \le \hat q, we get the coverage guarantee:

Coverage Theorem

If the scores are exchangeable, then

1−α≤P(Ynew∈C(Xnew))≤1−α+1n+1,1-\alpha \le \mathbb P\big(Y_{\text{new}} \in \mathcal C(X_{\text{new}})\big) \le 1-\alpha+\frac{1}{n+1},

where the upper bound holds when the scores have no ties.

Note that this is a finite-sample guarantee. It holds for every nn, with no asymptotics and no assumption on the model or the data distribution beyond exchangeability.


Example: CQR

Now we can think of applying conformal prediction to continuous outputs, too. The best example is conformalized quantile regression (CQR) by Romano, Patterson, and Candès (2019), as presented in Angelopoulos & Bates. Quantile regression estimates the interval [t^α/2(x), t^1−α/2(x)][\hat t_{\alpha/2}(x),\ \hat t_{1-\alpha/2}(x)] aiming at 1−α1-\alpha coverage, but it might actually fail the guarantee due to estimation noise and model misspecification. Setting the nonconformity score as the signed distance to the estimated quantiles,

s(x,y)=max⁡{t^α/2(x)−y,  y−t^1−α/2(x)},s(x, y) = \max\big\{\hat t_{\alpha/2}(x) - y,\ \ y - \hat t_{1-\alpha/2}(x)\big\},

we get the prediction set

C(x)=[t^α/2(x)−q^,  t^1−α/2(x)+q^].\mathcal C(x) = \big[\hat t_{\alpha/2}(x) - \hat q,\ \ \hat t_{1-\alpha/2}(x) + \hat q\big].
q̂q̂t̂1−α/2(x)t̂α/2(x)prediction set 𝒞(x)quantile regressionxy
Conformalized quantile regression. The grey curves are the estimated quantiles; the conformal band adds q̂ on both sides. Redrawn after Angelopoulos & Bates (2021).

However, the critical point to note is that the conformal prediction interval guarantees the marginal coverage,1 not the conditional coverage

P(Y∈C(X)∣X=x)≥1−αfor every x.\mathbb P\big(Y \in \mathcal C(X) \mid X = x\big) \ge 1-\alpha \quad \text{for every } x.

Intuitively, we may need q^(x)\hat q(x), a threshold that depends on xx, for conditional coverage, while CQR uses one q^\hat q for every xx. In fact, exact distribution-free conditional coverage is impossible in general.2

Footnotes

  1. Marginal over the calibration set, too. For one fixed calibration set and without ties, the coverage follows Beta(k, n+1−k)\mathrm{Beta}(k,\ n+1-k) with k=⌈(n+1)(1−α)⌉k = \lceil (n+1)(1-\alpha) \rceil, so it concentrates around 1−α1-\alpha as nn grows. See Vladimir Vovk, Conditional validity of inductive conformal predictors, ACML 2012. ↩

  2. Vovk (2012); Jing Lei, Larry Wasserman, Distribution-free prediction bands for non-parametric regression, JRSS-B 2014; Rina Foygel Barber, Emmanuel J. Candès, Aaditya Ramdas, Ryan J. Tibshirani, The limits of distribution-free conditional predictive inference, Information and Inference 2021. ↩