Uncertainty Sets for Image Classifiers using Conformal Prediction

1 INTRODUCTION . Imagine you are a doctor making a high-stakes medical decision based on diagnostic information from a computer vision classifier . What would you want the classifier to output in order to make the best decision ? This is not a casual hypothetical ; such classifiers are already used in medical settings ( e.g. , Razzak et al. , 2018 ; Lundervold & Lundervold , 2019 ; Li et al. , 2014 ) . A maximumlikelihood diagnosis with an accompanying probability may not be the most essential piece of information . To ensure the health of the patient , you must also rule in or rule out harmful diagnoses . In other words , even if the most likely diagnosis is a stomach ache , it is equally or more important to rule out stomach cancer . Therefore , you would want the classifier to give you—in addition to an estimate of the most likely outcome—actionable uncertainty quantification , such as a set of predictions that provably covers the true diagnosis with a high probability ( e.g. , 90 % ) . This is called a prediction set ( see Figure 1 ) . Our paper describes a method for constructing prediction sets from any pre-trained image classifier that are formally guaranteed to contain the true class with the desired probability , relatively small , and practical to implement . Our method modifies a conformal predictor ( Vovk et al. , 2005 ) given in Romano et al . ( 2020 ) for the purpose of modern image classification in order to make it more stable in the presence of noisy small probability estimates . Just as importantly , we provide extensive evaluations and code for conformal prediction in computer vision . Formally , for a discrete response Y ∈ Y = { 1 , . . . , K } and a feature vector X ∈ Rd , we desire an uncertainty set function , C ( X ) , mapping a feature vector to a subset of { 1 , . . . , K } such that P ( Y ∈ C ( X ) ) ≥ 1− α , ( 1 ) for a pre-specified confidence level α such as 10 % . Conformal predictors like our method can modify any black-box classifier to output predictive sets that are rigorously guaranteed to satisfy the desired coverage property shown in Eq . ( 1 ) . For evaluations , we focus on Imagenet classification ∗Equal contribution . Blog : https : //people.eecs.berkeley.edu/˜angelopoulos/blog/ posts/conformal-classification using convolutional neural networks ( CNNs ) as the base classifiers , since this is a particularly challenging testbed . In this setting , X would be the image and Y would be the class label . Note that the guarantee in Eq . ( 1 ) is marginal over X and Y—it holds on average , not for a particular image X . A first approach toward this goal might be to assemble the set by including classes from highest to lowest probability ( e.g. , after Platt scaling and a softmax function ; see Platt et al. , 1999 ; Guo et al. , 2017 ) until their sum just exceeds the threshold 1 − α . We call this strategy naive and formulate it precisely in Algorithm 1 . There are two problems with naive : first , the probabilities output by CNNs are known to be incorrect ( Nixon et al. , 2019 ) , so the sets from naive do not achieve coverage . Second , image classification models ’ tail probabilities are often badly miscalibrated , leading to large sets that do not faithfully articulate the uncertainty of the model ; see Section 2.3 . Moreover , smaller sets that achieve the same coverage level can be generated with other methods . The coverage problem can be solved by picking a new threshold using holdout samples . For example , with α =10 % , if choosing sets that contain 93 % estimated probability achieves 90 % coverage on the holdout set , we use the 93 % cutoff instead . We refer to this algorithm , introduced in Romano et al . ( 2020 ) , as Adaptive Prediction Sets ( APS ) . The APS procedure provides coverage but still produces large sets . To fix this , we introduce a regularization technique that tempers the influence of these noisy estimates , leading to smaller , more stable sets . We describe our proposed algorithm , Regularized Adaptive Prediction Sets ( RAPS ) , in Algorithms 2 and 3 ( with APS as a special case ) . As we will see in Section 2 , both APS and RAPS are always guaranteed to satisfy Eq . ( 1 ) —regardless of model and dataset . Furthermore , we show that RAPS is guaranteed to have better performance than choosing a fixed-size set . Both methods impose negligible computational requirements in both training and evaluation , and output useful estimates of the model ’ s uncertainty on a new image given , say , 1000 held-out examples . In Section 3 we conduct the most extensive evaluation of conformal prediction in deep learning to date on Imagenet and Imagenet-V2 . We find that RAPS sets always have smaller average size than naive and APSsets . For example , using a ResNeXt-101 , naive does not achieve coverage , while APS and RAPS achieve it almost exactly . However , APS sets have an average size of 19 , while RAPS sets have an average size of 2 at α = 10 % ( Figure 2 and Table 1 ) . We will provide an accompanying codebase that implements our method as a wrapper for any PyTorch classifier , along with code to exactly reproduce all of our experiments . 1.1 RELATED WORK . Reliably estimating predictive uncertainty for neural networks is an unsolved problem . Historically , the standard approach has been to train a Bayesian neural network to learn a distribution over network weights ( Quinonero-Candela et al. , 2005 ; MacKay , 1992 ; Neal , 2012 ; Kuleshov et al. , 2018 ; Gal , 2016 ) . This approach requires computational and algorithmic modifications ; other approaches avoid these via ensembles ( Lakshminarayanan et al. , 2017 ; Jiang et al. , 2018 ) or approximations of Bayesian inference ( Riquelme et al. , 2018 ; Sensoy et al. , 2018 ) . These methods also have major practical limitations ; for example , ensembling requires training many copies of a neural network adversarially . Therefore , the most widely used strategy is ad-hoc traditional calibration of the softmax scores with Platt scaling ( Platt et al. , 1999 ; Guo et al. , 2017 ; Nixon et al. , 2019 ) . This work develops a method for uncertainty quantification based on conformal prediction . Originating in the online learning literature , conformal prediction is an approach for generating predictive sets that satisfy the coverage property in Eq . ( 1 ) ( Vovk et al. , 1999 ; 2005 ) . We use a convenient data-splitting version known as split conformal prediction that enables conformal prediction meth- ods to be deployed for essentially any predictor ( Papadopoulos et al. , 2002 ; Lei et al. , 2018 ) . While mechanically very different from traditional calibration as discussed above , we will refer to our approach as conformal calibration to highlight that the two methodologies have overlapping but different goals . Conformal prediction is a general framework , not a specific algorithm—important design decisions must be made to achieve the best performance for each context . To this end , Romano et al . ( 2020 ) and Cauchois et al . ( 2020 ) introduce techniques aimed at achieving coverage that is similar across regions of feature space , whereas Vovk et al . ( 2003 ) ; Hechtlinger et al . ( 2018 ) and Guan & Tibshirani ( 2019 ) introduce techniques aimed at achieving equal coverage for each class . While these methods have conceptual appeal , thus far there has been limited empirical evaluation of this general approach for state-of-the-art CNNs . Concretely , the only works that we are aware of that include some evaluation of conformal methods on ImageNet—the gold standard for benchmarking computer vision methods—are Hechtlinger et al . ( 2018 ) , Park et al . ( 2019 ) , Cauchois et al . ( 2020 ) , and Messoudi et al . ( 2020 ) , although in all four cases further experiments are needed to more fully evaluate their operating characteristics for practical deployment . At the heart of conformal prediction is the conformal score - a measure of similarity between labeled examples which is used to compare a new point to among those in a hold out set . Our theoretical contribution can be summarized as a modification of the conformal score from Romano et al . ( 2020 ) to have smaller , more stable sets . Lastly , there are alternative approaches to returning prediction sets not based on conformal prediction ( Pearce et al. , 2018 ; Zhang et al. , 2018 ) . These methods can be used as input to a conformal procedure to potentially improve performance , but they do not have finite-sample coverage guarantees when used alone . 2 METHODS . In developing uncertainty set methods to improve upon naive , we are guided by three desiderata . First and most importantly , the coverage desideratum says the sets must provide 1−α coverage , as discussed above . Secondly , the size desideratum says we want sets of small size , since these convey more detailed information and may be more useful in practice . Lastly , the adaptiveness desideratum says we want the sets to communicate instance-wise uncertainty : they should be smaller for easy test-time examples than for hard ones ; see Figure 1 for an illustration . Coverage and size are obviously competing objectives , but size and adaptiveness are also often in tension . The size desideratum seeks small sets , while the adaptiveness desideratum seeks larger sets when the classi- Algorithm 1 Naive Prediction Sets Input : α , sorted scores s , associated permutation of classes I , boolean rand 1 : procedure NAIVE ( α , s , I , rand ) 2 : L← 1 3 : while ∑L i=1 si < 1− α do . Stop if 1− α probability exceeded 4 : L← L+ 1 5 : if rand then . Break ties randomly ( explained in Appendix B ) 6 : U ← Unif ( 0 , 1 ) 7 : V ← ( ∑L i=1 si − ( 1− α ) ) /sL 8 : if U ≤ V then 9 : L← L− 1 10 : return { I1 , ... , IL } Output : The 1− α prediction set , { I1 , ... , IL } fier is uncertain . For example , always predicting a set of size five could achieve coverage , but it is not adaptive . As noted above , both APSand RAPS achieve correct coverage , and we will show that RAPS improves upon APS according to the other two desiderata . We now turn to the specifics of our proposed method . We begin in Subsection 2.1 by describing an abstract data-splitting procedure called conformal calibration that enables the near-automatic construction of valid predictive sets ( that is , sets satisfying Eq . ( 1 ) ) . Subsequently , in Subsection 2.2 , we provide a detailed presentation of our procedure , with commentary in Section 2.3 . In Subsection 2.4 we discuss the optimality of our procedure , proving that it is at least as good as the procedure that returns sets of a fixed size , unlike alternative approaches .

Summary: The paper proposes a new conformalized procedure for computing uncertainty sets in classification tasks. The key feature of the method is that the size of the uncertainty sets are regularized via a penalty on the size. The issue of large uncertainty sets produced by conformalized procedures is an interesting one, which the paper does well to highlight. The proposed solution of using an additive regularizer is reasonable, and appears to be effective for sensible choices of the hyper-parameters. However, the paper has some significant weaknesses.