Skip to content

pyconformal: Exact and Fast Conformal Prediction for Tabular Data and Time Series

Valery Manokhin

cs.LG

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.

Create a lesson