Year: 2021

Abstract:
Modern deep learning based classifiers show very high accuracy on test data but this does not provide sufficient guarantees for safe deployment, especially in highstake AI applications such as medical diagnosis. Usually, predictions are obtained without a reliable uncertainty estimate or a formal guarantee. Conformal prediction (CP) addresses these issues by using the classifier’s predictions, e.g., its probability estimates, to predict confidence sets containing the true class with a user-specified probability. However, using CP as a separate processing step after training prevents the underlying model from adapting to the prediction of confidence sets. Thus, this paper explores strategies to differentiate through CP during training with the goal of training model with the conformal wrapper end-to-end. In our approach, conformal training (ConfTr), we specifically “simulate” conformalization on mini-batches during training. Compared to standard training, ConfTr reduces the average confidence set size (inefficiency) of state-of-the-art CP methods applied after training. Moreover, it allows to “shape” the confidence sets predicted at test time, which is difficult for standard CP. On experiments with several datasets, we show ConfTr can influence how inefficiency is distributed across classes, or guide the composition of confidence sets in terms of the included classes, while retaining the guarantees offered by CP.

heading: 1 INTRODUCTION
text: In classification tasks, for input x, we approximate the posterior distribution over classes y ∈ [K] := {1, . . . ,K}, denoted πy(x) ≈ P (Y = y|X = x). Following Bayes’ decision rule, the single class with highest posterior probability is predicted for optimizing a 0-1 classification loss. This way, deep networks πθ,y(x) with parameters θ achieve impressive accuracy on held-out test sets. However, this does not guarantee safe deployment. Conformal prediction (CP) (Vovk et al., 2005) uses a posttraining calibration step to guarantee a user-specified coverage: by allowing to predict confidence sets C(X) ⊆ [K], CP guarantees the true class Y to be included with confidence level α, i.e. P (Y ∈ C(X)) ≥ 1 − α when the calibration examples (Xi, Yi), i ∈ Ical are drawn exchangeably from the test distribution. This is usually achieved in two steps: In the prediction step, so-called conformity scores (w.r.t. to a class k ∈ [K]) are computed to construct the confidence sets C(X). During the calibration step, these conformity scores on the calibration set w.r.t. the true class Yi are ranked to determine a cut-off threshold τ for the predicted probabilities πθ(x) guaranteeing coverage 1−α. This is called marginal coverage as it holds only unconditionally, i.e., the expectation is being taken not only w.r.t. (X,Y ) but also over the distribution of all possible calibration sets, rather than w.r.t. the conditional distribution p(Y |X). CP also outputs intuitive uncertainty estimates: larger confidence sets |C(X)| generally convey higher uncertainty. Although CP is agnostic to details of the underlying model πθ(x), the obtained uncertainty estimates depend strongly on the model’s performance. If the underlying classifier is poor, CP results in too large and thus uninformative confidence sets. “Uneven” coverage is also a common issue, where lower coverage is achieved on more difficult classes. To address such problems, the threshold CP method of (Sadinle et al., 2019) explicitly minimizes inefficiency. Romano et al. (2020) and Cauchois et al. (2020) propose methods that perform favorably in terms of (approximate) conditional coverage. The adaptive prediction sets (APS) method of Romano et al. (2020) is further extended by Angelopoulos et al. (2021) to return smaller confidence sets. These various objectives are typically achieved by changing the definition of the conformity scores. In all cases, CP is used as a post-training calibration step. In contrast, our work does not focus on advancing CP
itself, e.g., through new conformity scores, but develops a novel training procedure for the classifier πθ. After training, any of the above CP methods can readily be applied.
Indeed, while the flexibility of CP regarding the underlying model appears attractive, it is also a severe limitation: Learning the model parameters θ is not informed about the post-hoc “conformalization”, i.e., they are are not tuned towards any specific objective such as reducing expected confidence set size (inefficiency). During training, the model will typically be trained to minimize cross-entropy loss. At test time, in contrast, it is used to obtain a set predictor C(X) with specific properties such as low inefficiency. In concurrent work, Bellotti (2021) addresses this issue by learning a set predictor C(X) through thresholding logits: Classes with logits exceeding 1 are included in C(X) and training aims to minimize inefficiency while targeting coverage 1 − α. In experiments using linear models only, this approach is shown to decrease inefficiency. However, (Bellotti, 2021) ignores the crucial calibration step of CP during training and does not allow to optimize losses beyond marginal coverage or inefficiency. In contrast, our work subsumes (Bellotti, 2021), but additionally considers the calibration step during training, which is crucial for further decreasing inefficiency. Furthermore, we aim to allow fine-grained control over class-conditional inefficiency or the composition of the confidence sets by allowing to optimize arbitrary losses defined on confidence sets.
Our contributions can be summarized as follows: 1. We propose conformal training (ConfTr), a procedure allowing to train model and conformal
wrapper end-to-end. This is achieved by developing smooth implementations of recent CP methods for use during training. On each mini-batch, ConfTr “simulates” conformalization, using half of the batch for calibration, and the other half for prediction and loss computation, c.f . Fig. 1 a©. After training, any existing CP method can provide a coverage guarantee.
2. In experiments, using ConfTr for training consistently reduces the inefficiency of conformal predictors such as threshold CP (THR) (Sadinle et al., 2019) or APS (Romano et al., 2020) applied after training. We further improve over (Bellotti, 2021), illustrating the importance of the calibration step during training.
3. Using carefully constructed losses, ConfTr allows to “shape” the confidence sets obtained at test time: We can reduce class-conditional inefficiency or “coverage confusion”, i.e., the likelihood of two or more classes being included in the same confidence sets, c.f . Fig. 1 b©. Generally, in contrast to (Bellotti, 2021), ConfTr allows to optimize arbitrary losses on the confidence sets.
Because ConfTr is agnostic to the CP method used at test time, our work is complementary to most related work, i.e., any advancement in terms of CP is directly applicable to ConfTr. For example, this might include conditional or application-specific guarantees as in (Sadinle et al., 2016; Bates et al., 2021). Most importantly, ConfTr preserves the coverage guarantee obtained through CP.

heading: 2 DIFFERENTIABLE CONFORMAL PREDICTORS
text: We are interested in training the model πθ end-to-end with the conformal wrapper in order to allow fine-grained control over the confidence sets C(X). Before developing differentiable CP methods for training in Sec. 2.2, we review two recently proposed conformal predictors that we use at test time. These consist of two steps, see Sec. 2.1: for prediction (on the test set) we need to define the confidence sets Cθ(X; τ) which depend on the model parameters θ through the predictions πθ and where the threshold τ is determined during calibration on a held-out calibration set (Xi, Yi), i ∈ Ical in order to obtain coverage.

heading: 2.1 CONFORMAL PREDICTORS
text: The threshold conformal predictor (THR) (Sadinle et al., 2019) constructs the confidence sets by thresholding probabilities: Cθ(x; τ) := {k : πθ,k(x) =: Eθ(x, k) ≥ τ}. Here, the subscript Cθ makes the dependence on the model πθ and its parameters θ explicit. During calibration, τ is computed as the α(1 + 1/|Ical|)-quantile of the so-called conformity scores Eθ(xi, yi) = πθ,yi(xi). The conformity scores indicate, for each example, the threshold that ensures coverage. Marginal coverage of (1 − α) is guaranteed on a test example (X,Y ). In practice, THR can also be applied on logits (THRL) or log-probabilities (THRLP) instead of probabilities.
Adaptive Prediction Sets (APS) (Romano et al., 2020) constructs confidence sets based on the ordered probabilities. Specifically, Cθ(x; τ) := {k : Eθ(x, k) ≤ τ} with:
Eθ(x, k) := πθ,y(1)(x) + . . .+ πθ,y(k−1)(x) + Uπθ,y(k)(x), (1)
where πθ,y(1)(x) ≥ . . . ≥ πθ,y(K)(x) and U is a uniform random variable in [0, 1] to break ties. Similar to THR, the conformity scores Eθ(xi, yi) w.r.t. the true classes yi are used for calibration, but the (1− α)(1 + 1/|Ical|)-quantile is required to ensure marginal coverage on test examples. Performance of CP is then measured using two metrics: (empirical and marginal) coverage (Cover) as well as inefficiency (Ineff). Letting Itest be a test set of size |Itest|, these metrics are computed as
Cover := 1 |Itest| ∑ i∈Itest δ[yi ∈ C(xi)] and Ineff := 1 |Itest| ∑ i∈Itest |C(xi)|, (2)
where δ denotes an indicator function that is 1 when its argument is true and 0 otherwise. Due to the marginal coverage guarantee provided by CP (c.f . (Romano et al., 2020) or App. C), the empirical coverage, when averaged across several calibration/test splits, is Cover ≈ 1− α. Thus, we concentrate on inefficiency as the main metric to compare across CP methods and models. With accuracy, we refer to the (top-1) accuracy with respect to the arg max-predictions, i.e., arg maxk πθ,k(x), obtained by the underlying model π. As shown in Fig. 2 (left), THR clearly outperforms THRL and APS w.r.t. inefficiency (lower is better) averaged across random Ical/Itest splits (details in Sec. F).
CP is intended to be used as a “wrapper” around πθ. “Better” CP methods generally result in lower inefficiency for a fixed model πθ. For example, following Fig. 2 (left), regularized APS (RAPS) (Angelopoulos et al., 2021) recently showed how to improve inefficiency compared to APS by modifying the conformity score – without outperforming THR, however. Fine-grained control over inefficiency, e.g., conditioned on the class or the composition of the C(X) is generally not possible. Integrating CP into the training procedure promises a higher degree of control, however, requires differentiable CP implementations, e.g., for THR or APS.
1: function PREDICT(πθ(x), τ ) 2: compute Eθ(x, k), k∈[K] 3: return Cθ(x; τ) = {k : Eθ(x, k) ≥ τ}
1: function CALIBRATE({(πθ(xi), yi}ni=1, α) 2: compute Eθ(xi, yi), i=1, . . . , n 3: return QUANTILE({Eθ(xi, yi)}, α(1 + 1/n))
1: function SMOOTHPRED(πθ(x), τ , T=1) 2: return Cθ,k(x; τ) =σ( (Eθ(x,k)−τ)T ), k∈ [K] 3: function SMOOTHCAL({(πθ(xi), yi}ni=1, α) 4: return SMOOTHQUANT({Eθ(xi, yi)}, α(1+ 1n ))
1: function CONFORMALTRAINING(α, λ=1) 2: for mini-batch B do 3: randomly split batch Bcal ]Bpred = B 4: {“On-the-fly” calibration on Bcal:} 5: τ = SMOOTHCAL({(πθ(xi), yi)}i∈Bcal ,α) 6: {Prediction only on i ∈ Bpred:} 7: Cθ(xi; τ) = SMOOTHPRED(πθ(xi), τ ) 8: {Optional classification loss:} 9: LB = 0 or ∑ i∈Bpred L(Cθ(xi; τ), yi)
10: ΩB = ∑ i∈Bpred Ω(Cθ(xi; τ)) 11: ∆ =∇θ1/|Bpred|(LB + λΩB) 12: update parameters θ using ∆
Algorithm 1: Smooth CP and Conformal Training (ConfTr): Top left: At test time, for THR, PREDICT computes the conformity scores Eθ(x, k) for each k∈[K] and constructs the confidence sets Cθ(x; τ) by thresholding with τ . CALIBRATE determines the threshold τ as the α(1 + 1/n)quantile of the conformity scores w.r.t. the true classes yi on a calibration set {(xi, yi)} of size n:=|Ical|. THR and APS use different conformity scores. Right and bottom left: ConfTr calibrates on a part of each mini-batch, Bcal. Thereby, we obtain guaranteed coverage on the other part, Bpred (in expectation across batches). Then, the inefficiency on Bpred is minimized to update the model parameters θ. Smooth implementations of calibration and prediction are used.

heading: 2.2 DIFFERENTIABLE PREDICTION AND CALIBRATION STEPS
text: Differentiating through CP involves differentiable prediction and calibration steps: We want Cθ(x; τ) to be differentiable w.r.t. the predictions πθ(x), and τ to be differentiable w.r.t. to the predictions πθ(xi), i ∈ Ical used for calibration. We emphasize that, ultimately, this allows to differentiate through both calibration and prediction w.r.t. the model parameters θ, on which the predictions πθ(x) and thus the conformity scores Eθ(x, k) depend. For brevity, we focus on THR, see Alg. 1 and discuss APS in App. D.
Prediction involves thresholding the conformity scores Eθ(x, k), which can be smoothed using the sigmoid function σ(z) = 1/1+exp(−z) and a temperature hyper-parameter T : Cθ,k(x; τ) := σ ((Eθ(x,k)−τ)/T). Essentially, Cθ,k(x; τ) ∈ [0, 1] represents a soft assignment of class k to the confidence set, i.e., can be interpreted as the probability of k being included. For T → 0, the “hard” confidence set will be recovered, i.e.,Cθ,k(x; τ) = 1 for k ∈ Cθ(x; τ) and 0 otherwise. For THR, the conformity scores are naturally differentiable w.r.t. to the parameters θ because E(x, k) = πθ,k(x).
As the conformity scores are already differentiable, calibration merely involves a differentiable quantile computation. This can be accomplished using any smooth sorting approach (Blondel et al., 2020; Cuturi et al., 2019; Williamson, 2020). These often come with a “dispersion” hyper-parameter such that smooth sorting approximates “hard” sorting for → 0. Overall, this results in the threshold τ being differentiable w.r.t. the predictions of the calibration examples {(πθ(xi), yi}i∈Ical and the model’s parameters θ.
As this approximation is using smooth operations, the coverage guarantee seems lost. However, in the limit of T, → 0 we recover the original non-smooth computations and the corresponding coverage guarantee. Thus, it is reasonable to assume that, in practice, we empirically obtain coverage close to (1− α). We found that this is sufficient because these smooth variants are only used during training. At test time, we use the original (non-smooth) implementations and the coverage guarantee follows directly from (Romano et al., 2020; Sadinle et al., 2019).
3 CONFORMAL TRAINING (CONFTR): Learning CONFORMAL PREDICTION
The key idea of conformal training (ConfTr) is to “simulate” CP during training, i.e., performing both calibration and prediction steps on each mini-batch. This is accomplished using the differentiable conformal predictors as introduced in Sec. 2.2. ConfTr can be viewed as a generalization of (Bellotti, 2021) that just differentiates through the prediction step with a fixed threshold, without considering the crucial calibration step, see App. E. In both cases, only the training procedure changes. After training, standard (non-smooth) conformal predictors are applied.

heading: 3.1 CONFTR BY OPTIMIZING INEFFICIENCY
text: ConfTr performs (differentiable) CP on each mini-batch during stochastic gradient descent (SGD) training. In particular, as illustrated in Fig. 1 a©, we split each mini-batch B in half: the first half is used for calibration, Bcal, and the second one for prediction and loss computation, Bpred. That is, on Bcal, we calibrate τ by computing the α(1 + 1/|Bcal|)-quantile of the conformity scores in a differentiable manner. It is important to note that we compute Cθ(xi; τ) only for i ∈ Bpred and not for i ∈ Bcal. Then, in expectation across mini-batches and large enough |Bcal|, for T, → 0, CP guarantees coverage 1−α on Bpred. Assuming empirical coverage to be close to (1−α) in practice, we only need to minimize inefficiency during training:
min θ
logE [Ω(Cθ(X; τ))] with Ω(Cθ(x; τ)) = max ( 0,
K∑ k=1 Cθ,k(x; τ)− κ
) . (3)
We emphasize that ConfTr optimizes the model parameters θ on which the confidence sets Cθ depend through the model predictions πθ. Here, Ω is a “smooth” size loss intended to minimize the expected inefficiency, i.e., E[|Cθ(X; τ)|], not to be confused with the statistic in Eq. (2) used for evaluation. Remember that Cπ,k(x; τ) can be understood as a soft assignment of class k to the confidence set Cθ(x; τ). By default, we use κ = 1 in order to not penalize singletons. However, κ ∈ {0, 1} can generally be treated as hyper-parameter. After training, any CP method can be applied to re-calibrate τ on a held-out calibration set Ical as usual, i.e., the thresholds τ obtained during training are not kept. This ensures that we obtain a coverage guarantee of CP.

heading: 3.2 CONFTR WITH CLASSIFICATION LOSS
text: In order to obtain more control over the composition of confidence setsCθ(X; τ) at test time, ConfTr can be complemented using a generic loss L:
min θ
log (E [L(Cθ(X; τ), Y ) + λΩ(Cθ(X; τ))]) . (4)
While L can be any arbitrary loss defined directly on the confidence sets Cθ, we propose to use a “configurable” classification loss Lclass. This classification loss is intended to explicitly enforce coverage, i.e., make sure the true label Y is included in Cθ(X; τ), and optionally penalize other classes k not to be included in Cθ, as illustrated in Fig. 1 b©. To this end, we define
Lclass(Cθ(x; τ), y) := K∑ k=1 Ly,k [ Cθ,k(x; τ) · δ[y = k]︸ ︷︷ ︸
enforce y to be in C
+ (1− Cθ,k(x; τ)) · δ[y 6= k]︸ ︷︷ ︸ penalize class k 6=y not to be in C
] . (5)
As above, Cθ,k(x; τ) ∈ [0, 1] such that 1 − Cθ(x; τ) can be understood as the likelihood of k not being in Cθ(x; τ). In Eq. (5), the first term is used to encourage coverage, while the second term can be used to avoid predicting other classes. This is governed by the loss matrix L: For L = IK , i.e., the identity matrix with K rows and columns, this loss simply enforces coverage (perfect coverage if Lclass = 0). However, setting any Ly,k > 0 for y 6= k penalizes the model from including class k in confidence sets with ground truth y. Thus, cleverly defining L allows to define rather complex objectives, as we will explore next. ConfTr with (optional) classification loss is summarized in Alg. 1 (right) and Python code can be found in App. P.

heading: 3.3 CONFTR WITH GENERAL AND APPLICATION-SPECIFIC LOSSES
text: We consider several use cases motivated by medical diagnosis, e.g., breast cancer screening (McKinney et al., 2020) or classification of dermatological conditions (Liu et al., 2020; Roy et al., 2021; Jain et al., 2021). In skin condition classification, for example, predicting sets of classes, e.g., the top-k conditions, is already a common strategy for handling uncertainty. In these cases, we not only care about coverage guarantees but also desirable characteristics of the confidence sets. These constraints in terms of the predicted confidence sets can, however, be rather complicated and pose difficulties for standard CP. We explore several exemplary use cases to demonstrate the applicability of ConfTr, that are also relevant beyond the considered use cases in medical diagnosis.
First, we consider “shaping” class-conditional inefficiency, formally defined as
Ineff[Y = y] := 1∑
i∈Itest δ[yi = y] ∑ i∈Itest δ[yi = y]|C(xi)|. (6)
Similarly, we can define inefficiency conditional on a group of classes. For example, we could reduce inefficiency, i.e., uncertainty, on “low-risk” diseases at the expense of higher uncertainty on “high-risk” conditions. This can be thought of as re-allocating time spent by a doctor towards high-risk cases. Using ConfTr, we can manipulate group- or class-conditional inefficiency using a weighted size loss ω · Ω(C(X; τ)) with ω := ω(Y ) depending on the ground truth Y in Eq. (3). Next, we consider which classes are actually included in the confidence sets. CP itself does not enforce any constraints on the composition of the confidence sets. However, with ConfTr, we can penalize the “confusion” between pairs of classes: for example if two diseases are frequently confused by doctors, it makes sense to train models that avoid confidence sets that contain both diseases. To control such cases, we define the coverage confusion matrix as
Σy,k := 1 |Itest| ∑ i∈Itest δ[yi = y ∧ k ∈ C(xi)]. (7)
The off-diagonals, i.e., Σy,k for y 6= k, quantify how often class k is included in confidence sets with true class y. Reducing Σy,k can be accomplished using a positive entry Ly,k > 0 in Eq. (5).
Finally, we explicitly want to penalize “overlap” between groups of classes in confidence sets. For example, we may not want to concurrently include very high-risk conditions among low-risk ones in confidence sets, to avoid unwanted anxiety or tests for the patient. Letting K0 ] K1 being two disjoint sets of classes, we define mis-coverage as
MisCover0→1 = 1∑ i∈Itest δ[yi ∈ K0] ∑ i∈Itest δ[yi ∈ K0 ∧ (∃k ∈ K1 : k ∈ C(xi))]. (8)
Reducing MisCover0→1 means avoiding classesK1 being included in confidence sets of classesK0. Again, we use Ly,k > 0 for y ∈ K0, k ∈ K1 to approach this problem. MisCover1→0 is defined analogously and measures the opposite, i.e., classes K0 being included in confidence sets of K1.

heading: 4 EXPERIMENTS
text: We present experiments in two parts: First, in Sec. 4.1, we demonstrate that ConfTr can reduce inefficiency of THR and APS compared to CP applied to a baseline model trained using crossentropy loss separately (see Tab. 1 for the main results). Thereby, we outperform concurrent work of Bellotti (2021). Second, in Sec. 4.2, we show how ConfTr can be used to “shape” confidence sets, i.e., reduce class-conditional inefficiency for specific (groups of) classes or coverage confusion of two or more classes, while maintaining the marginal coverage guarantee. This is impossible using (Bellotti, 2021) and rather difficult for standard CP.
We consider several benchmark datasets as well as architectures, c.f . Tab. A, and report metrics averaged across 10 random calibration/test splits for 10 trained models for each method. We focus on (non-differentiable) THR and APS as CP methods used after training and, thus, obtain the corresponding coverage guarantee. THR, in particular, consistently achieves lower inefficiency for a fixed confidence level α than, e.g., THRL (i.e., THR on logits) or RAPS, see Fig. 2 (left). We set α = 0.01 and use the same α during training using ConfTr. Hyper-parameters are optimized for THR or APS individually. We refer to App. F for further details on datasets, models, evaluation protocol and hyper-parameter optimization.

heading: 4.1 REDUCING INEFFICIENCY WITH CONFTR
text: In the first part, we focus on the inefficiency reductions of ConfTr in comparison to a standard crossentropy training baseline and (Bellotti, 2021) (Bel). After summarizing the possible inefficiency reductions, we also discuss which CP method to use during training and how ConfTr can be used for ensembles and generalizes to lower α.
Main Results: In Tab. 1, we summarize the inefficiency reductions possible through ConfTr (trained with THRLP) in comparison to Bel (trained with THRL) and the baseline. Bel does not consistently improve inefficiency on all datasets. Specifically, on MNIST, EMNIST or CIFAR100, inefficiency actually worsens. Our ConfTr, in contrast, reduces inefficiency consistently, not only for THR but also for APS. Here, improvements on CIFAR for THR are generally less pronounced. This is likely because we train linear models on top of a pre-trained ResNet (He et al., 2016) where features are not taking into account conformalization at test time, see App. J. For APS, in contrast, improvements are still significant. Across all datasets, training with Lclass generally performs slightly better, especially for datasets with many classes such as EMNIST (K=52) or CIFAR100 (K=100). Overall, ConfTr yields significant inefficiency reductions, independent of the CP method used at test time.
Conformal Predictors for Training: In Tab. 1, we use THRLP during training, irrespective of the CP method used at test time. This is counter-intuitive when using, e.g., APS at test time. However, training with THR and APS is rather difficult, as discussed in App. I. This is likely caused by limited gradient flow as both THR and APS are defined on the predicted probabilities instead of log-probabilities as used for THRLP or in cross-entropy training. Moreover, re-formulating the conformity scores of APS in Eq. (11) to use log-probabilities is non-trivial. In contrast, Bel has to be trained using THRL as a fixed threshold τ is used during training. This is because the calibration step is ignored during training. Also, fixing τ is not straightforward for THR due to the limited range of the predicted probabilities πθ,k(x) ∈ [0, 1], see App. E. We believe that this contributes to the poor performance of Bel on several datasets. Finally, we found that Bel or ConfTr do not necessarily recover the accuracy of the baseline. Remember that we refer to the accuracy in terms of the arg max-prediction of πθ. When training from scratch, accuracy can be 2-6% lower while still reducing inefficiency. This is interesting because ConfTr is still able to improve inefficiency, highlighting that cross-entropy training is not appropriate for CP.
Further Results: Tab. 2 includes additional results for ConfTr to “conformalize” ensembles on CIFAR10 (left) and with lower confidence levels α on EMNIST (right). In the first example, we consider applying CP to an ensemble of models. Ensemble CP methods such as (Yang & Kuchibhotla, 2021) cannot improve Ineff over the best model of the ensemble, i.e., 3.10 for THR. Instead,
training an MLP on top of the ensemble’s logits can improve Ineff to 2.40 and additionally using ConfTr to 2.35. The second example shows that ConfTr, trained for α=0.01, generalizes very well to significantly smaller confidence levels, e.g., α=0.001 on EMNIST. In fact, the improvement of ConfTr (without Lclass) in terms of inefficiency is actually more significant for lower confidence levels. We also found ConfTr to be very stable regarding hyper-parameters, see App. H. Only too small batch sizes (e.g., |B|=100 on MNIST) prevents convergence. This is likely because of too few examples (|Bcal|=50) for calibration with α=0.01 during training. More results, e.g., on binary datasets or including additional hyper-parameter ablation can be found in App. J.

heading: 4.2 CONFORMAL TRAINING FOR APPLICATIONS: CASE STUDIES
text: For the second part, we focus on ConfTr trained with THRLP and evaluated using THR. We follow Sec. 3.3 and start by reducing class- or group-conditional inefficiency using ConfTr (without Lclass), before demonstrating reductions in coverage confusion of two or more classes and avoiding miscoverage between groups of classes (with Lclass). Because this level of control over the confidence sets is not easily possible using Bel or standard CP, we concentrate on ConfTr only:
Shaping Conditional Inefficiency: We use ConfTr to reduce class-conditional inefficiency for specific classes or a group of classes, as defined in Eq. (6). In Fig. 2, inefficiency is shown to vary widely across classes: On CIFAR10, the more difficult class 3 (“cat”) obtains higher inefficiency than the easier class 1 (“automobile”). Thus, in Fig. 3, we use ω=10 as described in Sec. 3.3 to reduce class- or group-conditional inefficiency. We report the relative change in percentage, showing that inefficiency reductions of 20% or more are possible for many classes, including “cat” on CIFAR10 (left, blue). This is also possible for two groups of classes, “vehicles” vs. “animals” (middle). However, these reductions usually come at the cost of a slight increase in average inefficiency across all classes (green). On CIFAR100, we consider 20 coarse classes, each containing 5 of the 100 classes (right). Again, significant inefficiency reductions per coarse class are possible. These observations generalize to all other considered datasets and different class groups, see App. L.
Avoiding Coverage Confusion: Next, we use ConfTr to manipulate the coverage confusion matrix as defined in Eq. (7). Specifically, we intend to reduce coverage confusion of selected sets of classes.
Using a non-zero entry Ly,k > 0, y 6= k in Lclass, as described in Sec. 3.3, Fig. 4 (left) shows that coverage confusion can be reduced significantly for large enough Ly,k on Fashion-MNIST: Considering classes 4 and 6 (“coat” and “shirt”) confusion can be reduced by roughly 1%. However, as accuracy stays roughly the same and coverage is guaranteed, this comes at the cost of increasing coverage confusion for other class pairs, e.g., 2 (“pullover”) and 4. ConfTr can also be used to reduce coverage confusion of multiple class pairs (middle) or a whole row in the coverage confusion matrix Σy,k with fixed y and y 6=k∈[K]. Fig. 4 (right) shows the results for class 6: coverage confusion with, e.g., classes 0 (“t-shirt”), 2 or 4 (blue, green and violet) is reduced roughly 0.5% each at the cost of increased confusion of classes 2 and 4 (in gray). These experiments can be reproduced on other datasets, e.g., MNIST or CIFAR10 in App. M.
Reducing Mis-Coverage: We can also address unwanted “overlap” of two groups of classes using ConfTr and Lclass. In Fig. 5 (left) we explicitly measure mis-coverage as defined in Eq. (8). First, on CIFAR10, we consider a singleton group K0={3} (“cat”) and K1=[K] \ {3}: The ConfTr baseline MisCover0→1 tells us that 98.92% of confidence sets with true class 3 also contain other classes. Given an average inefficiency of 2.84 this is reasonable. Using L3,k = 1, k 6= 3, this can be reduced to 91.6%. Vice-versa, the fraction of confidence sets of class y 6=3 containing class 3 can be reduced from 36.52% to 26.43%. On CIFAR100, this also allows to reduce overlap between “human-made” (35 classes) and “natural” (65 classes) things, e.g., MisCover0→1 reduces from 40.09% to 15.77%, at the cost of a slight increase in inefficiency. See App. N for additional results.
Binary Datasets: Finally, in Fig. 5 (right), we illustrate that the above conclusions generalize to the binary case: On WineQuality, we can control inefficiency of class 0 (“bad wine”, minority class with ∼37% of examples) at the expense of increased inefficiency for class 1 (“good wine”, top). Similarly, we can (empirically) improve class-conditional coverage for class 0 (bottom) or manipulate coverage confusion of both classes, see App. O.

heading: 5 CONCLUSION
text: We introduced conformal training (ConfTr), a novel method to train conformal predictors endto-end with the underlying model. This addresses a major limitation of conformal prediction (CP) in practice: The model is fixed, leaving CP little to no control over the predicted confidence sets. In thorough experiments, we demonstrated that ConfTr can improve inefficiency of state-of-the-art CP methods such as THR (Sadinle et al., 2019) or APS (Romano et al., 2020). More importantly, motivated by medical diagnosis, we highlighted the ability of ConfTr to manipulate the predicted confidence sets in various ways. First, ConfTr can “shape” the class-conditional inefficiency distribution, i.e., reduce inefficiency on specific classes at the cost of higher inefficiency for others. Second, ConfTr allows to control the coverage-confusion matrix by, e.g., reducing the probability of including classes other than the ground truth in confidence sets. Finally, this can be extended to explicitly reduce “overlap” between groups of classes in the predicted confidence sets. In all cases, ConfTr does not lose the (marginal) coverage guarantee provided by CP.
ETHICS STATEMENT
Recent deep learning based classifiers, as used in many high-stakes applications, achieve impressive accuracies on held-out test examples. However, this does not provide sufficient guarantees for safe deployment. Conformal prediction (CP), instead, predicts confidence sets equipped with a guarantee that the true class is included with specific, user-specified probability. These confidence sets also provide intuitive uncertainty estimates. We specifically expect CP to be beneficial in the medical domain, improving trustworthiness among doctors and patients alike by providing performance guarantees and reliable uncertainty estimates. Yet, the current work does not contain experiments with personal/sensitive medical data. The presented results are on standard benchmark datasets only.
However, these benefits of CP may not materialize in many applications unless CP can be better integrated into existing classifiers. These are predominantly deep networks, trained end-to-end to, e.g., optimize classification performance. CP, in contrast, is agnostic to the underlying model, being applied as “wrapper” post-training, such that the obtained confidence sets may not be optimal, e.g., in terms of size (inefficiency) or composition (i.e., the included classes). Especially in the medical domain, constraints on the confidence sets can be rather complex. Our conformal training (ConfTr) integrates CP into the training procedure, allowing to optimize very specific objectives defined on the predicted confidence sets – without losing the guarantees. In medical diagnosis, smaller confidence sets may avoid confusion or anxiety among doctors or patients, ultimately leading to better diagnoses. For example, we can reduce inefficiency (i.e., the ambiguity of predicted conditions) for conditions that are particularly difficult for doctors to diagnose. Alternatively, ConfTr allows to avoid confusion between low- and high-risk conditions within the confidence sets.
Generally, beyond medical diagnosis, we believe ConfTr to have positive impact in settings where additional constraints on confidence sets are relevant in addition to the guarantees and uncertainty estimates provided by CP.
REPRODUCIBILITY STATEMENT
In order to ensure reproducibility, we include a detailed description of our experimental setup in App. F. We discuss all necessary information for conformal training (ConfTr) as well as our baselines. This includes architectures, training procedure and hyper-parameters, as well as preprocessing/data augmentation if applicable. Furthermore, we describe our evaluation procedure which includes multiple calibration/test splits for conformal prediction (CP) at test time as well as multiple training runs to capture randomness in the used calibration examples and during training. To this end, Tab. A reports the training/calibration/test splits of all used datasets and Tab. B the used hyper-parameters for ConfTr. While Alg. 1 already summarizes the used (smooth) threshold CP methods and our ConfTr, App. P (specifically Alg. B) lists the corresponding Python implementation of these key components.

heading: A OVERVIEW AND OUTLINE
text: In the appendix, we discuss an additional baseline, called coverage training (CoverTr), provide additional details on our experimental setup and include complementary results. Specifically, the appendix includes:
• Additional discussion of related work in Sec. B;
• Formal statement of the coverage guarantee obtained through conformal prediction (CP) in Sec. C;
• Differentiable implementation of APS in Sec. D;
• Discussion of coverage training (CoverTr) and (Bellotti, 2021) in Sec. E;
• Details on our experimental setup, including dataset splits, model details and used hyperparameters for ConfTr, in Sec. F;
• Experiments regarding random training and test trials in Sec. G;
• Hyper-parameter ablation on MNIST in Sec. H;
• CoverTr and ConfTr ablation on MNIST and Fashion-MNIST in Sec. I;
• Complete inefficiency (Ineff) results on all datasets in Sec. J;
• Effect of (standard) ConfTr on class-conditional inefficiency and coverage (Cover) confusion in Sec. K;
• Additional results for ConfTr shaping the class-conditional inefficiency distribution in Sec. L;
• More experiments for ConfTr manipulating coverage confusion in Sec. M;
• Complementary results for ConfTr reducing mis-coverage (MisCover) in Sec. N;
• Class-conditional inefficiency and coverage confusion on binary datasets in Sec. O;
• Python- and Jax (Bradbury et al., 2018) code for ConfTr in Sec. P.

heading: B RELATED WORK
text: Conformal prediction (CP) builds on early work by Vovk et al. (2005) considering both regression, see e.g., (Romano et al., 2019) for references, and classification settings, e.g. (Romano et al., 2020; Angelopoulos et al., 2021; Cauchois et al., 2020; Hechtlinger et al., 2018). Most of these approaches follow a split CP approach (Lei et al., 2013) where a held-out calibration set is used, as in the main paper, however, other variants based on cross-validation (Vovk, 2013) or jackknife (i.e., leave-oneout) (Barber et al., 2019a) are available. These approaches mostly provide marginal coverage. Vovk (2012); Barber et al. (2019b) suggest that it is generally difficult or impossible to obtain conditional coverage. However, Romano et al. (2020) work towards empirically better conditional coverage and Sadinle et al. (2019) show that efficient class-conditional coverage is possible. Angelopoulos et al. (2021) extend the work by Romano et al. (2020) to obtain smaller confidence sets at the expense of the obtained empirical conditional coverage. CP has also been studied in the context of ensembles (Yang & Kuchibhotla, 2021), allowing to perform model selection based on inefficiency while keeping coverage guarantees. The work of Bates et al. (2021) can be seen as a CP extension in which a guarantee on an arbitrary, user-specified risk can be obtained, using a conformal predictor similar to (Sadinle et al., 2019). Our conformal training (ConfTr) follows the split CP approach and is specifically targeted towards classification problems. Nevertheless, extensions to regression, or other CP formulations such as (Bates et al., 2021) during training, are possible. Beyond that, ConfTr is agnostic to the CP method used at test time and can thus be seen as complementary to the CP methods discussed above. This means that ConfTr can easily be combined with approaches such as (Bates et al., 2021) or class-conditional conformal predictors (Sadinle et al., 2019) at test time.
In terms of learning to predict confidence sets, our approach has similarities to the multiple choice learning of Guzmán-Rivera et al. (2012) which yields multiple possible outputs in structured prediction settings (e.g., image segmentation). However, the obtained prediction sets are fixed size and no coverage guarantee is provided. Concurrent work by Bellotti (2021) is discussed in detail in App. E.

heading: C COVERAGE GUARANTEE
text: Following Romano et al. (2020), we briefly state the coverage guarantee obtained by CP in formal terms: Given that the learning algorithm used is invariant to permutations of the training examples, and the calibration examples {(Xi, Yi)}i∈Ical are exchangeably drawn from the same distribution encountered at test time, the discussed CP methods satisfy
P (Y ∈ C(X)) ≥ 1− α. (9)
As highlighted in (Romano et al., 2020), this bound is near tight if the scoresE(xi) are almost surely distinct:
P (Y ∈ C(X)) ≤ 1− α+ 1 |Ical|+ 1 . (10)
Note that this is the case for APS due to the uniform random variable U in Eq. (11). (Romano et al., 2020) notes that there is generally no guarantee on conditional coverage, as this requires additional assumptions. However, class-conditional coverage can be obtained using THR as outlined in (Sadinle et al., 2019). Moreover, Sadinle et al. (2019) show that THR is the most efficient conformal predictor given a fixed model πθ, i.e., minimizes inefficiency. We refer to (Sadinle et al., 2019) for exact statements of the latter two findings.

heading: D DIFFERENTIABLE APS
text: Our differentiable implementation closely follows the one for THR outlined in Sec. 2.2. The main difference is the conformity score E(x, k) computation, i.e.,
Eθ(x, k) := πθ,y(1)(x) + . . .+ πθ,y(k−1)(x) + Uπθ,y(k)(x), (11)
where πθ,y(1)(x) ≥ . . . ≥ πθ,y(K)(x) and U is a uniform random variable in [0, 1] to break ties. As in the calibration step, we use an arbitrary smooth sorting approach for this. This implementation could easily be extended to include the regularizer of Angelopoulos et al. (2021), as well.

heading: E COVERAGE TRAINING
text: As intermediate step towards conformal training (ConfTr), we can also ignore the calibration step and just differentiate through the prediction step, i.e., Cθ(X; τ). This can be accomplished by fixing the threshold τ . Then, πθ essentially learns to produce probabilities that yield “good” confidence sets Cθ(X; τ) for the chosen threshold τ . Following Alg. A, coverage training (CoverTr) computes Cθ(X; τ) on each mini-batch using a fixed τ . The model’s parameters θ are obtained by solving
min θ
log (E [L(Cθ(X; τ), Y ) + λΩ(Cθ(X; τ))]) . (12)
Again, L is the classification loss from Eq. (5) and Ω the size loss from Eq. (3). The classification loss has to ensure that the true label y is in the predicted confidence set Cθ(X; τ) as the calibration step is missing. In contrast to ConfTr, CoverTr strictly requires both classification and size loss during training. This is because using a fixed threshold τ yields trivial solutions for both classification and size loss when used in isolation (i.e., L is minimized for Cθ(X; τ) = [K] and Ω is minimized for Cθ(X; τ) = ∅). Thus, balancing both terms in Eq. (12) using λ is crucial during training. As with ConfTr, the threshold τ is re-calibrated at test time to obtain a coverage guarantee. Choosing τ for training, in contrast, can be difficult: First, τ will likely evolve during training (when πθ gets
1: function COVERAGETRAINING(τ , λ) 2: for mini-batch B do 3: C(xi; τ) := SMOOTHPRED(πθ(xi), τ ), i∈B 4: LB := ∑ i∈B L(Cθ(xi; τ), yi)
5: ΩB := ∑ i∈B Ω(Cθ(xi; τ)) 6: ∆ := ∇θ1/|B|(LB + λΩB) 7: update parameters θ using ∆
Algorithm A: Coverage Training (CoverTr): Compared to Alg. 1 for ConfTr, CoverTr simplifies training by not differentiating through the calibration step and avoiding splitting the batch B in half. However, fixing the threshold τ can be a problem and training requires both coverage and size loss.
Table A: Used Datasets: Summary of train/calibration/test splits, epochs and models used on all datasets in our experiments. The calibration set is usually less than 10% of the training set. On most datasets, the test set is roughly two times larger than the calibration set. When computing random calibration/test splits for evaluation, see text, the number of calibration and test examples stays constant. * On Camelyon, we use features provided by Wilder et al. (2020) instead of the original images. ** For EMNIST, we use a custom subset of the “byClass” split.
Dataset Statistics Dataset Train Cal Test Dimensions Classes Epochs Model Camelyon2016* (Bejnordi et al., 2017) 280 100 17 31 2 100 1-layer MLP GermanCredit (Dua & Graff, 2017) 700 100 200 24 2 100 Linear WineQuality (Cortez et al., 2009) 4500 500 898 11 2 100 2-layer MLP MNIST (LeCun et al., 1998) 55k 5k 10k 28× 28 10 50 Linear EMNIST** (Cohen et al., 2017) 98.8k 5.2k 18.8k 28× 28 52 75 2-layer MLP Fashion-MNIST (Xiao et al., 2017) 55k 5k 10k 28× 28 10 150 2-layer MLP CIFAR10 (Krizhevsky, 2009) 45k 5k 10k 32× 32× 3 10 150 ResNet-34 CIFAR100 (Krizhevsky, 2009) 45k 5k 10k 32× 32× 3 100 150 ResNet-50
more and more accurate) and, second, the general ballpark of reasonable thresholds τ depends on the dataset as well as model and is difficult to predict in advance.
In concurrent work by Bellotti (2021) (referred to as Bel), the problem with fixing a threshold τ is circumvented by using THRL during training, i.e., THR on logits. As the logits are unbounded, the threshold can be chosen arbitrarily, e.g., τ = 1. As Bel also follows the formulation of Eq. (12), the approach can be seen as a special case of CoverTr. However, a less flexible coverage loss is used during training: Instead of Lclass, the loss is meant to enforce a specific coverage level (1 − α) on each mini-batch. This is done using a squared loss on coverage:
Lcov :=
[( 1
|B| ∑ i∈B Cθ,yi(xi; τ)
) − (1− α) ]2 (13)
for a mini-batch B of examples. In contrast to Eq. (12), Lcov is applied per batch and not per example. For the size loss, Bellotti (2021) uses κ = 0 in Eq. (3). Besides not providing much control over the confidence sets, Lcov also encourages coverage (1−α) instead of perfect coverage. Nevertheless, this approach is shown to improve inefficiency of THRL on various UCI datasets (Dua & Graff, 2017) using linear logistic regression models. The experiments in the main paper show that this generalizes to non-linear models and more complex datasets. Nevertheless, Bel is restricted to THRL which is outperformed significantly by both THR and APS. Thus, Bel is consistently outperformed by ConfTr in terms of inefficiency improvements. Moreover, the approach cannot be used for any of the studied use cases in Sec. 3.3.
Using CoverTr with THR and APS remains problematic. While we found τ ∈ [0.9, 0.99] (or [−0.1,−0.01 for THRLP) to work reasonably on some datasets, we had difficulties on others, as highlighted in Sec. I. Moreover, as CoverTr requires balancing coverage L and size loss Ω, hyperparameter optimization is more complex compared to ConfTr. By extension, these problems also limit the applicability of Bel. Thus, we would ideally want to re-calibrate the threshold τ after each model update. Doing calibration on a larger, held-out calibration set, however, wastes valuable training examples and compute resources. Thus, ConfTr directly calibrates on each mini-batch and also differentiates through the calibration step itself to obtain meaningful gradients.

heading: F EXPERIMENTAL SETUP
text: Datasets and Splits: We consider Camelyon2016 (Bejnordi et al., 2017), GermanCredit (Dua & Graff, 2017), WineQuality (Cortez et al., 2009), MNIST (LeCun et al., 1998), EMNIST (Cohen et al., 2017), Fashion-MNIST (Cohen et al., 2017) and CIFAR (Krizhevsky, 2009) with a fixed split of training, calibration and test examples. Tab. A summarizes key statistics of the used datasets which we elaborate on in the following. Except Camelyon, all datasets are provided by Tensorflow (Abadi et al., 2015)1. For Camelyon, we use the pre-computed features of Wilder et al. (2020) which
1https://www.tensorflow.org/datasets
are based on open source code from the Camelyon2016 challenge2. For datasets providing a default training/test split, we take the last 10% of training examples as calibration set. On Camelyon, we use the original training set, but split test examples into 100 validation and 17 test examples. This is because less than 100 calibration examples are not meaningful for α=0.05. As we evaluate 10 random calibration/test splits, the few test examples are not problematic in practice. On GermanCredit and WineQuality, we manually created training/calibration/test splits, roughly matching 70%/10%/20%. We use the “white wine” subset for WineQuality; to create a binary classification problem, wine with quality 6 or higher is categorized as “good wine” (class 1), following (Bellotti, 2021). Finally, for EMNIST, we consider a subset of the “byClass” split that contains 52 = 2 ·26 classes comprised of all lower and upper case letters. We take the first 122.8k examples, split as in Tab. A.
Models and Training: We consider linear models, multi-layer perceptrons (MLPs) and ResNets (He et al., 2016) as shown in Tab. A. Specifically, we use a linear model on MNIST and GermanCredit, 1- or 2-layer MLPs on Camelyon2016, WineQuality and Fashion-MNIST, and ResNet-34/50 (He et al., 2016) on CIFAR10/100. Models and training are implemented in Jax (Bradbury et al., 2018)3 and the ResNets follow the implementation and architecture provided by Haiku (Hennigan et al., 2020)4. Our l-layer MLPs comprise l hidden layers. We use 32, 256, 128, 64 units per hidden layer on Camelyon, WineQuality, EMNIST and Fashion-MNIST, respectively. These were chosen by grid search over {16, 32, 64, 128, 256}. In all cases, we use ReLU activations (Nair & Hinton) and batch normalization (Ioffe & Szegedy, 2015). We train using stochastic gradient descent (SGD) with momentum 0.0005 and Nesterov gradients. The baseline models are trained with cross-entropy loss, while ConfTr follows Alg. 1 and CoverTr follows Alg. A. Learning rate and batch size are optimized alongside the ConfTr hyper-parameters using grid search, see below. The number of epochs are listed in Tab. A and we follow a multi-step learning rate schedule, multiplying the initial learning rate by 0.1 after 2/5, 3/5 and 4/5 of the epochs. We use Haiku’s default initializer. On CIFAR, we apply whitening using the per-channel mean and standard deviation computed on the training set. On the non-image datasets (Camelyon, GermanCredit, WineQuality), we whiten each feature individually. On MNIST, EMNIST and Fashion-MNIST, the input pixels are just scaled to [−1, 1]. Except on CIFAR, see next paragraph, we do not use any data augmentation. Finally, we do not use Platt scaling (Guo et al., 2017) as used in (Angelopoulos et al., 2021).
Fine-Tuning on CIFAR: On CIFAR10 and CIFAR100, we train base ResNet-34/ResNet-50 models which are then fine-tuned using Bel, CoverTr or ConfTr. We specifically use a ResNet-34 with only 4 base channels to obtain an accuracy of 82.6%, using only random flips and crops as data augmentation. The rationale is to focus on the results for CP at test time, without optimizing accuracy of the base model. On CIFAR100, we use 64 base channels for the ResNet-50 and additionally employ AutoAugment (Cubuk et al., 2018) and Cutout (Devries & Taylor, 2017) as data augmentation. This model obtains 73.64% accuracy. These base models are trained on 100% of the training examples (without calibration examples). For fine-tuning, the last layer (i.e., logit layer) is re-initialized and trained using the same data augmentation as applied for the base model, subject to the random training trials described below. We also consider “extending” the ResNet by training a 2-layer MLP with 128 units per hidden layer on top of the features (instead of re-initializing and fine-tuning the logit layer). All reported results either correspond to fine-tuned (i.e., linear model on features) or extended models (i.e., 2-layer MLP on features) trained on these base models.
Hyper-Parameters: The final hyper-parameters selected for ConfTr (for THR at test time) on all datasets are summarized in Tab. B. These were obtained using grid search over the following hyper-parameters: batch size in {1000, 500, 100} for WineQuality, MNIST, EMNIST, Fashion-MNIST and CIFAR, {300, 200, 100, 50} on GermanCredit and {80, 40, 20, 10} on Camelyon; learning rate in {0.05, 0.01, 0.005}; temperature T ∈ {0.01, 0.1, 0.5, 1}; size weight λ ∈ {0.0001, 0.0005, 0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 5, 10} (c.f . Eq. (1), right); and κ ∈ {0, 1} (c.f . Eq. (3)). Grid search was done for each dataset individually on 100% of the training examples (c.f . Tab. A). That is, for hyper-parameter optimization we did not perform random training trials as described next. The best hyper-parameters according to inefficiency after evaluating 3 random calibration/test splits were selected, both for THR and APS at test time, with and without Lclass.
2https://github.com/arjunvekariyagithub/camelyon16-grand-challenge 3https://github.com/google/jax 4https://github.com/deepmind/dm-haiku
Table B: Used ConfTr Hyper-Parameters with and without Lclass for THRLP during training and THR at test time. The hyper-parameters for APS at test time might vary slightly from those reported here. The exact grid search performed to obtained these hyper-parameters can be found in the text. Note that, while hyper-parameters fluctuate slightly, λ needs to be chosen higher when training with Lclass. Additionally, and in contrast to Bel, κ = 1 in Eq. (3) performs better, especially combined with Lclass. Note that dispersion for smooth sorting is fixed to = 0.1.
ConfTr Hyper-Parameters (for THRLP during training and THR at test time)
Dataset, Method BatchSize Learning rate Temp. T Size weight λ κ in Eq. (3)
Camelyon, ConfTr 20 0.005 0.1 5 1 Camelyon, ConfTr +Lclass 10 0.01 0.01 5 1 GermanCredit, ConfTr 200 0.05 1 5 1 GermanCredit, ConfTr +Lclass 400 0.05 0.1 5 1 WineQuality, ConfTr 100 0.005 0.5 0.05 1 WineQuality, ConfTr +Lclass 100 0.005 0.1 0.5 1 MNIST, ConfTr 500 0.05 0.5 0.01 1 MNIST, ConfTr +Lclass 100 0.01 1 0.5 1 EMNIST, ConfTr 100 0.01 1 0.01 1 EMNIST, ConfTr +Lclass 100 0.01 1 5 1 Fashion-MNIST, ConfTr 100 0.01 0.1 0.01 0 Fashion-MNIST, ConfTr +Lclass 100 0.01 0.1 0.5 1 CIFAR10, fine-tune ConfTr 500 0.01 1 0.05 0 CIFAR10, fine-tune ConfTr +Lclass 500 0.05 0.1 1 1 CIFAR10, “extend” ConfTr 100 0.01 1 0.005 0 CIFAR10, “extend” ConfTr +Lclass 500 0.05 0.1 0.1 1 CIFAR100, fine-tune ConfTr 100 0.005 1 0.005 0 CIFAR100, fine-tune ConfTr +Lclass 100 0.005 1 0.01 1
Table C: Importance of Random Trials: We report coverage and inefficiency with the corresponding standard deviation across 10 test (left) and 10 training trials (right). ConfTr was trained using THRLP if not stated otherwise. For test trials, a fixed model is used. Results for training trials additionally include 10 test trials, but the standard deviation is reported only across the training trials. These results help to disentangle the impact of test and training trials. For example, while ConfTr with APS (during training) works in the best case, the standard deviation of 3.1 across multiple training trials indicates that training is not stable.
MNIST: test trials, Cover/Ineff for THR Method Acc Cover Ineff Baseline 92.45 99.09±0.2 2.23±0.15 ConfTr 90.38 99.05±0.2 2.14±0.13 ConfTr +Lclass 91.14 99.03±0.19 2.09±0.12 MNIST: Training trials, Cover/Ineff for THR Method Acc Cover Ineff Baseline 92.4±0.06 99.09±0.8 2.23±0.01 ConfTr 90.2±0.12 99.03±0.22 2.18±0.025 ConfTr +Lclass 91.2±0.05 99.05±0.21 2.11±0.028 ConfTr with APS 87.9±4.81 99.09±0.29 5.79±3.1
Tab. B allows to make several observations. First, on the comparably small (and binary) datasets Camelyon and GermanCredit, the size weight λ = 5 is rather high. For ConfTr without Lclass, this just indicates that a higher learning rate could be used. Then using Lclass, however, this shows that the size loss is rather important for ConfTr, especially on binary datasets. Second, we found the temperature T to have low impact on results, also see Sec. H. On multiclass datasets, the size weight λ is usually higher when employing Lclass. Finally, especially with Lclass, using “valid” size loss, i.e., κ = 1, to not penalize confidence sets of size 1, works better than κ = 0.
Random Training and Test Trials: For statistically meaningful results, we perform random test and training trials. Following common practice (Angelopoulos et al., 2021), we evaluate CP methods at test time using 10 random calibration/test splits. To this end, we throw all calibration and test examples together and sample a new calibration/test split for each trial, preserving the original calibration/test composition which is summarized in Tab. A. Metrics such as coverage and inefficiency are then empirically evaluated as the average across all test trials. Additionally, and in contrast to (Bellotti, 2021), we consider random training trials: After hyper-parameters optimization on all training examples, we train 10 models with the final hyper-parameters on a new training set obtained by sampling the original one with up to 5 replacements. For example, on MNIST, with 55k training
Table D: Hyper-Parameter Ablation on MNIST: For ConfTr without Lclass, we report inefficiency and accuracy when varying hyper-parameters individually: batch size/learning rate, size weight λ, temperature T and confidence level α. While size weight λ and temperature T have insignificant impact, too small batch size can prevent ConfTr from converging. Furthermore, the chosen hyperparameters do not generalize well to higher confidence levels α ∈ {0.1, 0.05}.
Batch Size and Learning Rate Batch Size 1000 1000 1000 500 500 500 100 100 100 Learning Rate 0.05 0.01 0.005 0.05 0.01 0.005 0.05 0.01 0.005 Ineff 2.27 2.24 2.24 2.18 2.18 2.17 8.04 7.32 9.66 Acc 89.05 89.18 89.06 90.23 90.22 90.27 11.5 22.46 12.13
Size Weight λ λ 0.001 0.005 0.01 0.05 0.1 1 10 Ineff 2.18 2.18 2.18 2.19 2.19 2.19 2.16 Acc 90.2 20.23 90.23 90.2 90.25 90.23 90.26
Temperature T T 0.01 0.05 0.1 0.5 1 5 10 Ineff 2.39 2.23 2.2 2.19 2.18 2.2 2.29 Acc 88.54 89.94 90.02 90.24 90.28 90.05 89.63
Confidence Level α (during training) α 0.1 0.05 0.01 0.005 Ineff 8.07 7.23 2.18 2.17 Acc 12.88 39.82 90.23 89.47
examples, we randomly sample 10 training sets of same size with each, on average, containing only ∼68% unique examples from the original training set. Overall, this means that we report, e.g., inefficiency as average over a total of 10 · 10 = 100 random training and test trials. As a consequence, our evaluation protocol accounts for randomness at test time (i.e., regarding the calibration set) and at training time (i.e., regarding the training set, model initialization, etc.).
G IMPORTANCE OF RANDOM TRIALS
In Tab. C we highlight the importance of random training and test trials for evaluation. On the left, we show the impact of trials at test time, i.e., 10 random calibration/test splits, for a fixed model on MNIST. While the standard deviation of coverage is comparably small, usually ≤ 0.2%, standard deviation of inefficiency is higher in relative terms. This makes sense as coverage is guaranteed, while inefficiency depends more strongly on the sampled calibration set. The right table, in contrast, shows that training trials exhibit lower standard deviation in terms of inefficiency. However, training with, e.g., APS will mainly result in high inefficiency, on average, because of large standard deviation. In fact, ConfTr with APS or THR at training time results in worse inefficiency mainly because training is less stable. This supports the importance of running multiple training trials for ConfTr.
H IMPACT OF HYPER-PARAMETERS
In Tab. D, we conduct ablation for individual hyper-parameters of ConfTr with THRLP and without Lclass on MNIST. The hyper-parameters used in the main paper, c.f . Tab. B, are highlighted in bold. As outlined in Sec. F, hyper-parameter optimization was conducted on 100% training examples with only 3 random test trials, while Tab. D shows results using random training and test trials. We found batch size and learning rate to be most impactful. While batch sizes 1000 and 500 both work, batch size 100 prevents ConfTr from converging properly. This might be due to the used α = 0.01 which might be too low for batch size 100 where only 50 examples are available for calibration during training. Without Lclass, the size weight λ merely scales the learning rate and, thus, has little to no impact. For ConfTr with Lclass, we generally found the size weight λ to be more important for balancing classification loss L and size loss Ω in Eq. (4). Temperature has no significant impact, although a temperature of 0.5 or 1 works best. Finally, the hyper-parameters do generalize to a lower confidence level α = 0.005. Significantly lower values, e.g., α = 0.001, are, however,
Table E: Ablation for CoverTr and ConfTr on MNIST and Fashion-MNIST: We report inefficiency and accuracy for (Bellotti, 2021) (Bel), CoverTr and ConfTr considering various CP methods for training and testing. Bel outperforms the baseline when using THRL, but does not do so for THR on MNIST. CoverTr with THR or APS during training is challenging, resulting in high inefficiency (mainly due to large variation among training trials, c.f . Tab. C), justifying our choice of THRLP for ConfTr. Also CoverTr is unable to improve over the THR baseline. Similar observations hold on Fashion-MNIST where, however, CoverTr with THR or APS was not possible.
MNIST: Ablation for CoverTr and ConfTr Method Baseline Bel CoverTr ConfTr Train THRL THR APS THRLP THRLP THRLP +Lclass Test THRL THR APS THRL THR THR APS THR APS THR APS THR APS Avg. Ineff 3.57 2.23 2.5 2.73 2.7 6.34 4.86 2.5 2.76 2.18 2.16 2.11 2.14 Avg. Acc 92.39 92.39 92.39 81.41 90.01 83.85 88.53 92.63 92.63 90.24 90.21 91.18 91.35
Fashion-MNIST: Ablation for CoverTr and ConfTr Method Baseline Bel CoverTr ConfTr Train THRL THR THRLP THRLP THRLP +Lclass Test THRL THR APS THRL THR THR THR THR APS THR APS Ineff 2.52 2.05 2.36 1.83 1.9 4.03 2.69 1.69 1.82 1.67 1.73 Acc 89.16 89.16 89.16 84.29 84.61 89.23 87.48 88.86 87.43 89.23 88.69
not meaningful due to the batch size of 500. However, significantly higher confidence levels, e.g., α = 0.1 or α = 0.05, require re-optimizing the other hyper-parameters.

heading: I COVERTR AND CONFTR ABLATION ON MNIST AND FASHION-MNIST
text: In Tab. E, we present an ablation for CoverTr, see Sec. E, and ConfTr on MNIST, using a linear model, and Fashion-MNIST, using a 2-layer MLP. Bel is generally able to improve inefficiency of THRL. Using THR, however, Bel worsens inefficiency on MNIST significantly, while improving slightly over the baseline on Fashion-MNIST. As a result, the improvement of ConfTr over Bel is also less significant on Fashion-MNIST. Using CoverTr with THR or APS during training works poorly. As described in Tab. C, this is mainly due to a high variation across training runs, i.e., individual models might work well, but training is not stable enough to get consistent improvements. Thus, on MNIST, inefficiency for CoverTr with THR and APS is very high. Moreover, on FashionMNIST, we were unable to train CoverTr with THR and APS. Using THRLP, training with CoverTr works and is reasonably stable, but does not improve over the baseline. It does improve over Bel on MNIST though. As described in the main paper, we suspect the fixed threshold τ to be problematic. Overall, however, only ConfTr is able to outperform the THR baseline on both datasets. Here, ConfTr with Lclass works slightly better than without.

heading: J ALL INEFFICIENCY RESULTS
text: Tab. F shows complementary results for ConfTr on CIFAR10, EMNIST and CIFAR100. For results on MNIST and Fashion-MNIST, see Tab. D. On CIFAR10, we also include ConfTr using a 2-layer MLP on top of ResNet features – instead of the linear model used in the main paper. In Tab. F, this is referred to as “extending”. However, inefficiency increases slightly compared to re-initializing and training just the (linear) logit layer. This shows that the smaller inefficiency improvements on CIFAR shown in the main paper are not due to the linear model used, but rather caused by the features themselves. We suspect that this is because the features are trained to optimize cross-entropy loss, leaving ConfTr less flexibility to optimize inefficiency. In Tab. G, we consider three binary datasets, i.e., WineQuality, GermanCredit and Camelyon. On binary datasets, THRL, THR and APS perform very similar. This already suggests that there is little room for inefficiency improvements. Indeed, ConfTr is not able to improve inefficiency significantly. However, this is partly due to our thorough evaluation scheme: On Camelyon (using α=0.05), we do not report averages across all training trials, but the results corresponding to the best model. This is because sub-sampling the training examples is unreasonable given that there are only 280 of them. Thus, Camelyon shows that ConfTr can improve inefficiency. On WineQuality or GermanCredit, however, this is “hidden” in reporting averages across 10 training runs.
Table F: Inefficiency and Accuracy on Multiclass Datasets: Complementing Tab. 1 in the main paper, we include results for CoverTr on CIFAR10. Furthermore, we consider training a non-linear 2-layer MLP on the ResNet features on CIFAR10, c.f . Sec. F, alongside the ensemble results from the main paper. We report inefficiency and accuracy in all cases, focusing on ConfTr in comparison to Bel. On EMNIST, we additionally consider α = 0.005, 0.001 (for the baseline and ConfTr only). As in the main paper, ConfTr consistently improves inefficiency of THR and APS.
CIFAR10: Fine-Tuning and “Extending” Fine-tuning “Extend”
Method Baselines Bel CoverTr ConfTr ConfTr Train THRL THRLP THRLP THRLP +Lclass THRLP +Lclass Test THRL THR APS THR THR THR APS THR APS THR THR Ineff 3.92 2.93 3.3 2.93 2.84 2.88 3.05 2.84 2.93 2.89 2.96 Acc 82.6 82.6 82.6 82.18 82.36 82.32 82.34 82.4 82.4 82.3 82.23
CIFAR10: Ensemble Results
Method (Ensemble Models) Ensemble+MLP Ensemble+ConfTr Train THRLP Test THRL THR APS THRL THR APS THR Avg. Ineff 4.19 3.1 3.48 3.12 2.4 2.77 2.35 Best Ineff 3.74 2.84 3.17 3.0 2.33 2.71 2.3 Avg. Acc 80.65 80.65 80.65 85.88 85.88 85.88 85.88 Best Acc 82.58 82.58 82.58 86.01 86.01 86.01 86.02
EMNIST Method Baselines Bel ConfTr Train THRL THRL THRLP THRLP +Lclass Test THRL THR APS THRL THR THR APS THR APS Ineff 5.07 2.66 4.23 3.95 3.48 2.66 2.86 2.49 2.87 Ineff, α=0.005 9.23 4.1 6.04 – – 3.37 – – – Ineff, α=0.001 23.89 15.73 19.33 – – 13.65 – – – Acc 83.79 83.79 83.79 80.69 80.69 77.1 77.43 77.49 78.09
CIFAR100 Method Baselines Bel ConfTr Train THRL THRLP THRLP +Lclass Test THRL THR APS THR THR APS THR APS Ineff 19.22 10.63 16.62 10.91 10.78 12.99 10.44 12.73 Acc 73.36 73.36 73.36 72.65 72.02 72.78 73.27 72.99

heading: K EFFECT OF CONFTR ON CLASS-CONDITIONAL INEFFICIENCY AND COVERAGE CONFUSION
text: Fig. G shows that standard ConfTr (without Lclass) does not have a significant influence on the classconditional inefficiency distribution compared to the baseline. Similarly, ConfTr with Lclass and identity loss matrix L = IK does not influence coverage confusion besides reducing overall inefficiency. Specifically, on MNIST, Fashion-MNIST and CIFAR10, we show the class-conditional inefficiency distribution (left) as well as the coverage confusion matrices (middle and right) for the baseline and ConfTr. On the left, we consider ConfTr without Lclass, and on the right with Lclass. As can be seen, only an overall reduction of inefficiency is visible, the distribution of Ineff[y], c.f . Eq. (6), across classes y remains roughly the same. For coverage confusion Σ from Eq. (7), the same observation can be made, i.e., an overall reduction of inefficiency also reduces confusion, but the spatial pattern remains the same. Thus, in the main paper and the following experiments, we always highlight the improvement over standard ConfTr, without Lclass for reducing class-conditional inefficiency and with Lclass for changing coverage confusion or improving MisCover.
Table G: Inefficiency and Accuracy on Binary Datasets. Experimental results on the binary datasets WineQuality, GermanCredit and Camelyon. While we include APS on WineQuality, we focus on THR on GermanCredit and Camelyon due to slightly lower inefficiency. However, THRL, THR and APS perform very similarly on all tested binary datasets. Generally, ConfTr does not improve significantly over the baseline. * On Camelyon, we report the best results without training trials as sub-sampling the 280 training examples is prohibitively expensive.
WineQuality Method Baselines Bel CoverTr ConfTr Train THRL THRLP THRLP THRLP +Lclass Test THRL THR APS THR THR THR APS THR APS Ineff, α=0.01 1.76 1.76 1.79 1.77 1.81 1.75 1.82 1.74 1.77 Ineff, α=0.05 1.48 1.49 1.53 1.57 1.50 1.51 – 1.52 – Acc 82.82 82.82 82.82 71.3 81.5 73.8 74.24 73.91 73.91
GermanCredit Method Baselines Bel ConfTr Train THRL THRLP +Lclass Test THRL THR APS THR THR THR Ineff 1.89 1.86 1.90 1.85 1.88 1.77 Acc 74.4 74.4 74.4 72.35 72.81 69.5
Camelyon* α=0.05 Method Baselines Bel ConfTr Train THRL THRLP +Lclass Test THRL THR APS THR THR THR Best Ineff 1.41 1.47 1.59 1.25 1.2 1.25 Best Acc 88 88 88 92 91.5 85

heading: L SHAPING CLASS-CONDITIONAL INEFFICIENCY ON OTHER DATASETS
text: Fig. A and B provide complementary results demonstrating the ability of ConfTr to shape the classor group-conditional inefficiency distribution. First, Fig. A plots inefficiency for individual classes on CIFAR10 and coarse classes on CIFAR100. In both cases, significant inefficiency reductions are possible for high weights ω in Eq. (3), irrespective or whether the corresponding (coarse) class has above-average inefficiency to begin with. This means that inefficiency reduction is possible for easier and harder classes alike. Second, Fig. B plots the relative inefficiency changes, in percentage, possible per-class or group on MNIST, Fashion-MNIST and CIFAR100. For CIFAR100, we show only the first 10 classes for brevity. In all cases, significant inefficiency reductions are possible, at the expense of a slight increases in average inefficiency across all classes. Here, MNIST is considerably
0 2 4 6 8 10 Size Weight Class 0
1
2
3
In ef
fic ie
nc y
CIFAR10: Reducing Ineff of Class 0
Ineff Class 0 Avg. Ineff
0 2 4 6 8 10 Size Weight Class 3
2
4
In ef
fic ie
nc y
CIFAR10: Reducing Ineff of Class 3
Ineff Class 3 Avg. Ineff
CIFAR100: Reducing Ineff of Group 9
0 2 4 6 8 10 Size Weight Group 9
5
10
In ef
fic ie
nc y
CIFAR10: Reducing Ineff of Class 0
Ineff Group 9 Avg. Ineff
CIFAR100: Reducing Ineff of Group 15
0 2 4 6 8 10 Size Weight Group 15
5
10
15
In ef
fic ie
nc y
CIFAR10: Reducing Ineff of Class 0
Ineff Group 15 Avg. Ineff
Figure A: Reducing Class- and Group-Conditional Inefficiency on CIFAR. Results, complementary to Fig. 3, showing the impact of higher size weights ω in Eq. (3) for classes 0 and 3 (“airplane” and “cat”) on CIFAR10 and coarse classes 9 and 15 (“large man-made outdoor things” and “reptiles”) on CIFAR100. ConfTr allows to reduce inefficiency (blue) in all cases, irrespective of whether inefficiency is generally above or below average (green).
0 2 4 6 8 Class
30
20
10
0
10
Re la
tiv e
Ch an
ge (%
) MNIST: Ineff Improvement by Class
Ineff Improvement Avg. Ineff Increase
0 2 4 6 8 Class
15
10
5
0
Re la
tiv e
Ch an
ge (%
) MNIST: Ineff Reduction by Group
Ineff Improvement Group 0 Avg. Ineff Increase Group 0 1 1
0 2 4 6 8 Class
15
10
5
0
5
Re la
tiv e
Ch an
ge (%
) F-MNIST: Ineff Improvement by Class
Ineff Improvement Avg. Ineff Increase
0 2 4 6 8 Class
40
20
0
Re la
tiv e
Ch an
ge (%
) CIFAR100: Ineff Improvement by Class
Ineff Improvement Avg. Ineff Increase
Figure B: Relative Class and Group-Conditional Inefficiency Improvements: Complementing the main paper, we plot the possible (relative) inefficiency reduction by class or group (“odd” vs “even”) on MNIST and Fashion-MNIST. On CIFAR100, we consider the first 10 classes for brevity. In all cases, significant per-class or -group inefficiency reductions are possible.
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.70 1.04 5.07 1.90 1.58 0.85 0.76 0.70 3.31 1.70
1.14 9.90 0.39 0.33 0.17 0.25 0.34 0.18 1.40 4.29
2.86 0.25 9.74 5.43 3.95 4.13 3.59 2.15 0.71 0.36
1.81 0.39 5.05 9.74 4.31 9.11 4.52 3.60 0.72 0.66
1.21 0.12 5.17 5.89 9.96 5.51 2.39 3.86 0.27 0.27
0.75 0.25 4.80 9.24 2.93 9.86 2.26 3.84 0.26 0.37
0.58 0.25 4.26 5.00 2.48 2.22 9.79 0.59 0.40 0.20
0.87 0.24 2.39 3.37 4.31 5.63 0.52 9.90 0.28 0.47
4.28 1.51 1.09 0.87 0.49 0.39 0.47 0.31 10.18 1.56
1.84 4.33 0.63 0.88 0.39 0.46 0.34 0.61 1.76 10.17
CIFAR10: Coverage Confusion for ConfTr+Lclass+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.71 1.32 5.14 2.00 1.92 1.11 1.12 0.98 3.14 2.06
1.35 9.92 0.56 0.43 0.22 0.36 0.50 0.34 1.51 3.67
3.28 0.56 9.74 5.04 3.88 4.14 4.01 2.27 1.00 0.76
2.68 0.87 5.41 9.70 4.27 8.86 5.32 3.77 1.13 1.35
1.59 0.39 4.87 5.39 9.97 4.12 2.89 3.33 0.46 0.57
1.22 0.61 4.64 8.25 2.77 9.86 2.79 3.50 0.52 0.79
0.84 0.46 4.06 4.48 2.51 2.30 9.81 0.76 0.61 0.46
1.22 0.52 2.48 3.12 3.28 4.04 0.94 9.90 0.51 0.84
4.15 1.71 1.47 1.04 0.74 0.55 0.71 0.47 10.18 1.73
2.10 3.82 0.82 1.07 0.54 0.67 0.57 0.82 1.86 10.20
CIFAR10: Coverage Confusion for ConfTr+Lclass+Thr, Off-Diagonal Weight 1
Figure C: Full Coverage Confusion Matrix on CIFAR10: We plot the full coverage confusion matrices Σ from Eq. (7) on CIFAR10 for the ConfTr baseline (with Lclass, left) and ConfTr with Ly,k = 1 in Eq. (5) for classes y, k ∈ {4, 5, 7} (right, highlighted in red).
C IF
A R
10 F-
M N
IS T 4-6 4.07
0 0.01 0.05 0.1 0.5 1 Off-Diagonal Weight
4.32 4.25 4.21 4.18 3.44 3.10
6- 4 4.00
0 0.01 0.05 0.1 0.5 1 Off-Diagonal Weight
3.49 3.50 3.48 3.33 2.87 2.62
3- 5 9.18
0 0.01 0.05 0.1 0.5 1 Off-Diagonal Weight
9.11 8.82 8.81 8.80 8.61 8.39
5- 3 9.21
0 0.01 0.05 0.1 0.5 1 Off-Diagonal Weight
9.24 8.26 8.20 8.11 7.77 7.56
0 1 2 3 4 5 6 7 8 9 Class
0
0.01
0.05
0.1
0.5
1
Of f-D
ia go
na l W
ei gh
t
4.44 0.16 4.29 1.47 3.49 0.02 9.90 0.01 0.42 0.01
4.42 0.16 4.26 1.45 3.51 0.02 9.96 0.02 0.42 0.03
4.40 0.15 4.11 1.42 3.45 0.03 9.95 0.01 0.44 0.01
4.33 0.16 4.07 1.43 3.39 0.03 9.94 0.01 0.42 0.02
4.19 0.17 3.87 1.36 3.15 0.03 9.90 0.02 0.40 0.02
4.00 0.17 3.72 1.29 3.03 0.03 9.88 0.01 0.42 0.01
Fashion-MNIST: Reducing Cov Confusion for Class/Row 6
0 1 2 3 4 5 6 7 8 9 Class
0
0.01
0.05
0.1
0.5
1
Of f-D
ia go
na l W
ei gh
t
1.81 0.39 5.05 9.74 4.31 9.11 4.52 3.60 0.72 0.66
2.54 0.83 5.19 9.68 4.58 8.82 5.13 4.26 1.02 1.25
2.49 0.71 5.13 9.69 4.48 8.78 4.98 4.12 1.02 1.23
2.44 0.75 5.09 9.70 4.44 8.78 4.94 4.13 1.00 1.15
2.35 0.72 4.89 9.70 4.20 8.56 4.65 3.80 0.99 1.11
2.39 0.73 4.69 9.71 3.97 8.46 4.53 3.61 0.95 1.05
CIFAR10: Reducing Cov Confusion for Class/Row 3
Figure D: Coverage Confusion Changes on Fashion-MNIST and CIFAR10: Left: coverage confusion change when targeting classes 4 and 6 (“coat” and “shirt”) on Fashion-MNIST and 3 and 5 (“cat” and “dog”) on CIFAR10. The separate cell on the left is the ConfTr baseline which is, up to slight variations, close to Ly,k = 0. Middle and right: coverage confusion for a whole row, i.e., Σy,k with fixed class y and all k 6= y. We show row 6 on Fashion-MNIST and 3 on CIFAR10. In both cases, coverage confusion can be reduced significantly.
easier than Fashion-MNIST: higher inefficiency reductions are possible per class and the cost in terms of average inefficiency increase is smaller. On CIFAR100, inefficiency reductions of 40% or more are possible. This is likely because of the high number of classes, i.e., ConfTr has a lot of flexibility to find suitable trade-offs during training.

heading: M MANIPULATING COVERAGE CONFUSION ON OTHER DATASETS
text: Fig. C to E provide additional results for reducing coverage confusion using ConfTr. First, in Fig. C we show the full coverage confusion matrices for the ConfTr baseline (with Lclass, left) and ConfTr with Ly,k = 1, y 6= k ∈ {4, 5, 7} (right, marked in red) on CIFAR10. This allows to get the complete picture of how coverage confusion changes and the involved trade-offs. As demonstrated in the main paper, coverage confusion for, e.g., classes 4 and 5 (“deer” and “dog”) reduces. However, coverage confusion for other class pairs might increase slightly. Then, supplementary to Fig. 4 in the main paper, we provide the actual numbers in Fig. D. In particular, we visualize how the actual coverage confusion entries (left) or rows (right) change depending on the off-diagonal weights Ly,k. Finally, Fig. E presents additional results on MNIST and CIFAR10. From these examples it can be seen that reducing coverage confusion is easier on MNIST, reducing linearly with the corresponding penalty Ly,k. Moreover, the achieved reductions are more significant. On CIFAR10, in contrast, coverage confusion reduces very quickly for small Ly,k before stagnating for larger Ly,k. At the same time, not all targeted class pairs might yield significant coverage confusion reductions.
0.0 0.2 0.4 0.6 0.8 1.0 Off-Diagonal Weight
2
1
0
1
Co v
Co nf
us io
n Ch
an ge
(% ) MNIST: Reducing Cov Confusion 4-7-9
4-7 7-4 4-9 9-4 7-9 9-7 5-8 8-5
0.0 0.2 0.4 0.6 0.8 1.0 Off-Diagonal Weight
2
1
0
Co v
Co nf
us io
n Ch
an ge
(% ) MNIST: Reducing Cov Confusion Class 9
9-4 9-7 9-8 4-9
0.0 0.2 0.4 0.6 0.8 1.0 Off-Diagonal Weight
2
1
0
1
Co v
Co nf
us io
n Ch
an ge
(% ) CIFAR10: Reducing Cov Confusion 4-5-7
4-5 5-4 4-7 7-4 5-7 7-5 0-3 3-0
0.0 0.2 0.4 0.6 0.8 1.0 Off-Diagonal Weight
0.5
0.0
0.5
Co v
Co nf
us io
n Ch
an ge
(% ) CIFAR10: Reducing Cov Confusion Class 3
3-2 3-4 3-5 3-0
Figure E: Coverage Confusion Reduction on MNIST and CIFAR10: Controlling coverage confusion for various class pairs. On MNIST, coverage confusion reduction is usually more significant and the reduction scales roughly linear with the weight Ly,k. On CIFAR10, in contrast, coverage confusion cannot always be reduced for multiple class pairs at the same time (see light gray).
Table H: Mis-Coverage on MNIST, Fashion-MNIST and CIFAR10: We present inefficiency and mis-coverage for various cases: On MNIST, we consider 2 vs. other classes as well as even vs. odd classes. In both cases, mis-coverage can be reduced significantly. As in the main paper, however, reducing MisCover0→1 usually increases MisCover1→0 and vice-versa. On Fashion-MNIST, we consider 6 (“shirt”) vs. other classes. Only on CIFAR10, considering “vehicles” vs. “animals”, miscoverage cannot be reduced significantly. In particular, we were unable to reduce MisCover1→0.
K0= 2 vs. K1= Others MNIST MisCover ↓ Method Ineff 0→1 1→0 ConfTr 2.11 49.68 14.74 LK0,K1=1 2.15 36.63 17.42 LK1,K0=1 2.09 51.54 7.62 K0= Even vs. K1= Odd MNIST MisCover ↓ Method Ineff 0→1 1→0 ConfTr 2.11 38.84 38.69 LK0,K1=1 2.16 29.36 49.08 LK1,K0=1 2.09 44.3 26.08
K0= 6 (“shirt”) vs. K1= Others F-MNIST MisCover ↓ Method Ineff 0→1 1→0 ConfTr 1.67 80.28 20.93 LK0,K1=1 1.70 72.58 25.81 LK1,K0=1 1.72 81.18 17.66 K0= “vehicles” vs. K1= “animals” CIFAR10 MisCover ↓ Method Ineff 0→1 1→0 ConfTr 2.84 22.22 16.45 LK0,K1=1 2.92 20.00 22.69 LK1,K0=1 2.87 24.76 16.73

heading: N MISCOVER RESULTS ON ADDITIONAL DATASETS
text: Tab. H provides mis-coverage results for different settings on MNIST, Fashion-MNIST and CIFAR10. As in the main paper, we are able to reduce mis-coverage significantly on MNIST and Fashion-MNIST. Only on CIFAR10, considering “vehicles” vs. “animals” as on CIFAR100 in the main paper, we are unable to obtain significant reductions. While, we are able to reduce MisCover0→1 slightly from 22.22% to 20%, MisCover1→0 increases slightly from 16.45% to 16.73% even for high off-diagonal weights used in L. Compared to CIFAR100, this might be due to less flexibility to find suitable trade-offs as CIFAR10 has only 10 classes. Moreover, mis-coverages on CIFAR10 are rather small to begin with, indicating that vehicles and animals do not overlap much by default.

heading: O ADDITIONAL RESULTS ON BINARY DATASETS
text: Fig. F shows results complementing Fig. 5 (right) in the main paper. Specifically, we show that reducing inefficiency for class 1 (“good wine”) is unfortunately not possible. This might also be due to the fact that class 1 is the majority class, with ∼63% of examples. However, in addition to improving coverage conditioned on class 0, we are able to reduce coverage confusion Σ0,1, c.f . Sec. 3.3. We found that these results generalize to GermanCredit, however, being less pronounced, presumably because of significantly fewer training and calibration examples.
0 2 4 6 8 10 Size Weight Class 0
1.5
2.0
In ef
fic ie
nc y WineQuality: Reducing Ineff of Class 0
Size 0 Size 1
0 2 4 6 8 10 Size Weight Class 1
1.5
2.0
In ef
fic ie
nc y WineQuality: Reducing Ineff of Class 1
Size 1 Size 0
0 1 Predicted Class
0
1Tr ue
C la
ss 14.40 19.43
6.66 59.51
Cov Confusion
0 1 Predicted Class
0
1Tr ue
C la
ss 23.06 10.77
12.40 53.77
Class 0 Weight 1.25
0 1 Predicted Class
0
1Tr ue
C la
ss 24.35 9.48
33.83 32.34
Cov Confusion
0 1 Predicted Class
0
1Tr ue
C la
ss 24.35 9.48
33.83 32.34
Cov Confusion
0 1 Predicted Class
0
1Tr ue
C la
ss 29.70 4.13
24.35 41.82
Class 0 Weight 4.00
0 1 Predicted Class
0
1Tr ue
C la
ss 14.40 19.43
6.66 59.51
Cov Confusion
0 1 Predicted Class
0
1Tr ue
C la
ss 19.30 14.53
9.87 56.30
0-1 Weight 0.01
0 1 Predicted Class
0
1Tr ue
C la
ss 19.69 14.14
10.16 56.01
0-1 Weight 0.05
0 1 Predicted Class
0
1Tr ue
C la
ss 21.49 12.34
10.97 55.20
0-1 Weight 0.10
0 1 Predicted Class
0
1Tr ue
C la
ss 24.27 9.56
14.44 51.73
0-1 Weight 0.50
Figure F: Manipulating Inefficiency and Coverage Confusion on WineQuality: Complementing Fig. 5 (right) in the main paper, we plot the possible inefficiency reduction for class 1 (“good wine”, left) and full coverage confusion matrices for increased L0,0 > 1 and L1,0 > 0 (right, top and bottom, respectively). While we can reduce inefficiency for class 0 (“bad wine”), this is not possible for class 1. However, class-conditional coverage for class 0 can be improved significantly and we can reduce coverage confusion Σ0,1.

heading: P PSEUDO CODE
text: Alg. B presents code in Python, using Jax (Bradbury et al., 2018), Haiku (Hennigan et al., 2020) and Optax (Hessel et al., 2020). We assume access to a smooth sorting routine that allows to compute quantiles in a differentiable way: smooth_quantile. Specifically, Alg. B provides an exemplary implementation of ConfTr with (smooth) THR and Lclass as outlined in Alg. 1 in the main paper. smooth_predict_threshold and smooth_calibrate_threshold implement differentiable prediction and calibration steps for THR. These implementations are used in compute_loss_and_error to “simulate” CP on mini-batches during training. Size loss Ω from Eq. (3) and classification loss from Eq. (5) are implemented in compute_size_loss and compute_general_classification_loss. Note that the definition of compute_loss_and_error distinguishes between trainable_params and fixed_params, allowing to fine-tune a pre-trained model.
0 2 4 6 8 Class
0
1
2
3
In ef
fic ie
nc y
MNIST: Baseline+Thr
0 2 4 6 8 Class
0
1
2
In ef
fic ie
nc y
MNIST: ConfTr+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.66 0.01 0.93 0.46 0.11 2.34 0.60 0.19 0.51 0.20
0.02 11.20 2.83 1.70 0.07 0.75 0.19 0.85 3.38 0.19
0.59 1.14 10.03 3.26 0.52 0.93 1.27 0.57 2.36 0.47
0.49 0.57 2.43 10.12 0.25 4.00 0.35 0.78 3.12 1.32
0.22 0.29 0.69 0.51 9.75 0.91 1.18 1.38 1.62 4.97
1.24 0.39 1.16 3.41 1.18 8.91 1.19 0.64 5.06 1.38
0.88 0.17 2.20 0.37 1.21 1.82 9.55 0.15 1.21 0.30
0.15 0.52 1.00 1.51 0.79 0.44 0.08 10.23 0.69 5.16
0.62 1.18 3.10 3.79 1.24 4.63 1.00 0.61 9.68 2.37
0.27 0.38 0.46 1.71 6.25 1.50 0.13 5.75 3.36 9.96
MNIST: Coverage Confusion Matrix for Baseline+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.67 0.02 0.83 0.44 0.11 2.22 0.59 0.21 0.37 0.21
0.02 11.20 1.58 1.17 0.06 0.72 0.16 0.57 2.09 0.14
0.55 1.38 10.01 3.01 0.61 0.88 1.32 0.62 2.24 0.55
0.47 0.62 2.27 10.12 0.25 3.72 0.34 0.85 2.76 1.29
0.23 0.29 0.83 0.62 9.75 0.93 1.09 1.33 1.32 4.57
1.16 0.47 1.30 3.26 1.14 8.94 1.23 0.71 4.35 1.37
0.74 0.20 1.97 0.41 1.24 1.60 9.54 0.22 1.00 0.34
0.15 0.58 1.04 1.36 0.83 0.46 0.10 10.22 0.60 4.93
0.63 1.22 2.80 3.42 1.13 3.88 0.97 0.69 9.66 2.05
0.31 0.37 0.60 1.42 4.92 1.15 0.18 4.73 1.94 9.94
MNIST: Coverage Confusion Matrix for ConfTr+Lclass+Thr
0 2 4 6 8 Class
0
1
2
In ef
fic ie
nc y
F-MNIST: Baseline+Thr
0 2 4 6 8 Class
0
1
2
In ef
fic ie
nc y
F-MNIST: ConfTr+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.87 0.79 2.31 2.13 0.85 0.39 5.72 0.27 0.90 0.33
0.47 9.98 0.33 0.93 0.51 0.25 0.57 0.13 0.27 0.17
2.18 0.59 9.93 1.02 4.65 0.36 4.47 0.30 0.68 0.25
2.76 1.98 1.90 9.83 2.30 0.47 2.62 0.42 1.10 0.53
0.82 0.75 5.64 1.71 9.69 0.32 4.07 0.23 0.96 0.27
0.54 0.42 0.40 0.43 0.40 10.29 0.50 2.14 0.79 1.55
4.61 0.89 4.27 2.02 4.00 0.59 9.80 0.38 1.21 0.45
0.21 0.20 0.23 0.19 0.17 2.02 0.19 9.80 0.36 2.98
1.11 0.35 0.73 0.80 0.85 0.89 1.11 0.68 9.75 0.48
0.32 0.22 0.22 0.43 0.23 1.22 0.24 2.78 0.30 10.03
F-MNIST: Coverage Confusion Matrix for Baseline+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.88 0.17 1.47 1.70 0.38 0.07 6.14 0.03 0.30 0.01
0.21 9.96 0.12 0.45 0.13 0.01 0.25 0.01 0.06 0.01
1.30 0.10 9.95 0.59 4.44 0.03 4.98 0.01 0.18 0.01
2.21 0.80 1.45 9.83 1.82 0.05 2.54 0.02 0.31 0.03
0.36 0.10 6.00 1.41 9.68 0.02 4.32 0.01 0.26 0.02
0.05 0.02 0.02 0.04 0.02 10.26 0.01 1.07 0.11 0.63
4.44 0.16 4.29 1.47 3.49 0.02 9.90 0.01 0.42 0.01
0.00 0.00 0.01 0.00 0.01 1.02 0.00 9.78 0.03 2.07
0.43 0.04 0.26 0.20 0.23 0.18 0.54 0.14 9.72 0.05
0.02 0.01 0.01 0.02 0.01 0.38 0.02 1.54 0.01 10.01
F-MNIST: Coverage Confusion Matrix for ConfTr+Lclass+Thr
0 2 4 6 8 Class
0
2
4
In ef
fic ie
nc y
CIFAR10: Baseline+Thr
0 2 4 6 8 Class
0
2
4
In ef
fic ie
nc y
CIFAR10: ConfTr+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.71 1.41 4.87 2.07 1.97 1.08 0.99 1.04 3.19 2.02
1.38 9.92 0.58 0.52 0.26 0.37 0.54 0.38 1.55 3.36
3.28 0.63 9.72 4.81 4.03 3.91 3.67 2.42 1.05 0.79
2.44 0.88 4.96 9.69 4.47 8.64 4.80 3.98 1.18 1.41
1.53 0.44 4.72 4.96 9.99 4.57 2.74 3.81 0.53 0.61
1.08 0.61 4.38 8.24 3.15 9.86 2.59 4.06 0.53 0.82
0.80 0.54 3.81 4.19 2.65 2.26 9.81 0.87 0.66 0.43
1.22 0.56 2.41 3.21 3.83 4.54 0.81 9.93 0.58 0.93
3.97 1.82 1.37 1.16 0.79 0.57 0.68 0.53 10.19 1.61
2.02 3.65 0.79 1.28 0.65 0.78 0.65 0.88 1.87 10.18
CIFAR10: Coverage Confusion Matrix for Baseline+Thr
0 1 2 3 4 5 6 7 8 9 Predicted Class
0
1
2
3
4
5
6
7
8
9
Tr ue
C la
ss
9.70 1.21 5.03 1.98 1.87 1.08 1.02 1.02 3.07 1.94
1.34 9.91 0.53 0.42 0.22 0.34 0.47 0.35 1.45 3.33
3.08 0.51 9.73 4.98 4.05 4.11 3.80 2.43 0.93 0.70
2.56 0.81 5.14 9.69 4.65 8.83 5.02 4.10 1.03 1.23
1.48 0.35 4.70 5.24 9.99 4.90 2.89 3.78 0.42 0.53
1.15 0.57 4.65 8.32 3.21 9.88 2.63 4.08 0.48 0.74
0.77 0.44 3.94 4.31 2.53 2.32 9.81 0.88 0.57 0.39
1.17 0.49 2.40 2.97 3.85 4.86 0.90 9.93 0.47 0.81
3.88 1.60 1.35 1.04 0.69 0.56 0.64 0.45 10.18 1.60
1.97 3.55 0.81 1.07 0.57 0.67 0.54 0.80 1.73 10.18
CIFAR10: Coverage Confusion Matrix for ConfTr+Lclass+Thr
Figure G: Class-Conditional Inefficiency and Coverage Confusion: Comparison between baseline and ConfTr regarding class-conditional inefficiency and coverage confusion Σ, c.f . Sec. 3.3. For the inefficiency comparison, we consider ConfTr without Lclass, while for coverage confusion, ConfTr was trained with Lclass. As ConfTr reduces overall inefficiency quite significantly on MNIST and Fashion-MNIST, class-conditional inefficiency is also lower, on average. But the distribution across classes remains similar. The same holds for coverage confusion, where lower overall inefficiency reduces confusion across the matrix, but the “pattern” remains roughly the same. On CIFAR10, ConfTr does not improve average inefficiency significantly, such that the confusion matrix remains mostly the same.
Algorithm B Python Pseudo-Code for ConfTr: We present code based on our Python and Jax implementation of ConfTr. In particular, we include smooth calibration and prediction steps for THR as well as the classification loss Lclass and the size loss Ω. Instead of including a full training loop, compute_loss_and_error shows how to compute the loss which can then be called using jax.value_and_grad(compute_loss_and_error, has_aux=True) and used for training using Optax. Hyper-parameters, including alpha, dispersion, size_weight, temperature, loss_matrix, size_weights and weight_decay, are not defined explicitly for brevity. smooth_quantile is assumed to be a provided differentiable quantile computation method. Finally, model can be any Jax/Haiku model.
1 import jax 2 import jax.numpy as jnp 3 import haiku as hk 4 5 def smooth_predict_threshold( 6 probabilities: jnp.ndarray, tau: float, temperature: float) -> jnp.ndarray: 7 """Smooth implementation of prediction step for Thr.""" 8 return jax.nn.sigmoid((probabilities - tau) / temperature) 9
10 def smooth_calibrate_threshold( 11 probabilities: jnp.ndarray, labels: jnp.ndarray, 12 alpha: float, dispersion: float) -> float: 13 """Smooth implementation of the calibration step for Thr.""" 14 conformity_scores = probabilities[jnp.arange(probabilities.shape[0]), labels.astype(int)] 15 return smooth_quantile(array, dispersion, (1 + 1./array.shape[0]) * alpha) 16 17 def compute_general_classification_loss( 18 confidence_sets: jnp.ndarray, labels: jnp.ndarray, 19 loss_matrix: jnp.ndarray) -> jnp.ndarray: 20 """Compute the classification loss Lclass on the given confidence sets.""" 21 one_hot_labels = jax.nn.one_hot(labels, confidence_sets.shape[1]) 22 l1 = (1 - confidence_sets) * one_hot_labels * loss_matrix[labels] 23 l2 = confidence_sets * (1 - one_hot_labels) * loss_matrix[labels] 24 loss = jnp.sum(jnp.maximum(l1 + l2, jnp.zeros_like(l1)), axis=1) 25 return jnp.mean(loss) 26 27 def compute_size_loss( 28 confidence_sets: jnp.ndarray, target_size: int, weights: jnp.ndarray) -> jnp.ndarray: 29 """Compute size loss.""" 30 return jnp.mean(weights * jnp.maximum(jnp.sum(confidence_sets, axis=1) - target_size, 0)) 31 32 FlatMapping = Union[hk.Params, hk.State] 33 def compute_loss_and_error( 34 trainable_params: FlatMapping, fixed_params: FlatMapping, inputs: jnp.ndarray, 35 labels: jnp.ndarray, model_state: FlatMapping, training: bool, rng: jnp.ndarray, 36 ) -> Tuple[jnp.ndarray, FlatMapping]: 37 """Compute classification and size loss through calibration/prediction.""" 38 params = hk.data_structures.merge(trainable_params, fixed_params) 39 # Model is a Haiku model, e.g., ResNet or MLP. 40 logits, new_model_state = model.apply(params, model_state, rng, inputs, training=training) 41 probabilities = jax.nn.softmax(logits, axis=1) 42 43 val_split = int(0.5 * probabilities.shape[0]) 44 val_probabilities = probabilities[:val_split] 45 val_labels = labels[:val_split] 46 test_probabilities = probabilities[val_split:] 47 test_labels = labels[val_split:] 48 # Calibrate on the calibration probabilities with ground truth labels: 49 val_tau = smooth_calibrate_threshold(val_probabilities, val_labels, alpha, dispersion) 50 51 # Predict on the test probabilities: 52 test_confidence_sets = smooth_predict_threshold(test_probabilities, val_tau, rng) 53 # Compute the classification loss Lclass with a fixed loss matrix L: 54 classification_loss = compute_general_classification_loss( 55 test_confidence_sets, test_labels, loss_matrix) 56 # Optionally set size weights determined by ground truth labels: 57 weights = size_weights[test_labels] 58 # Compute size loss multiplied by size weight: 59 size_loss = size_weight * compute_size_loss(confidence_sets, weights) 60 61 # Compute the log of classification and size loss: 62 loss = jnp.log(classification_loss + size_loss + 1e-8) 63 loss += weight_decay * sum(jnp.sum(jnp.square(param)) for param in jax.tree_leaves(params)) 64 65 return loss, new_model_state

Review summaries:
Conformal prediction is a method that intends to provide set-valued, calibrated prediction, in the sense that they cover the true class with a guaranteed marginal statistical accuracy. The paper mainly proposes to learn the conformal predictor at the same time as the predictive model is used, through an end-to-end procedure.  To this effect, conformity scores and threshold values (using quantiles) are approximated by differentiable surrogates that are directly injected into the learning framework. It is also argued that the framework can offer some solutions to better control class-wise predictions, or class-wise constraints on the conformal sets. 

In split conformal prediction, conformalization is applied using a model that has been trained on a separate training set. However, the training procedure usually optimizes an objective that has little to do with the ultimate goal of producing informative prediction sets. For the problem of classification, the paper proposes an alternative training procedure that simulates conformalization on mini-batches so that the learned model is directly optimized to produce smaller prediction sets. In addition, the proposed alternative training procedure can accommodate other loss functions, which can induce certain structures in the prediction sets. The performance gains are demonstrated through experiments.

**Summary:** * The paper considers putting conformal inference into the process of fitting deep neural networks, i.e., the paper considers "differentiable conformal prediction" / back-prop'ing through conformal inference. * The goal is to reduce the size of the prediction sets generated by conformal inference -- and more specifically to reduce the size variably in different parts of the input space. * Some experiments are given to show that the confidence set sizes are indeed smaller w/ the proposal than w/o it. 

Conformal prediction methods generally operate via post-processing on black-box classifiers to produce a confidence set. In this paper, the authors integrate this post-processing step into the training procedure in order to reduce the inefficiency of conformal prediction while providing the same coverage guarantee. The proposed method uses soft thresholding and differentiable sorting to convert two popular conformal post-processing method classess (THR - Sadinle et al. and APS - Romano et al.) into differentiable modules, although they only use THRLP (the method from Sadinle et al. applied to log-probabilities) in the training process for the results (in Table 1).  Additionally, they propose the use of weighted inefficiency regularization (also termed the size loss) and a "configurable" classification loss that can yield desirable behavior w.r.t. class-conditional inefficiency and mis-coverage (or coverage confusion) respectively.  The proposed method is shown to outperform a competing method by Belloti on 5 public multi-class datasets (including CIFAR100) and a binary dataset (wineQuality).