Abstract
PUNCC is an open-source Python library designed to provide a unified, framework-agnostic toolkit for Conformal Prediction (CP). Compatible with PyTorch, TensorFlow, and scikit-learn, it enables the transformation of standard point predictions into uncertainty intervals with rigorous mathematical guarantees. This paper introduces the library's modular architecture and demonstrates its utility across regression, classification, and time-series tasks, highlighting its ability to maintain valid coverage even under distribution shifts.
Introduction
Machine learning models often produce overconfident point predictions without quantifying uncertainty, which is critical for high-stakes decision-making. Conformal Prediction (CP) offers a distribution-free, model-agnostic alternative with non-asymptotic guarantees. However, implementing these algorithms can be complex and fragmented. PUNCC addresses this gap by providing a standardized, modular library that integrates various CP procedures into a single, easy-to-use workflow.
Methods and Architecture
PUNCC is built around a modular Predictor-Calibrator-Splitter paradigm, designed to decouple model interfaces from conformalization logic.
- Predictor: A wrapper that standardizes model interfaces across different frameworks (e.g., scikit-learn, PyTorch), ensuring consistent behavior.
- Calibrator: The core component responsible for computing nonconformity scores and constructing final prediction sets or intervals.
- Splitter: Manages data partitioning for training and calibration, supporting schemes like K-fold cross-validation and time-series-specific splits.
The library implements a wide array of algorithms, including Split Conformal Prediction (SCP), Conformalized Quantile Regression (CQR), and Regularized Adaptive Prediction Sets (RAPS). A key feature is the caching of nonconformity scores, allowing for rapid generation of prediction sets across multiple confidence levels.
Experimental Evaluation
The authors evaluated PUNCC across three distinct domains to demonstrate its versatility and efficiency.
Regression and Classification
On the California Housing dataset, adaptive methods like CQR and CV+ achieved target coverage with intervals up to 50% narrower than standard SCP. In image classification tasks using the Imagewoof dataset, the RAPS method significantly improved efficiency, reducing the average prediction set size from 40.6 to 21.2 classes while maintaining a 90% coverage guarantee.
Time-Series and Distribution Shift
A critical challenge for CP is handling non-exchangeable data, such as time-series with distribution drifts. Using the Elec2 electricity market dataset, PUNCC's implementation of Weighted Split Conformal Prediction (WSCP) and EnbPI demonstrated superior robustness.
While baseline methods saw coverage drop to as low as 60% during shifts, WSCP maintained the target 90% coverage by weighting recent data more heavily, as shown in the visualization of electricity transfer predictions.
Conclusion
PUNCC simplifies the application of Conformal Prediction in real-world workflows by providing a robust and flexible framework. By standardizing complex CP procedures, it lowers the barrier to entry for rigorous uncertainty quantification. Future developments will focus on expanding the library to include anomaly detection, multivariate predictions, and advanced online learning methods.
Summary updated