Sam Babichenko

Reading notes / Conformal prediction and distribution shift

Adaptive conformal inference

Gibbs and Candès, 2021

Context. Split conformal prediction gives P(Y∈C^)≥1−α\mathbb P(Y\in\hat C)\ge1-\alpha only when calibration and test points are exchangeable. In online use (markets, election night, transaction streams) the data drift, and a quantile calibrated on the past undercovers after a shift. Earlier fixes need to know something about the shift (a likelihood ratio, or the radius of a divergence ball); this paper assumes nothing. It keeps the conformal machinery and treats the level fed to the calibration quantile as one parameter, re-estimated online from the observed misses. Gibbs and Candès run coverage as a feedback loop, raising the nominal coverage after a miss and lowering it after a hit. The parameter integrates the coverage error, and since it is confined to a bounded interval (below 0 the set is everything, above 1 it is empty), the integrated error stays bounded and the average miss rate converges to α\alpha at rate 1/(γT)1/(\gamma T) on every data sequence. This is integral control with a bounded state, and the step size γ\gamma trades slow response to a shift against step-to-step noise, as with constant-step SGD tracking a moving optimum.

Setting. Pairs (Xt,Yt)(X_t,Y_t) arrive one at a time, and YtY_t is revealed after each prediction. At time tt there is a score StS_t (say ∣y−μ^(x)∣|y-\hat\mu(x)|, or the CQR score) and a calibration quantile function Q^t\hat Q_t, both refit on past data, and the set C^t(β)={y:St(Xt,y)≤Q^t(1−β)}\hat C_t(\beta)=\{y:S_t(X_t,y)\le\hat Q_t(1-\beta)\}. Q^t\hat Q_t is non-decreasing with Q^t(p)=−∞\hat Q_t(p)=-\infty for p<0p<0 and +∞+\infty for p>1p>1, so C^t(β)\hat C_t(\beta) is the whole line for β<0\beta<0 and empty for β>1\beta>1. Let Mt(β)=P(St(Xt,Yt)>Q^t(1−β))M_t(\beta)=\mathbb P(S_t(X_t,Y_t)>\hat Q_t(1-\beta)) be the miscoverage at level β\beta and αt∗=sup⁡{β:Mt(β)≤α}\alpha_t^*=\sup\{\beta:M_t(\beta)\le\alpha\} the level that would give coverage 1−α1-\alpha at time tt. Adaptive conformal inference (ACI) starts at α1∈[0,1]\alpha_1\in[0,1] (in practice α1=α\alpha_1=\alpha) and updates errt=1{Yt∉C^t(αt)},αt+1=αt+γ(α−errt).\mathrm{err}_t=\mathbf 1\{Y_t\notin\hat C_t(\alpha_t)\},\qquad \alpha_{t+1}=\alpha_t+\gamma(\alpha-\mathrm{err}_t). A miss lowers αt\alpha_t by γ(1−α)\gamma(1-\alpha), widening the next set, and a hit raises it by γα\gamma\alpha.

Proposition (long-run coverage on any sequence). With no assumption on the data, for every TT and on every path, ∣1T∑t=1Terrt−α∣≤max⁡{α1,1−α1}+γγT.\Big|\frac1T\sum_{t=1}^T\mathrm{err}_t-\alpha\Big|\le\frac{\max\{\alpha_1,1-\alpha_1\}+\gamma}{\gamma T}. For α1=α=0.1\alpha_1=\alpha=0.1 and the paper's γ=0.005\gamma=0.005, the right side is 181/T181/T. In a noiseless model with a fixed target α∗\alpha^* and piecewise-linear MM, the average error is exactly (1−(1−cγ)T) ∣α1−α∗∣/(γT)(1-(1-c\gamma)^T)\,|\alpha_1-\alpha^*|/(\gamma T) for small γ\gamma, cc the slope of MM on the side where α1\alpha_1 starts, so the 1/(γT)1/(\gamma T) rate is the right one when α∗\alpha^* is unknown.

Hidden Markov model and per-step coverage. The finer results put a model on the drift. A Markov chain AtA_t drives the environment, and given the chain the pairs are independent with (Xt,Yt)∼PAt(X_t,Y_t)\sim P_{A_t}; the score and quantile function are held fixed. Write M(p∣a)=P(S(Xt,Yt)>Q^(1−p)∣At=a)M(p|a)=\mathbb P(S(X_t,Y_t)>\hat Q(1-p)\mid A_t=a), let αa∗\alpha_a^* solve M(αa∗∣a)=αM(\alpha_a^*|a)=\alpha, and let D=E∣αAt+1∗−αAt∗∣D=\mathbb E|\alpha^*_{A_{t+1}}-\alpha^*_{A_t}| be the drift of the target. The pair (αt,At)(\alpha_t,A_t) is assumed to start in its unique stationary law. Theorem. If every M(⋅∣a)M(\cdot|a) is LL-Lipschitz and each αa∗∈(0,1)\alpha_a^*\in(0,1) exists, then E[(M(αt∣At)−α)2]≤L(1+γ)γ D+Lγ2,\mathbb E\big[(M(\alpha_t|A_t)-\alpha)^2\big]\le\frac{L(1+\gamma)}{\gamma}\,D+\frac{L\gamma}2, which at γ=2D\gamma=\sqrt{2D} is at most L(2+1)DL(\sqrt2+1)\sqrt D; with perfect quantiles L=1L=1.

Theorem (concentration of the miss rate). In the same model, let the chain have absolute spectral gap 1−η>01-\eta>0, and set B=sup⁡a∣E[errt∣At=a]−α∣B=\sup_a|\mathbb E[\mathrm{err}_t|A_t=a]-\alpha| and σB2=E[(E[errt∣At]−α)2]\sigma_B^2=\mathbb E[(\mathbb E[\mathrm{err}_t|A_t]-\alpha)^2]. Then P(∣1T∑t≤Terrt−α∣≥ε)≤2e−Tε2/8+2exp⁡(−T(1−η)ε28(1+η)σB2+20Bε),\mathbb P\Big(\Big|\frac1T\sum_{t\le T}\mathrm{err}_t-\alpha\Big|\ge\varepsilon\Big)\le2e^{-T\varepsilon^2/8}+2\exp\Big(-\frac{T(1-\eta)\varepsilon^2}{8(1+\eta)\sigma_B^2+20B\varepsilon}\Big), and under a second-order expansion of each M(⋅∣a)M(\cdot|a) at αa∗\alpha_a^* with slope bounded away from 00 and below 1/γ1/\gamma, σB2≤B2\sigma_B^2\le B^2 and B≤C(γ+γ−1ϵ1)B\le C(\gamma+\gamma^{-1}\epsilon_1), with ϵ1\epsilon_1 the worst conditional expected one-step drift of α∗\alpha^*. Step 4 explains why the first term is established only for a single state.

Step 1

The parameter stays bounded, because the sets saturate. Each update moves αt\alpha_t by less than γ\gamma. If αt<0\alpha_t<0 the set is the whole line, so errt=0\mathrm{err}_t=0 and αt\alpha_t rises; if αt>1\alpha_t>1 the set is empty, so errt=1\mathrm{err}_t=1 and αt\alpha_t falls. So αt∈[−γ,1+γ]\alpha_t\in[-\gamma,1+\gamma] for all tt. Nothing about the data is used, only that the quantile map saturates, which is why ACI must be allowed the trivial sets that the convention Q^t=±∞\hat Q_t=\pm\infty outside [0,1][0,1] provides.

Step 2

Summing the update gives the long-run bound. Unrolling the recursion turns the summed errors into the total movement of the parameter: αT+1−α1=γ∑t=1T(α−errt).\alpha_{T+1}-\alpha_1=\gamma\sum_{t=1}^T(\alpha-\mathrm{err}_t). By Step 1 the left side is at most max⁡{α1,1−α1}+γ\max\{\alpha_1,1-\alpha_1\}+\gamma in absolute value; divide by γT\gamma T. For tightness, with MM linear of slope cc near α∗\alpha^* the mean error decays like c(1−cγ)t−1(α1−α∗)c(1-c\gamma)^{t-1}(\alpha_1-\alpha^*), and the geometric sum gives the same 1/(γT)1/(\gamma T) rate. So the proposition is a statement about the transient: the average forgets the initialization at rate 1/(γT)1/(\gamma T), and it says nothing finer. The update is also online subgradient descent on the pinball loss, but static regret is not a useful measure against a moving target, so the paper proves the bound directly.

Step 3

Under slow drift, per-step miscoverage is small, by a tracking argument. Take (αt−αAt∗)2(\alpha_t-\alpha^*_{A_t})^2 as a Lyapunov function, as in constant-gain stochastic approximation: (αt+1−αAt∗)2=(αt−αAt∗)2−2γ(errt−α)(αt−αAt∗)+γ2(α−errt)2.(\alpha_{t+1}-\alpha^*_{A_t})^2=(\alpha_t-\alpha^*_{A_t})^2-2\gamma(\mathrm{err}_t-\alpha)(\alpha_t-\alpha^*_{A_t})+\gamma^2(\alpha-\mathrm{err}_t)^2. Conditioning turns errt−α\mathrm{err}_t-\alpha into M(αt∣At)−M(αAt∗∣At)M(\alpha_t|A_t)-M(\alpha^*_{A_t}|A_t), and for a non-decreasing LL-Lipschitz MM, (M(x)−M(y))(x−y)≥(M(x)−M(y))2/L(M(x)-M(y))(x-y)\ge(M(x)-M(y))^2/L, so the cross term removes at least (2γ/L) E(M(αt∣At)−α)2(2\gamma/L)\,\mathbb E(M(\alpha_t|A_t)-\alpha)^2 per step. Moving the target to αAt+1∗\alpha^*_{A_{t+1}} costs at most 2(1+γ)∣αAt+1∗−αAt∗∣2(1+\gamma)|\alpha^*_{A_{t+1}}-\alpha^*_{A_t}| per step; sum and use stationarity. The bound is a lag term plus a noise term: LD/γLD/\gamma comes from a target moving by DD per step while the parameter moves by about γ\gamma, and Lγ/2L\gamma/2 is the noise of steps of size γ\gamma. Balancing them gives γ∝D\gamma\propto\sqrt D, so the step size should be larger when the target moves faster.

Step 4

Feedback makes the misses negatively dependent, so the miss rate concentrates; state switches add clustering the proof does not control. Split each centered miss into noise around its state's mean and the state's bias: errt−α=(errt−E[errt∣At])+(E[errt∣At]−α).\mathrm{err}_t-\alpha=(\mathrm{err}_t-\mathbb E[\mathrm{err}_t|A_t])+(\mathbb E[\mathrm{err}_t|A_t]-\alpha). The bias piece is a bounded mean-zero function of the stationary chain, so a Bernstein inequality for Markov chains with a spectral gap gives the second exponential; it carries the positive dependence, since misses cluster when the environment lingers in states where ACI is biased. In the noise piece the feedback helps: given the states, αt\alpha_t decreases with the number of past misses, so Chebyshev's association inequality factors the moment generating function as if the misses were independent, and Hoeffding's lemma gives 2e−Tε2/82e^{-T\varepsilon^2/8}. With several states that Hoeffding-rate term is not established (my note, not in the paper): after each switch αt\alpha_t lags the new target, the lag depends on the whole state path, so it lands in the noise piece and is positively correlated over time. In a two-state check (sticky chain, α∗∈{0.1,0.5}\alpha^*\in\{0.1,0.5\}, γ=0.005\gamma=0.005, T=4000T=4000) the noise piece exceeds its claimed tail, about 0.0050.005 against 2e−Tε2/8≈0.00152e^{-T\varepsilon^2/8}\approx0.0015 at ε=0.12\varepsilon=0.12. The written proof misses this by applying Hoeffding's lemma conditionally on α1\alpha_1 and the states, where errt−E[errt∣At]\mathrm{err}_t-\mathbb E[\mathrm{err}_t|A_t] need not be centered; centering at the mean given the whole state path makes the feedback argument sound but leaves the gap to E[errt∣At]\mathbb E[\mathrm{err}_t|A_t] uncontrolled. Whether the theorem's bound holds with several states is open (that check does not contradict it, because its second term exceeds 1 there), so under regime switches expect misses to cluster more than i.i.d.

Step 5

In experiments ACI holds local coverage, and the score determines how much it must correct. On two real sequences ACI holds local coverage where fixed α\alpha drifts, and the score decides how much drift ACI has to absorb (α=0.1\alpha=0.1, γ=0.005\gamma=0.005, local coverage over a moving window against the spread of i.i.d. Bernoulli(0.1) misses). Volatility: GARCH(1,1) forecasts of squared daily returns with the normalized score ∣Vt−σ^t2∣/σ^t2|V_t-\hat\sigma_t^2|/\hat\sigma_t^2; fixed-α\alpha coverage wanders between about 0.85 and 0.95 on four stocks picked from twelve because it fails on them, while ACI stays inside the Bernoulli band (on all twelve). With the unnormalized score, fixed-α\alpha coverage falls to about 0.4 for Fannie Mae and ACI's coverage swings much more widely, which a larger γ\gamma only partly fixes, as Steps 3 and 4 predict, since what matters is how fast αt∗\alpha_t^* moves. Election night: CQR on 2020 county vote totals in reporting order; fixed α\alpha falls to about 0.83 after time-zone changes, while ACI stays near 0.9. Both are illustrations on a handful of series with a hand-picked γ\gamma.

Consequences and limits. ACI is a one-line wrapper that drives any conformal method's long-run miss rate to α\alpha on any sequence, drifting or adversarial, and under slow drift it also tracks per-step coverage, with γ\gamma set by how fast the right level moves. The guarantee is about frequency only: it says nothing about set size, and a method that outputs the whole line 90% of the time and the empty set otherwise also satisfies it; infinite sets occur whenever αt<0\alpha_t<0. Most of the work is done by the score and the refit model, which should make αt∗\alpha_t^* nearly stationary, as the normalized volatility score does. The finer theory needs a fixed quantile function, a stationary start and a hidden Markov model, γ\gamma is chosen by hand, and each label must arrive before the next prediction. The last point matters in fraud, where chargebacks arrive weeks late and the loop would run on stale errors; the paper lists delayed feedback as open. Later work chooses γ\gamma online by aggregating copies of ACI (Gibbs and Candès, 2022) and recasts the update as a controller on the score quantile (Angelopoulos et al., 2023).

Terms

αt\alpha_t
The working level fed to the calibration quantile, C^t={y:St≤Q^t(1−αt)}\hat C_t=\{y:S_t\le\hat Q_t(1-\alpha_t)\}; ACI's only state.
αt+1=αt+γ(α−errt)\alpha_{t+1}=\alpha_t+\gamma(\alpha-\mathrm{err}_t)
The update: a miss widens the next set, a hit narrows it. It is subgradient descent on the pinball loss.
αt∗\alpha_t^*
The level that would give exact coverage 1−α1-\alpha at time tt; the moving target ACI tracks.
αt∈[−γ,1+γ]\alpha_t\in[-\gamma,1+\gamma]
Confinement: outside [0,1][0,1] the set is the whole line or empty, which pushes αt\alpha_t back.
Long-run bound
∣1T∑errt−α∣≤(max⁡{α1,1−α1}+γ)/(γT)|\frac1T\sum\mathrm{err}_t-\alpha|\le(\max\{\alpha_1,1-\alpha_1\}+\gamma)/(\gamma T) on every sequence.
Drift DD
E∣αAt+1∗−αAt∗∣\mathbb E|\alpha^*_{A_{t+1}}-\alpha^*_{A_t}|: the size of the shift, measured in the level needed for exact coverage.
Lag versus jitter
E(M(αt∣At)−α)2≤L(1+γ)D/γ+Lγ/2\mathbb E(M(\alpha_t|A_t)-\alpha)^2\le L(1+\gamma)D/\gamma+L\gamma/2, best at γ=2D\gamma=\sqrt{2D}.
B, σB2B,\ \sigma_B^2
Worst-state and average squared bias of the miss rate given the hidden state; B≲γ+ϵ1/γB\lesssim\gamma+\epsilon_1/\gamma.
Negative association
A miss lowers αt\alpha_t and widens the next set, so, given the states, the misses concentrate around their conditional means at least as fast as i.i.d. Bernoulli.
Local coverage
Coverage averaged over a moving window (500 days, 300 counties), compared with the spread of i.i.d. Bernoulli misses.

Quiz

  1. What does the noiseless linear example after the long-run proposition show?
  2. In the volatility example, why does dividing the score by σ^t2\hat\sigma_t^2 improve ACI's coverage?
  3. With γ=0.005\gamma=0.005 and α1=α=0.1\alpha_1=\alpha=0.1, which outcome does the long-run proposition not rule out?

Sources