Skip to content

Evaluation, diagnostics, benchmarks, and additional tests · Evaluation, diagnostics, benchmarks, and additional hypothesis tests · EVA027 · Diagnostic

Split conformal prediction and coverage audit

Constructs prediction sets using held-out conformity scores, then audits coverage and set size.

Runs in CodeSplash Complete calculation CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page.

Do it in CodeSplash Run it on your own data, in Python or R.

Availability
Runs in CodeSplash
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
Verified in Python and R through evaluate.conformal_audit. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Constructs prediction sets using held-out conformity scores, then audits coverage and set size.

Question / hypotheses

Does the reported set contain future outcomes at the target marginal rate under the stated exchangeability conditions?

Architecture / computational structure

An independently fitted predictor produces a nonconformity score for each calibration case. Select the finite-sample corrected score quantile and invert the score inequality into a prediction set. Coverage auditing then measures inclusion and set size on a separate evaluation sample.

Assumptions

The fitted model must be independent of calibration labels, and calibration/test units must be exchangeable for the basic guarantee. Conditional or time-series coverage requires additional methods.

Formula / computational definition

q=s(⌈(n+1)(1−α)⌉),C(x)={y:s(x,y)≤q}.q=s_{(\lceil(n+1)(1-\alpha)\rceil)},\qquad C(x)=\{y:s(x,y)\le q\}.

Parameters and notation

s is a nonconformity score; n calibration size; alpha target miscoverage. If the order exceeds n, use an infinite cutoff. Score design and alpha are chosen before final evaluation.

Fitting, fine-tuning, and adaptation

Train the predictor before calibration and fit the threshold using calibration scores only. Fine-tuning the predictor, changing the nonconformity score, or selecting alpha using those labels can invalidate the original guarantee and calls for a justified recalibration scheme. Report marginal coverage and subgroup audits separately; they are different claims.

How to use and calibrate

Train, calibrate on a separate split, then measure test coverage and width. Audit important subgroups without claiming that marginal coverage automatically holds conditionally.

Example application

Wrap a neural forecast with residual-based uncertainty intervals.

Interpretation / pitfalls

Watch out

Distribution shift, grouped records, and repeated temporal observations can break exchangeability. A huge prediction set can achieve coverage without usefulness. Retraining or tuning the model after calibration requires recalibration.

Python and R code examples

Scope: Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.

Validation: Python — Executed successfully on synthetic inputs. R — reviewed but not executed in this environment. Python dependencies are explicit imports; R uses base R unless a package/bridge is explicitly named.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline. · needs numpy

import numpy as np
s=np.array([.1,.2,.3,.4,.5,.6,.7,.8,.9]); alpha=.2; n=len(s)
k=int(np.ceil((n+1)*(1-alpha))); q=np.inf if k>n else np.sort(s)[k-1]
print("interval",2.0-q,2.0+q)
R

Complete calculation — Mathematical calculation on synthetic inputs; not a complete benchmark pipeline.

s <- seq(.1,.9,.1); alpha <- .2; n <- length(s); k <- ceiling((n+1)*(1-alpha))
q <- if(k>n) Inf else sort(s)[k]; print(c(2-q,2+q))

Sources

From the CodeSplash reference, entry EVA027.