Evaluating and Calibrating Uncertainty Prediction in Regression Tasks

1 INTRODUCTION . Regression problems arise in many real-world machine learning tasks . To name just a few : Depth from a single image ( Eigen et al. , 2014 ) , Object localization and Acoustic localization ( Vera-Diaz et al. , 2018 ) . Many of these tasks are solved by deep neural networks used within decision making pipelines which require the machine learning block not only to predict the target but to also output its confidence in the prediction . For example , the commonly used Kalman-Filter tracking algorithm ( Blackman , 2004 ) requiring variance estimation for the observed object ’ s location estimation . In addition , we may want the system to output a final uncertainty , reflecting real-world empirical probabilities , to allow a safety-critical system such as a self-driving car agent to take appropriate actions when confidence drops . In practice , using the confidence in the localization of objects has been shown to improve the non-maximal suppression stage and consequently the overall detection performance ( He et al. , 2018 ) . Similarly , ( Feng et al. , 2018 ) describe a probabilistic 3D vehicle detector for Lidar point clouds that can model both classification and spatial uncertainty . To provide uncertainty estimation , each prediction produced by the machine learning module during inference should be a distribution over the target domain . There are several approaches for achieving this , most common are Bayesian neural networks ( Gal , 2016 ; Gal & Ghahramani , 2016 ) , ensembles ( Lakshminarayanan et al. , 2017 ) and outputting a parametric distribution directly ( Nix & Weigend , 1994 ) . Bayesian neural networks place a probability distribution over the network parameters , which is translated to an uncertainty in the prediction , providing a technically sound approach but with overhead at inference time . In the direct approach , outputs of the network represent the parameters of the output distribution for either discrete ( Niculescu-Mizil & Caruana , 2005 ) or continuous ( Nix & Weigend , 1994 ) distributions . Note that the direct approach naturally captures the aleatoric uncertainty ( inherent observation noise ) , but captures less the epistemic uncertainty ( uncertainty in the model ) ( Kendall & Gal , 2017 ) . We chose as a test case for our calibration method , the direct approach for producing uncertainty : we transform the network output from a single scalar to a Gaussian distribution by taking the scalar as the mean and adding a branch that predicts the standard deviation ( STD ) as in ( Lakshminarayanan et al. , 2017 ) . While this is probably the simplest form , it is commonly used in practice , and our analysis is applicable to more complex distributions as well as other approaches . Adjusting the output distributions to match the observed empirical ones via a post process is called uncertainty calibration . It was shown that modern deep networks tend to be over confident in their predictions ( Guo et al. , 2017 ) . The same study revealed that for classification , Platt Scaling ( Platt , 1999 ) , a simple scaling of the pre-activation of the last layer , achieves well calibrated confidence estimates ( Guo et al. , 2017 ) . In this paper we show that a similar simple scaling strategy , applied to the standard deviations of the output distributions , can calibrate regression algorithms as well . One major question is how to define calibration for regression , where the model outputs a continuous distribution over possible predictions . In recent work ( Kuleshov et al. , 2018 ) suggested a definition based on credible intervals where if we take the p percentiles of each predicted distribution the output should fall below them for exactly p percent of the data . Based on this definition the authors further suggested a calibration evaluation metric and re-calibration method . While this seems very sensible and has the advantage of considering the entire distribution , we found serious flaws in this definition . The main problem arises from averaging over the whole dataset . We show , both empirically and analytically , that one can calibrate using this evaluation metric practically any output distribution , even one which is entirely uncorrelated with the empirical uncertainty as can be seen in Fig . 1 . We elaborate on this property of the evaluation method described in ( Kuleshov et al. , 2018 ) in Section 2 and show empirical evidence in Section 4 . We propose a new simple definition for calibration for regression , which is closer to the standard one for classification . Calibration for classification can be viewed as expecting the output for every single data point to correctly predict its error , in terms of misclassification probability . In a similar fashion , we define calibration for regression by simply replacing the misclassification probability with the mean square error . Based on this definition , we propose a new calibration evaluation metric similar to the Expected Calibration Error ( ECE ) ( Naeini et al. , 2015 ) , which groups examples into interval bins with similar uncertainty , and then measures the discrepancy between each bin ’ s parameters and the parameters of the empirical distribution within the bin . An additional dispersion measure completes our set of diagnostic tools by revealing cases where the individual uncertainty outputs are uninformative as they all return similar values . Finally , we propose a calibration method where we re-adjust the predicted uncertainty , in our case the outputted Gaussian variance , by minimizing the negative-log-likelihood ( NLL ) on a separate re-calibration set . We show good calibration results on a real-world dataset using a simple parametric model which scales the uncertainty by a constant factor . As opposed to ( Kuleshov et al. , 2018 ) , we show that our approach can not calibrate predicted uncertainty that is uncorrelated with the real uncertainty , as one would expect . To summarize , our main contributions are : • Revealing the fundamental flaws in the current definition of calibrated regression uncertainty ( Kuleshov et al. , 2018 ) • A new proposed definition for calibrated uncertainty in regression tasks • A simple scaling method that can reduce the calibration error similar to temperature scaling for classification ( Guo et al. , 2017 ) , evaluated on large scale real world vision datasets . 1.1 RELATED WORK . While shallow neural networks are typically well-calibrated ( Niculescu-Mizil & Caruana , 2005 ) , modern , deep networks , albeit superior in accuracy , are no-longer calibrated ( Guo et al. , 2017 ) . Uncertainty calibration for classification is a relatively studied field . Calibration plots or Reliability diagrams provide a visual representation of uncertainty prediction calibration ( DeGroot & Fienberg , 1983 ; Niculescu-Mizil & Caruana , 2005 ) by plotting expected sample accuracy as a function of confidence . Confidence values are grouped into interval bins to allow computing the sample accuracy . A perfect model corresponds to the plot of the identity function . The Expected Calibration Error ( ECE ) ( Naeini et al. , 2015 ) summarizes the reliability diagram by averaging the error ( gap between confidence and accuracy ) in each bin , producing a single value measure of the calibration . Similarly , the Maximum Calibration Error ( MCE ) ( Naeini et al. , 2015 ) measures the maximal gap . Negative Log Likelihood ( NLL ) is a standard measure of a model ’ s fit to the data ( Hastie et al. , 2001 ) but combines both accuracy of the model and its uncertainty estimation in one measure . Based on these measures , several calibration methods were proposed , which transform the network ’ s confidence output to one that will produce a calibrated prediction . Non-parametric transformations include Histogram Binning ( Zadrozny & Elkan , 2001 ) , Bayesian Binning into Quantiles ( Naeini et al. , 2015 ) and Isotonic Regression ( Zadrozny & Elkan , 2001 ) while parametric transformations include versions of Platt Scaling ( Platt , 1999 ) such as Matrix Scaling and Temperature Scaling ( Guo et al. , 2017 ) . In ( Guo et al. , 2017 ) it is demonstrated that the simple Temperature Scaling , consisting of a one scalingparameter model which multiplies the last layer logits , suffices to produce excellent calibration on many classification data-sets . In comparison with classification , calibration of uncertainty prediction in regression , has received little attention so far . As already described , ( Kuleshov et al. , 2018 ) propose a practical method for evaluation and calibration based on confidence intervals and isotonic regression . The proposed method is applied in the context of Bayesian neural networks . In recent work ( Phan et al. , 2018 ) , the authors follow ( Kuleshov et al. , 2018 ) definition and method of calibration for regression , but use a standard deviation vs. MSE scatter plot , somewhat similar to our approach , as a sanity check . 2 CONFIDENCE-INTERVALS BASED CALIBRATION . We next review the method for regression uncertainty calibration proposed in ( Kuleshov et al. , 2018 ) which is based on confidence intervals , and highlight its shortcomings . We refer to this method in short as the “ interval-based ” calibration method . We start by introducing basic notations for uncertainty calibration used throughout the paper . Notations . Let X , Y ∼ P be two random variables jointly distributed according to P and X × Y their corresponding domains . A dataset { ( xt , yt ) } Tt=1 consists of i.i.d samples of X , Y . A forecaster H : X → P ( Y ) outputs per example xt a distribution pt ≡ H ( xt ) over the label space , where P ( Y ) is the set of all distributions over Y . In classification tasks , Y is discrete and pt is a multinomial distribution , and in regression tasks in which Y is a continuous domain , pt is usually a parametric probability density function , e.g . a Gaussian . For regression , we denote by Ft : Y → [ 0 , 1 ] the CDF corresponding to pt . According to ( Kuleshov et al. , 2018 ) a forecaster in a regression setting H is calibrated if : ∑T t=1 I { yt ≤ F −1 t ( p ) } T T→∞−−−−→ p , ∀p ∈ [ 0 , 1 ] ( 1 ) . Intuitively this means that the yt is smaller than F−1t ( p ) with probability approximately p , or that the predicted CDF matches the empirical one as the dataset size goes to infinity . This is equivalent to PX , Y ( Y ≤ [ F ( X ) ] −1 ( p ) ) = p , ∀p ∈ [ 0 , 1 ] ( 2 ) Where F ( X ) represents the CDF corresponding to H ( X ) . This notion is translated by ( Kuleshov et al. , 2018 ) to a practical evaluation and calibration methodology . A re-calibration dataset S = { ( xt , yt ) } Tt=1 is used to compute the empirical CDF value for each predicted CDF value p ∈ Ft ( yt ) : P̂ ( p ) = | { yt|Ft ( yt ) ≤ p , t = 1 . . . T } | T ( 3 ) The calibration consists of fitting a regression function R ( i.e . isotonic regression ) , to the set of points { ( p , P̂ ( p ) ) } Tt=1 . For diagnosis the authors suggest a calibration plot of { ( p , P̂ ( p ) ) } at equally spaced values of p. We start by intuitively explaining the basic limitation of this methodology . From Eq . 3 P̂ is nondecreasing and therefore isotonic regression finds a perfect fit . Therefore , the modified CDF R ◦ Ft will satisfy P̂ ( p ) = p on the re-calibration set , and the new forecaster is calibrated up to sampling error . This means that perfect calibration is possible no matter what the CDF output is , even for output CDFs which are statistically independent of the actual empirical uncertainty . We note that this might be acceptable when the uncertainty prediction is degenerate , e.g . all output distributions are Gaussian with the same variance , but this is not the case here . We also note that the issue is with the calibration definition not the re-calibration , as we show with the following analytic example . We next present a concise analytic example in which the output distribution and the ground truth distribution are independent , yet fully calibrated according to Eq . 2 . Consider the case where the target has a normal distribution yt ∼ N ( 0 , 1 ) and the network outputH ( xt ) has a Cauchy distribution with zero location parameter and random scale parameter γt independent of xt and yt , defined as : zt ∼ N ( 0 , 1 ) ( 4 ) γt = |zt| H ( xt ) = Cauchy ( 0 , γt ) Following a known equality for Cauchy distributions , the CDF output of the network Ft ( y ) = F ( y γt ) , where F is the CDF of a Cauchy distribution with zero location and 1 scale parameters . First we note that ytγt and yt zt , i.e . with and without the absolute value , have the same distribution due to symmetry . Next we recall the well known fact that the ratio of two independent normal random variables is distributed as Cauchy with zero location and 1 scale parameters ( i.e . ytzt ∼ Cauchy ( 0 , 1 ) ) . This means that probability that Ft ( yt ) ≡ F ( ytγt ) ≤ p is exactly p ( recall that F is a Cauchy ( 0 , 1 ) CDF ) . In other words , the prediction is perfectly calibrated according to the definition in Eq . 2 , even though the scale parameter was random and independent of the distribution of yt . While the Cauchy distribution is a bit unusual due to the lack of mean and variance , the example does not depend on it and it was chosen for simplicity of exposition . It is possible to prove the existence of a distribution whose product of two independent samples is Gaussian ( Thorin , 1977 ) and replace the Cauchy with a Gaussian , but it is an implicit construction and not a familiar distribution .

Summary: This paper is concerned with uncertainty calibration diagnostics and re-calibration methods, applied to neural network regression. It is motivated by a flaw in the diagnostic proposed by Kuleshov+ 2018 (abreviated K2018 below), as explained around eq4, and proposes a replacement diagnostic for uncertainty calibration quality (sec 3 before 3.1). It then specialises by considering the class of uncertainty prediction schemes qualified as "direct" uncertainty modeling (defined sec1), in which the network predicts the parameters of a parametric distribution over the target output, typically mean and variance of a Gaussian. For this class of schemes, it proposes a recalibration method (sec 3.1), which consists, as shown eq12, of rescaling (with a single parameter $s$) the square root of the variance predicted by the neural network. It then presents experiments (sec4) to demonstrate that the motivating flaw can be evidenced by their diagnostic, and fixed by their recalibration method where it makes sense (ie where predicted uncertainties are not random, i.e. statistically independent of the empirical uncertainty).