pyconformal: Exact and Fast Conformal Prediction for Tabular Data and Time Series
Organizations: Independent Researcher
Abstract
Conformal prediction is used for its guarantee: if calibration and test data are exchangeable, a 90% split-conformal interval covers at least 90% of the time, for any model and any calibration size. That guarantee belongs to an exact procedure, and software loses it through small choices. We audited thirteen Python and R packages on data where the guarantee must hold, reading five conformal libraries module by module, and found about thirty faults. Two forecasting libraries cover 63% at a 90% target with their default of two calibration windows. One library's prediction sets cover 45% when rows are predicted one at a time. Two implementations of adaptive conformal inference clip the working level and lose the guarantee that defines the method. The basic split-conformal routines of the main libraries met their level in every test. We present pyconformal, an MIT-licensed package that implements about thirty conformal methods for regression, classification, probability calibration, predictive distributions, time series and panel data behind one interface. Every method is tested against its definition, against reference code where it exists, and against its guarantee. The package also contains algorithmic improvements: an exact Venn-Abers kernel in integer arithmetic, rank trees for online methods, closed forms for conformal predictive distributions, CV+ in 3 megabytes where MAPIE needs 3 gigabytes, and a repaired rule for conformal interquantile regression. With identical output, Venn-Abers calibration on a million points takes 0.37 seconds against 75 in the reference implementation, and conformal predictive intervals for a million test points take 0.01 seconds against 79 in crepes. We describe the design, the algorithms and what each gains in time and memory, the verification method, the audit and the benchmarks.
Figures & tables
| Regression | Split conformal [ 32 , 23 ] , normalised, Mondrian [ 48 ] , weighted [ 40 ] ; jackknife+ and CV+ [ 4 ] ; conformalised quantile regression (CQR) [ 33 ] ; conformal thresholded intervals (CTI) [ 26 ] ; conformal interquantile regression (CIR, CIR+) [ 17 ] , with the window rule changed as explained in Section 5 ; a quantile regression forest [ 30 ] with out-of-bag calibration; QuantileBooster , which makes CatBoost, XGBoost or LightGBM predict a grid of quantile levels for CQR, CTI and CIR |
| Classification | LAC [ 36 ] , APS [ 34 ] , RAPS [ 1 ] , SAPS [ 20 ] , each randomised or not, marginal, class-conditional or Mondrian by any category |
| Calibration | Inductive and cross Venn–Abers predictors [ 46 , 44 ] , binary and multiclass [ 28 ] |
| Predictive distributions | Conformal predictive systems [ 47 , 45 ] : quantiles, distribution function, intervals, CRPS; normalised and Mondrian; weighted for covariate shift [ 21 ] |
| Time series, online | ACI [ 14 ] , DtACI [ 15 ] , AgACI [ 53 ] , non-exchangeable conformal prediction [ 5 ] , conformal PID control [ 2 ] |
| Time series, ensembles and residual models | EnbPI [ 50 ] , SPCI [ 51 ] |
| Time series, multi-step | Multi-step split conformal prediction and AcMCP [ 49 ] ; conformal seasonal pools [ 29 ] |
| Package | What is wrong | Effect |
|---|---|---|
| statsforecast 2.1.1, mlforecast 1.1.0 | The interval half-width is the ordinary 90th percentile of past forecast errors, without the finite-sample correction that the conformal guarantee needs. By default only 2 past errors are used, and no valid finite 90% interval can be made from 2 errors. No warning is given. | Intervals are too narrow. Sold as 90%, they cover 63–65% at the default (4,000 series) and 86% with 20 calibration windows. |
| Darts 0.48.1 | When there are too few calibration errors for a valid finite interval, the largest error is used, with no warning, where the only valid interval is infinite. | 75% coverage in place of 90% with 3 calibration points. The default setting is correct. |
| TorchCP 1.2.1 | SAPS(randomized=False) scores the most likely class as 0 in calibration and as its probability in prediction, so the threshold does not match the sets it is applied to. | Sets are too small or empty: coverage 36% and 2.5% in place of 90% when top-1 accuracy is 82% and 89% (10 classes, weight 0.2). The default mode is correct. |
| crepes 0.9.1 | The CRPS of normalised predictive systems multiplies one term by the difficulty estimate twice. | The reported accuracy score is wrong: a true CRPS of 2.19 is reported as 7.19 at . Intervals are not affected. |
| Fault | Measured | On tracker |
|---|---|---|
| MAPIE 1.6.0 | ||
| ACI clips its working level to ; this is not the algorithm of [ 14 ] | Miss rate 13.7%, 19.8% and 33.4% on three drifting sequences, where the theorem allows 10.6%; unclipped 10.1%. On i.i.d. data 10.1% clipped and 10.0% unclipped | no |
| APS and RAPS with include_last_label=False | 81.5% and 83.6%; the docstring says coverage may be higher than the target | issue 1021 |
| Default RCPS bound: the test statistic is run on two halves of the data and the two maxima are added | Bound below the true risk in up to 19.7% of runs where 10% is allowed; 12.3% through the public class | pull request 998, closed unmerged |
| Default Holm procedure stops at an undefined p-value, so learn-then-test returns no threshold | No threshold in 161 of 300 runs; Bonferroni on the same data, 0 of 300. Validity not affected | no |
| crepes 0.9.1 | ||
| Method | Against | Theirs | Ours | Factor | Same |
|---|---|---|---|---|---|
| Venn–Abers, | venn-abers, MAPIE | 75.0 s | 0.366 s | 205 | yes |
| Venn–Abers, | venn-abers | 2.32 s | 0.079 s | 29 | yes |
| CPS intervals, | crepes | 79.2 s | 0.0098 s | 8,100 | yes |
| CPS CRPS, 5,000/5,000 | crepes | 0.309 s | 0.00047 s | 656 | yes a |
| Split regression, | PUNCC, crepes, MAPIE | 4.2–8.9 ms | 1.9 ms | 2–5 | yes |
| CQR, | MAPIE; PUNCC | 19.7; 10.5 ms | 3.2 ms | 6; 3 | yes |
| Series | Intervals | Coverage | Median width |
|---|---|---|---|
| US births | statsforecast, default | 61.1% | 518 |
| statsforecast, 10 windows | 80.8% | 890 | |
| pyconformal, multi-step split | 91.0% | 1,234 | |
| pyconformal, AcMCP, no scorecaster | 89.9% | 2,025 | |
| Saugeen River | statsforecast, default | 66.0% | 10.7 |
| statsforecast, 10 windows | 79.2% | 29.0 |
Appendix figures & tables15 assets
Supplementary material from the paper’s appendix.
Appendix
| Correct or safe | Not correct | ||||||
|---|---|---|---|---|---|---|---|
| Package | Exact, finite | Infinite | Refused, none valid | Too narrow | Too wide | Refused, one valid | Error |
| pyconformal | 1,056 | 184 | 0 | 0 | 0 | 0 | 0 |
| TorchCP 1.2.1 | 1,056 | 184 | 0 | 0 | 0 | 0 | 0 |
| MAPIE 1.6.0 | 1,056 | 0 | 184 | 0 | 0 | 0 | 0 |
| PUNCC 0.9.3 | 1,054 | 0 | 176 | 0 | 0 | 0 | 10 |
| conformalforecast 0.1.0 (Nixtla) | 1,046 | 0 | 184 | 0 | 0 | 10 | 0 |
| statsforecast | mlforecast | |||
|---|---|---|---|---|
| Calibration windows | distribution | error | distribution | error |
| 2 (default) | 0.634 | 0.645 | 0.634 | 0.645 |
| 5 | 0.776 | 0.781 | 0.773 | 0.781 |
| 10 | 0.823 | 0.830 | 0.824 | 0.832 |
| 20 | 0.860 | 0.862 | 0.862 | 0.865 |
| Scores | Calibration | Test | venn-abers | MAPIE | Ours | Ours, no Numba | Factor |
|---|---|---|---|---|---|---|---|
| Realistic | 0.087 | 0.086 | 0.0081 | 0.028 | 11 | ||
| Realistic | 2.317 | 2.258 | 0.0793 | 0.251 | 29 | ||
| Realistic | 74.96 | 75.65 | 0.3662 | 2.985 | 205 | ||
| Rounded (2 decimals) | 0.015 | 0.015 | 0.0033 | 0.004 | 5 | ||
| Rounded (2 decimals) | 0.144 | 0.126 | 0.0254 | 0.027 | 6 | ||
| Rounded (2 decimals) | 0.183 | 0.223 | 0.0687 | 0.100 | 3 |
| Task | Calibration | Test | crepes | Ours | Factor |
|---|---|---|---|---|---|
| 90% intervals | 0.0358 | 0.00015 | 241 | ||
| 90% intervals | 0.620 | 0.0010 | 602 | ||
| 90% intervals | 79.2 | 0.0098 | 8,126 | ||
| Distribution function | 0.081 | 0.0019 | 42 | ||
| Distribution function | 1.27 | 0.020 | 64 | ||
| Distribution function | 145 | 0.261 | 556 |
| Method, package | 10 classes | 100 classes | 1,000 classes |
|---|---|---|---|
| LAC, ours | 0.909 / 1.23 / 0.001 | 0.905 / 7.58 / 0.011 | 0.897 / 78.7 / 0.062 |
| LAC, TorchCP | 0.909 / 1.23 / 0.007 | 0.905 / 7.58 / 0.018 | 0.897 / 78.7 / 0.146 |
| LAC, MAPIE | 0.909 / 1.23 / 0.010 | 0.905 / 7.58 / 0.064 | 0.897 / 78.7 / 0.293 |
| LAC, PUNCC | 0.909 / 1.23 / 0.133 | 0.905 / 7.58 / 0.321 | 0.897 / 78.7 / 0.895 |
| APS randomised, ours | 0.899 / 1.73 / 0.008 | 0.901 / 8.38 / 0.066 | 0.899 / 78.4 / 0.364 |
| APS randomised, TorchCP | 0.907 / 1.76 / 0.017 | 0.900 / 8.41 / 0.276 | 0.899 / 78.7 / 1.696 |
| Method | Reference | Steps | Reference | Ours | Factor |
| Conformal PID (P) | authors’ code | 20,000 | 10.2 | 0.09 | 112 |
| Conformal PID (P+I) | authors’ code | 20,000 | 14.0 | 0.13 | 106 |
| ACI | authors’ code | 20,000 | 114 | 0.40 | 286 |
| DtACI, update step only | authors’ R code | 50,000 | 41 | 0.62 | 66 |
| AgACI, update step only | R code, 30 experts | 50,000 | 20 | 4.4 | 4.5 |
| Non-exchangeable CP | definition recomputed each step | 4,000 | 71 | 0.30 | 236 |
| Series (seasonal periods) | statsforecast 2.1.1 | pyconformal |
|---|---|---|
| 15-minute data, 6 weeks, 4,032 points | 3,145 | 6 |
| Hourly data, 1 year, 8,760 points | 1,698 | 12 |
| Hourly data, 11 years, 100,000 points | 19,300 | 98 |
| Call | Against | Calibration / test | Theirs | Ours | Ratio |
|---|---|---|---|---|---|
| CV+ prediction, 10 folds | MAPIE | 2,000 a / 20,000 | 1,300 | 3.2 | 406 |
| 5,000 a / 20,000 | 3,057 | 3.2 | 955 | ||
| CPS, 90% intervals | crepes | / | 20.1 | 3.1 | 6 |
| / | 197 | 31.5 | 6 | ||
| CPS, distribution function | crepes | / | 6.9 | 5.5 | 1.3 |
| / | 55.8 | 54.4 | 1.0 |
| Dataset | Model | Pinball | CQR | CIR+ | Fit (s) | Predict (s) |
|---|---|---|---|---|---|---|
| California housing | quantile-forest (Zillow) | 0.129 | 1.87 | 1.43 | 1.5 | 0.14 |
| QuantileForest | 0.124 | 1.70 | 1.41 | 0.23 | 0.08 | |
| CatBoost | 0.119 | 1.36 | 1.38 | 6.4 | 0.02 | |
| XGBoost | 0.123 | 1.49 | 1.40 | 9.2 | 0.28 | |
| LightGBM | 0.116 | 1.36 | 1.34 | 7.1 | 0.98 | |
| kin8nm | quantile-forest (Zillow) | 0.048 | 0.573 | 0.532 | 0.65 | 0.07 |
| Machine | 2 virtual cores (Intel Xeon, 2.1 GHz), 7 GB memory, Linux |
|---|---|
| Python | 3.13; Numba 0.68.1, scikit-learn 1.9.1, SciPy 1.17.1; NumPy 2.5.5 (OpenBLAS 0.3.34), or NumPy 1.26.4 with PyTorch 2.15 in the environment used for MAPIE, TorchCP and PUNCC |
| Packages | MAPIE 1.6.0, crepes 0.9.1, TorchCP 1.2.1, PUNCC 0.9.3, venn-abers 1.5.4, statsforecast 2.1.1, mlforecast 1.1.0, Darts 0.48.1, conformalforecast 0.1.0 (Nixtla), conformal-tights 0.5.0, online-cp 0.4.0, quantile-forest 1.5.0, R forecast 9.0.2, R conformalForecast 0.2.1.9000 (development version) |
| Threads | defaults (2 for BLAS and Numba); not pinned |
| Precision | 64-bit floats throughout |
| Timing | best of 3 runs (single run where one run exceeds a minute); compiled kernels warmed up first |
| Seeds | fixed in every script (NumPy default_rng with the seed given in the script) |
| Method, model | Package | Median | 95th pct. | 99th pct. | Max |
|---|---|---|---|---|---|
| ACI, zero-cost model | MAPIE | 620 | 943 | 1,054 | 3,641 |
| pyconformal | 9.3 | 10.9 | 28.9 | 164 | |
| ACI, model costing 100 s per call | MAPIE | 695 | 902 | 1,228 | 2,944 |
| pyconformal | 111 | 128 | 156 | 575 | |
| EnbPI, 30 linear models | MAPIE | 5,737 | 8,230 | 10,378 | 13,871 |
| pyconformal | 2,080 | 2,742 | 4,515 | 6,434 |
| Configuration | Ratio | ||
|---|---|---|---|
| Continuous scores, informative | 0.035 | 0.489 | 14.0 |
| Pure noise | 0.030 | 0.391 | 13.0 |
| Anti-correlated | 0.018 | 0.254 | 14.0 |
| Perfectly separated | 0.013 | 0.237 | 18.1 |
| Labels alternate in score order | 0.016 | 0.244 | 14.8 |
| Blocks of equal labels | 0.016 | 0.271 | 17.1 |
| Mode | Raw coverage | Coverage after CQR | Length after CQR | Pinball loss | Predict (s) |
|---|---|---|---|---|---|
| Exact | 0.900 | 0.901 (0.002) | 3.705 (0.014) | 0.1379 (0.0008) | 0.144 |
| One sample per leaf | 0.895 | 0.902 (0.001) | 3.802 (0.012) | 0.1402 (0.0008) | 0.074 |
| Classes | Seconds | ns per row and class | Coverage | Mean set size | Input / peak memory (MB) |
|---|---|---|---|---|---|
| 100 | 0.005 | 26 | 0.898 | 8.5 | 3 / 427 |
| 1,000 | 0.053 | 27 | 0.905 | 82 | 32 / 434 |
| 10,000 | 0.669 | 34 | 0.903 | 839 | 320 / 1,371 |
| 30,000 | 2.018 | 34 | 0.904 | 2,257 | 960 / 3,247 |
| Outcome | Target | CQR | CIR (default) | CIR, authors’ rule | CIR+ | CTI |
|---|---|---|---|---|---|---|
| Skewed (gamma) | 90% | .900(1) / 5.59 | .906(1) / 5.12 | .905(1) / 5.11 | .901(1) / 5.04 | .899(1) / 4.95 |
| 80% | .802(1) / 4.30 | .806(1) / 3.84 | .802(1) / 3.78 | .801(1) / 3.79 | .801(1) / 3.86 | |
| Symmetric (normal) | 90% | .900(1) / 4.23 | .904(1) / 4.35 | .902(1) / 4.31 | .900(1) / 4.29 | .900(1) / 4.26 |
| 80% | .799(1) / 3.26 | .804(1) / 3.36 | .800(1) / 3.29 | .799(1) / 3.33 | .800(1) / 3.39 | |
| Bimodal (two normals) | 90% | .900(1) / 7.00 | .906(1) / 7.60 | .883(1) / 6.95 | .901(1) / 7.57 | .900(1) / 4.85 |
| 80% | .801(1) / 6.29 | .806(1) / 7.10 | .769(1) / 6.16 | .802(1) / 7.08 | .800(1) / 3.81 |