This repository contains code implementations for the following conformal prediction methods:
- Conformal Thresholded Intervals for Efficient Regression
- Entropy Reweighted Conformal Classification
This project is built upon the Python toolbox TorchCP.
This paper introduces Conformal Thresholded Intervals (CTI), a novel conformal regression method that aims to produce the smallest possible prediction set with guaranteed coverage.
- Utilizes multi-output quantile regression to estimate conditional interquantile intervals.
- Constructs prediction sets by thresholding these intervals based on their length.
- Guarantees marginal coverage and can achieve optimal conditional coverage under certain conditions.
- Computationally efficient and avoids estimating full conditional distributions.
- Produces potentially non-convex prediction sets that adapt to local data density.
Interquantile intervals:
Prediction set:
Where:
-
$q_k(x)$ = estimated$k/K$ quantile -
$t$ = threshold determined on calibration set -
$\mu$ = Lebesgue measure
- Train a quantile regression model on training data.
- Estimate interquantile intervals on calibration and test data.
- Determine threshold
$t$ using the calibration set. - Construct prediction sets for test points by thresholding intervals.
-
Marginal coverage:
$P(Y \in C(X)) \geq 1 - \alpha$ - Can achieve optimal conditional coverage and smallest expected prediction set size under certain conditions.
This paper proposes Entropy Reweighted Conformal Classification, a novel approach to improve the efficiency of prediction sets in conformal classification.
- Leverages the uncertainty of the classifier by using entropy-based reweighting.
- Applies a reweighting to the logits of the classification model based on the entropy of the predicted probability distribution.
- The reweighted logits are defined as:
$\tilde{z}_k(X) = \frac{z_k(X)}{H(X) \cdot T}$ where:-
$z_k(X)$ = original logit -
$H(X)$ = entropy of the predicted probability distribution -
$T$ = temperature parameter
-
- The reweighted probabilities are obtained by applying the softmax function to the reweighted logits:
$\tilde{f}_k(X) = \frac{\exp(\tilde{z}_k(X))}{\sum_j \exp(\tilde{z}_j(X))}$ - These reweighted probabilities are used to compute the conformity scores for conformal prediction.
- The temperature parameter
$T$ is optimized using cross-validation on a separate validation set. - Aims to improve the efficiency of prediction sets while maintaining the coverage guarantees of conformal prediction.
- Experimental results on various datasets (AG News, CAREER, MNIST, Fashion MNIST) demonstrate improved performance in terms of prediction efficiency and accuracy compared to existing techniques.
Prediction Set:
Where:
-
$A_n = a(f(X_n), Y_n)$ , conformity score $A_{N+1} = a(f(X_{N+1}), y_{N+1})$ -
$Q_A$ is the$(1-\alpha)$ -th sample quantile of$A_1, \dots, A_N$ $n\alpha = \lceil (1-\alpha)(|\mathcal{I}_2| + 1) \rceil$
Adaptive Prediction Sets (APS) Score:
Where:
-
$f_{(i)}(X_n)$ denotes the$i$ -th largest element of the probability vector$f(X_n)$ . -
$r(Y_n, f(X_n))$ is the rank of the true label$Y_n$ in the probability vector$f(X_n)$ . -
$U \sim \text{Uniform}(0,1)$ is independent of everything else.
- Train a classification model
$f$ on training data. - Compute entropy
$H(X)$ for each data point. - Apply entropy-based reweighting to logits.
- Compute reweighted probabilities.
- Calculate conformity scores using reweighted probabilities.
- Construct prediction sets using the conformal prediction framework.
- Optimize the temperature parameter
$T$ using cross-validation.
-
Marginal coverage:
$\mathbb{P}(Y_{N+1} \in C(X_{N+1})) \geq 1 - \alpha$ - Maintains the validity of conformal prediction while improving efficiency.
This approach integrates accurate uncertainty quantification with the coverage guarantees of conformal prediction, addressing limitations observed in previous attempts to combine confidence calibration with conformal prediction.
@inproceedings{luo2024entropy,
title={Entropy Reweighted Conformal Classification},
author={Luo, Rui and Colombo, Nicolo},
booktitle={The 13th Symposium on Conformal and Probabilistic Prediction with Applications},
pages={264--276},
year={2024},
organization={PMLR}
}
@article{luo2024conformal,
title={Conformal Thresholded Intervals for Efficient Regression},
author={Luo, Rui and Zhou, Zhixin},
journal={arXiv preprint arXiv:2407.14495},
year={2024}
}