TorchCP: A Python Library for Conformal Prediction

Jianguo Huang, Jianqing Song, Xuanning Zhou, Bingyi Jing, Hongxin Wei
2/20/2024
12 citations
cs.LGcs.CVmath.ST
gnn

Official code: ml-stat-Sustech/TorchCP (481 stars, Python, LGPL-3.0, last commit 2025-11-01).

Abstract

Conformal prediction (CP) is a powerful statistical framework that generates prediction intervals or sets with guaranteed coverage probability. While CP algorithms have evolved beyond traditional classifiers and regressors to sophisticated deep learning models like deep neural networks (DNNs), graph neural networks (GNNs), and large language models (LLMs), existing CP libraries often lack the model support and scalability for large-scale deep learning (DL) scenarios.

Show full abstract

This paper introduces TorchCP, a PyTorch-native library designed to integrate state-of-the-art CP algorithms into DL techniques, including DNN-based classifiers/regressors, GNNs, and LLMs. Released under the LGPL-3.0 license, TorchCP comprises about 16k lines of code, validated with 100\% unit test coverage and detailed documentation. Notably, TorchCP enables CP-specific training algorithms, online prediction, and GPU-accelerated batch processing, achieving up to 90\% reduction in inference time on large datasets. With its low-coupling design, comprehensive suite of advanced methods, and full GPU scalability, TorchCP empowers researchers and practitioners to enhance uncertainty quantification across cutting-edge applications.

View on arXivView PDF

Code Implementations(1)

LGPL-3.0

A Python toolbox for conformal prediction research on deep learning models, using PyTorch.

48153PythonDec 6, 20231 years agoLGPL-3.0
classificationconformal-predictiongraphlarge-language-modelsregression+1 more

Similar Papers

Cite this paper

@article{huang2024torchcp,
  title  = {TorchCP: A Python Library for Conformal Prediction},
  author = {Jianguo Huang and Jianqing Song and Xuanning Zhou and Bingyi Jing and Hongxin Wei},
  year   = {2024},
  eprint = {2402.12683},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.12683v5}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.12683.svg)](https://codeofpaper.com/paper/2402.12683)

Discussion