Skip to content

Conformalized quantile regression: intervals that adapt and still cover

Fit lower and upper quantiles, then widen or shrink them by one calibrated amount so the intervals cover at the chosen rate. The score, the rank, crossed quantiles, tiny calibration sets, and what marginal coverage leaves out.

Advanced ~13 min8 steps

What runs in CodeSplash

You will be able to

  • Compute the CQR score and the calibrated correction from the right order statistic
  • Explain why the correction can be negative and when the interval must be infinite
  • Handle crossed quantiles with a rule fixed before calibration
  • Tell marginal from group-conditional coverage, and name what breaks exchangeability

Read first

01

Quantiles alone don't cover

Read

Quantile regression fits a lower and an upper conditional quantile, say the 5th and 95th, by minimizing the pinball loss ρτ(u)=u(τ−1[u<0])\rho_\tau(u)=u(\tau-\mathbf 1[u<0]). The band adapts: narrow where outcomes are predictable, wide where they're noisy.

But nothing promises that a fitted 90% band covers 90% of new rows. Flexible models overfit their quantiles and cover too little; the next lesson's networks can be off in either direction. Conformalized quantile regression (CQR) keeps the adaptive shape and fixes the coverage with held-out data.

02

The score and the correction

Read

On mm calibration rows the model never trained on, score how far each outcome falls outside its band:

si=max⁡{q^L(xi)−yi,  yi−q^U(xi)}.s_i=\max\{\hat q_L(x_i)-y_i,\; y_i-\hat q_U(x_i)\}.

Positive means outside; negative means inside with room to spare. Take the kk-th smallest score with k=⌈(m+1)(1−α)⌉k=\lceil(m+1)(1-\alpha)\rceil, call it s^\hat s, and report [q^L(x)−s^, q^U(x)+s^][\hat q_L(x)-\hat s,\ \hat q_U(x)+\hat s] for a new row.

In the reference's example, m=8m=8 and α=0.2\alpha=0.2 give rank 8 and a correction of 0.200, added to both ends.

03

A negative correction

Predict

Predict first

Your CQR correction comes out negative. What happened?

It's a bug: corrections widen bandsThe bands were too wide; CQR narrows them
Reveal

The quantile bands were already too wide. Most calibration outcomes sat well inside them, so the right order statistic is negative and CQR shrinks every band by that amount. That's legitimate: the coverage promise holds in both directions.

04

Small calibration sets and crossed quantiles

Read

If kk exceeds mm, there is no score high enough and the honest interval is infinite. With 9 calibration rows you can't promise 95%: the rank would be 10. Keep enough calibration rows for the coverage you need, and don't swap in an interpolated quantile: it quietly breaks the finite-sample guarantee.

Two quantile models fit separately can cross, with the "lower" above the "upper" for some rows. Decide before calibrating whether to keep them or sort the pair (a rearrangement that never hurts the quantile loss), and calibrate with that rule.

05

What the promise covers

Read

The guarantee is marginal: averaged over new rows exchangeable with the calibration rows, coverage is at least 1−α1-\alpha. It says nothing about a particular subgroup: a rare group can be badly undercovered while the total looks perfect. Calibrating separately within each level of a column (Mondrian conformal) promises coverage per group, at the price of fewer calibration rows in each.

Exchangeability is the whole assumption. Time trends, rows clustered by patient or store, covariate shift, or choosing the model with the calibration rows all break it. Distribution-free doesn't mean assumption-free.

Let the noise grow with x and compare split conformal, scaled scores and CQR where the noise is largest.

HExplorable · Conformal coverage: marginal, conditional and under drift

A conformal interval promises 90% coverage. Over what, exactly, and when does the promise break?

Split conformal aims at 90%. When the noise grows with |x|, what share of points with |x| > 1.5 will it cover?

0.50
How sure?

Interval

Scaled divides residuals by a fitted spread; CQR conformalizes a rough quantile band; normal theory is the t interval.

100

The model is fit on n rows; the interval is calibrated on n more. As in the Simulation Lab's conformal design.

0.10

The interval aims to cover 1 − α of new points.

0.0

Noise SD is 1 + this × |x|. At 0 the noise is the same everywhere.

0.00

New points get (1 + drift) times the noise the interval was calibrated on.

Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

06

Where it stands in CodeSplash

Read
EntryIn CodeSplash
CQR (UNC009)Runs in the Predict run page's Uncertainty tab: Conformalized quantile regression (two quantile runs), calibrated on out-of-fold predictions, with When the quantiles cross and Coverage by group (Mondrian)

The tab computes CQR from saved predictions on the host, so a model trained in Python or R gets the same intervals. It isn't a registry method, so the readiness badge reads "Runs in CodeSplash (Predict)".

Reference · UNC009 · Runs in CodeSplash (Predict)Conformalized quantile regression (CQR)Calibrate fitted lower and upper conditional quantile functions to obtain finite-sample marginal prediction coverage.
07

Check your understanding

Checkpoint

Check yourself

A calibration row's outcome is 3 below its fitted lower quantile. What is its CQR score?

Show the answer

Answer: a

s=max⁡{q^L−y, y−q^U}s=\max\{\hat q_L-y,\ y-\hat q_U\} measures how far outside the band the outcome falls, on either side.

Check yourself

With 19 calibration rows and α = 10%, which calibration score sets the correction?

Show the answer

Answer: a

The +1 in (m+1)(m+1) accounts for the new row. That conservative rank is what makes the finite-sample guarantee hold.

Check yourself

You have 9 calibration rows and ask for 95% coverage. What does CQR return?

Show the answer

Answer: b

Small calibration sets limit the coverage you can promise. Collect more calibration rows or accept a lower level.

Check yourself

CQR covers 90% overall, but only 70% of rows from one rare region. Is the method broken?

Show the answer

Answer: b

Averaged coverage can hide a poorly served subgroup. Report coverage by prespecified groups.

08

Do it on your own data

In the app

Train two quantile runs (lower and upper) on the same split plan in Predict, open either run's Uncertainty tab, choose Conformalized quantile regression, set the rule for crossed quantiles, and read the coverage by group as well as overall.

Concepts in this lesson