Q UANTILE R EGULARIZATION : T OWARDS I MPLICIT C ALIBRATION OF R EGRESSION M ODELS
Anonymous authors
Paper under double-blind review
A BSTRACT
Deep learning models are often poorly calibrated, i.e., they may produce overconﬁdent predictions that are wrong, implying that their uncertainty estimates are unreliable.
While a number of approaches have been proposed recently to calibrate classiﬁcation models, relatively little work exists on calibrating regression models.
Isotonic Regression has recently been advocated for regression calibration.
We provide a detailed formal analysis of the side-effects of Isotonic Regression when used for regression calibration.
To address these, we investigate the idea of quantile calibration (Kuleshov et al., 2018), recast it as entropy estimation, and leverage the new formulation to construct a novel quantile regularizer, which can be used as a blackbox to calibrate any probabilistic regression model.
Unlike most of the existing approaches for calibrating regression models, which are based on post hoc processing of the model’s output, and require an additional dataset, our method is trainable in an end-to-end fashion, without requiring an additional dataset.
We provide empirical results demonstrating that our approach improves calibration for regression models trained on diverse architectures that provide uncertainty estimates, such as Dropout VI, Deep Ensembles.
I NTRODUCTION
For supervised machine learning, the notion of calibration of a learned predictive model is a measure of evaluating how well a model’s conﬁdence in its prediction matches with the correctness of these predictions.
For example, a binary classiﬁer will be considered perfectly calibrated if, among all predictions with probability score 0.9, 90% of the predictions are correct Guo et al.
Likewise, consider a probabilistic regression model that produces credible interval for the predicted outputs.
In this setting, the model will be considered perfectly calibrated if the 90% conﬁdence interval contains 90% of the true test outputs (Kuleshov et al., 2018).
Unfortunately, modern deep neural networks are known to be poorly calibrated (Guo et al., 2017), raising questions on their reliability.
The notion of calibration for classiﬁcation problems was originally ﬁrst considered in meteorology literature (Brier, 1950; Murphy, 1972; Gneiting & Raftery, 2007) and saw one of its ﬁrst prominent usage used in the machine learning literature by (Platt et al., 1999) in context of Support Vector Machines (SVM), in order to obtain probabilistic predictions from SVMs which are inherently non-probabilistic models.
Recently, there has been renewed interested in calibration, especially for classiﬁcation models, after it has been shown (Guo et al., 2017) that modern deep neural networks for classiﬁcation are often poorly calibrated.
The pupular notions of calibration for classiﬁcation include conﬁdence calibration, multiclass calibration, classwise calibration, and conﬁdence calibration (Kumar et al., 2019;
Vaicenavicius et al., 2019; Kull et al., 2019).
Most calibration methods (Platt et al., 1999; Zadrozny & Elkan, 2001; 2002; Guo et al., 2017; Kull et al., 2017; 2019) for classiﬁcation models are post hoc , where they learn a calibration mapping R : [0 , 1] → [0 , 1] using an additional dataset to recalibrate an already trained model.
There has been recent work showing some of these popular post hoc methods are either themselves miscalibrated or sample-inefﬁcient (Kumar et al., 2019) and they do not actually help the model output well-calibrated probabilities.
An alternative to post hoc processing is to ensure that model outputs well-calibrated probabilities after model training ﬁnishes.
We refer to these as implicit calibration methods.
Notably, such an approach does not require an additional dataset to learn the calibration mapping.
While almost all post hoc calibration methods for classiﬁcation models can be seen in a uniﬁed manner as density estimation methods (see section 2.1 ), existing implicit calibration methods for classiﬁcation models have been designed with various, often distinct, considerations/approaches.
Several heuristics like
Mixup (Zhang et al., 2017; Thulasidasan et al., 2019) and Label Smoothing (Szegedy et al., 2016;
M¨uller et al., 2019) that were part of high performance deep networks for classiﬁcation were later shown empirically to achieve calibration.
(Maddox et al., 2019) show that their optimization method instrinsically improves calibration.
(Pereyra et al., 2017) found that penalizing high-conﬁdence predictions acts as a regularizer.
A more principled way of achieving implicit calibration is by minimizing a loss function that is tailored for calibration (Kumar et al., 2018).
This is somewhat similar in spirit to our proposed approach which aims to do it for regression models.
Among the early approaches for calibrating regression models, (Gneiting et al., 2007) were the ﬁrst to propose a framework for calibrating regression models.
However, they do not provide any procedure to correct a miscalibrated model.
Recently, (Kuleshov et al., 2018) introduced the notion of Quantile Calibration which intuitively says that the p conﬁdence interval predicted by model should have target variable with probability p .
They use a post hoc calibration method based on Isotonic Regression (Fawcett & Niculescu-Mizil, 2007), which is a well-known calibration technique for classiﬁcation models.
The difference between Isotonic Calibration in classiﬁcation and Isotonic
Calibration in regression is in terms of ( i ) the dataset on which calibration mapping is learnt; and ( ii ) the function with which learnt calibration mapping is pre-composed .
In the former case, it is pre-composed with a probability mass function (PMF) and whereas in the latter, it is pre-composed with a conditional density function (CDF).
Both these differences have side effects; in particular ( i ) the nature of recalibration dataset already satisﬁes monotonicity constraint, so there is a risk of overﬁtting in case of smaller calibration datsets; and ( ii ) composing the CDF with a piecewise linear function can make the resultant CDF discontinuous and the corresponding PDF non-differentiable (see Sec.
3 for detailed discussion for side effects of the Isotonic Calibration approach).
In another recent work, (Song et al., 2019) proposed a much stronger notion of calibration called Distributional
Calibration which guarantees that among all instances whose predicted probability density function (PDF) of the response variable has mean µ and standard deviation σ , the marginal distribution of the target variable should have mean µ and standard deviation σ .
They too propose a post hoc recalibration method based on Gaussian processes, which can be computationally expensive.
Among other work, (Keren et al., 2018), consider a different setting where neural networks for classiﬁcation are used for regression problems and showed that temperature scaling (Hinton et al., 2015; Guo et al., 2017) and their proposed method based on empirical prediction intervals improves calibration for regression problems as well.
Again, these are post hoc methods.
Our contributions are summarized below:
We analyze in detail the side effects of Isotonic Calibration for regression models.
We show how using Isotonic Calibration results in truncation of the support, which will result in assigning zero likelihood fortes t time.
We also discuss about Isotonic Calibration resulting in nonsmooth PDFs, and its tendency to produce miscalibration when using small calibration datasets.
At test time, after composing the predicted CDF with the learned isotonic mapping, the mean prediction (point estimate) also changes.
Kuleshov et al.
(2018) do not acknowledge the changes in the mean estimate.
While Song et al.
(2019) acknowledge this issue, they use a trapezoidal approximation to remedy this.
In contrast, we derive an analytical expression for the updated point estimate after isotonic calibration.
We also provide a different expression for updated point estimate, which reduces the time-complexity from O ( m ) to O (1) , where m is calibration dataset size.
In order to mitigate these shortcomings of Isotonic Calibration, we propose a simple, yet novel and general purpose, trainable loss function for quantile calibration where the smoothness of PDF/CDF is not sacriﬁced for well-calibrated probabilties.
Our approach also eliminates the need for an additional calibration dataset.
We conduct extensive experiments on a wide range of architectures using the proposed loss function (Quantile Regularization) and show empirically that it improves calibration on wide range of architectures that produce uncertainty estimates.
B ACKGROUND AND D EFINITIONS
Before we proceed with deﬁnitions, we state the notation followed in the rest of paper.
X , Y denotes the input and output space respectively.
X, Y denote random variables modelling inputs and outputs.
P denotes probability measure f, g are reserved for probability density functions (PDF) and F, G for cummulative density functions (CDF).
We use c to denote the evaluation of a CDF at some particular value i.e., c = F ( . ) and p for evaluation of a PDF at some value i.e., p = f ( . )
Given sequence of elements a 1 , a 2 , . . .
, a n , we use a (1) , a (2) , . . .
a ( n ) for permutation s.t a ( i ) ≤ a ( i +1) .
Also, m denotes the calibration dataset size.
( X , y ) denotes the training data.
Given random variables X, Y , we use KL ( X || Y ) to denote the KL divergence between the corresponding distributions
A probabilistic regression model can be seen as conditional PDF/conditional CDF.
In the rest of the paper, we express it as conditional CDF M : X → ( Y → [0 , 1]) .
So, M ( x ) denotes model’s predicted CDF for x ∈ X denoted as F x .
In practice this is achieved by making model output parameters that parametrize the CDF, e.g., ( µ, σ ) for Gaussian, λ for Exponential, etc.
In the rest of the paper, we consider Gaussian likelihood unless stated otherwise, because it is one of the most prevalent cases.
Kuleshov et al.
(2018) proposed the following notion of calibration of regression models, called quantile calibration .
An appearling aspect of this deﬁnition is that we get reliable conﬁdence intervals.
Deﬁnition 1 (Quantile Calibration)
Given a regression model M : X → ( Y → [0 , 1]) and X, Y jointly distributed as P , the model M is said to be Quantile Calibrated iff
[Equation]
In words, [ M ( X ) ]
( Y ) is cumulative density that the model predicts for random input-response pairs drawn from the joint distribution of ( X, Y ) .
It is important to note that, regardless of dimensions of
X , Y and support of distributions of X, Y and the likelihood of model considered, [ M ( X )]
( Y ) is a random variable whose support is a subset of [0 , 1] because range of any real-valued CDF is [0 , 1] .
So Def. 1 is quite general and covers the case when output is vector-valued, i.e., Y = R n , n >
2. F UNDAMENTAL T HEOREM OF P OST H OC C ALIBRATION
The objective of post hoc calibration is to recalibrate a miscalibrated model M by learning a mapping R : [0 , 1] → [0 , 1] s.t.
R ◦ M is a calibrated model.
One such mapping can be obtained from the deﬁnition of calibration itself.
Setting R ( p ) =
P (cid:2)
[ M ( X )]( Y ) ≤ p (cid:3) makes R ◦ M a quantile calibrated model.
(Vaicenavicius et al., 2019) call an analogous mapping in the context of classiﬁcation as canonical calibration mapping .
Theorem 1 For any Model M : X → ( Y → [0 , 1]) and given the canonical calibration mapping
R ( p ) =
P (cid:2)
[ M ( X )]( Y ) ≤ p (cid:3) , R ◦
M is quantile calibrated
Note that learning the mapping R reduces to density estimation of P (cid:2)
[ M ( X )]( Y ) ≤ p (cid:3) , which is a hard problem in itself.
With this insight, and using the fact that the mapping is monotonically increasing, (Kuleshov et al., 2018) use Isotonic Regression to learn the mapping on a separate calibration dataset.
Similar theorems hold for other notions of calibration, too.
2. I SOTONIC C ALIBRATION
We next describe Isotonic Calibration which is based on Isotonic Regression .
Given Data { ( a i , b i ) } mi =1 where a i , b i ∈ R and a i ≤ a i +1 .
Isotonic Regression ﬁnds new e 1 , e 2 , . . .
e m by solving the following optimization problem
[Equation]
(Mair et al., 2009) provides a nice survey of algorithms for Isotonic Regression.
In particular
Scikit-learn (Pedregosa et al., 2011) uses Pool Adjacent Violaters Algorithm (PAVA) of complexity
O ( m ) .
Given the calibration dataset { x i , y i } mi =1 , Isotonic Calibration ﬁrst builds recalibration dataset as
D
[Equation]
[ y
[Equation] [Equation]
x
[Equation]
[ y
[Equation] [Equation]
i
[Equation]
1 (cid:111) and sort points in D based on ﬁrst coordinates and then applies Isotonic Regression to get an isotonic mapping R .
Let x test be a test input and F x test =
M ( x test ) be the CDF of its predicted output.
Now, during post-hoc calibration, we get a new CDF as G x test =
R ◦ F x test .
Conﬁdence intervals can be obtained from G x test .
Note that the parameters that parametrize the G x test (after calibration) are different from F x test (before calibration).
Importantly, what this implies is that mean prediction before and after calibration changes as well.
(Kuleshov et al.
(2018)) do not take this aspect into consideration, whereas (Song et al.
(2019)) uses trapezoidal approximation to ﬁnd the new mean, and ﬁnding which has a time complexity O ( m ) .
In contrast, we derive an analytical expression for the new mean which reduces time complexity from
O ( m ) to O (1) at test-time (See Eq .4), assuming a Gaussian likelihood model.
A NALYSIS OF I SOTONIC C ALIBRATION
Let { ( x i , y i ) } m i =1 be the calibration dataset .
Let { ( µ i , σ 2 i ) } m i =1 be means and variances predicted by the learned model.
Suppose we have obtained CDF values at actual outputs ( y 1 , y 2 , · · · , y m ) .
Let these be ( c 1 , c 2 , · · · , c m ) .
Then the re-calibration dataset after sorting based on ﬁrst co-ordinates would be D =
( c (1) , 1 m ) , ( c (2) , 2 m ) , · · · , ( c ( m ) , 1) } where
C = ( c (1) , c (2) , · · · c ( m ) ) is obtained by sorting ( c 1 , c 2 , · · · c m ) in ascending order.
Now Isotonic Calibration ﬁts isotonic regression on the dataset D .
Our entire analysis is based on next crucial observation.
Since ( 1 m , 2 m , · · · , 1) are already in increasing order, isotonic regression does not modify values.
In the notation of Sec.
2.2 what this means is that, if we have that ( a i , b i ) (cid:44) ( c ( i ) , 1 i ) then it will be e i
=
i , i.e., b i will be same as e i .
So we do not even need to use Isotonic Regression and just linear interpolation on D yields the same result as Isotonic Regression.
We ﬁrst give conditions under which smoothness is lost and later derive the correction one has to use after isotonic calibration.
All the proofs are provided in the supplementary material.
Claim 1 Let Y be a random variable with CDF F , and let G
= R ◦ F be its CDF after composing with mapping R obtained from isotonic regression characterized by C =
{ c (1) , c (2) , · · · , c ( m ) } .
If there exist i − 1 , i, i +1 ∈ { 0 , m }∧ c ( i ) − c
( i − 1) (cid:54) =
c ( i +1) − c
( i ) then the CDF G is not differentiable and its corresponding probability density function g is not continuous at F − 1 ( c ( i ) )
Because of this, the PDF of transformed r.v becomes discontinuous and spiky (see Fig. 2d ).
Update likelihood inversely depends on m ( c ( i ) − c
( i +1) )
(see Eq.
10 for full expression).
In many of cases, it becomes so small that sometimes the updated likelihood increases by factor of 10 2 to 10 5 for single point thereby completely destroying what the average log likelihood represents.
To show this, we report the maximum likelihood attained among the entire test dataset after isotonic calibration in
UCI experiments (see Table 4, Table 5).
Now we derive the analytical expression for the updated mean after Isotonic Calibration assuming a
Guassian likelihood.
Claim 2 Let Y iso be the transformed random variable after applying isotonic mapping R on the random variable Y .
Then the expectation of Y iso is as follows
[Equation]
The summation involves both recalibration dataset and test time prediction.
Now we will use properties of quantile functions (Lemma. 1) to decouple the dependency, using which summation just depends on the recalibration dataset.
Claim 3 Let c ( i ) =
F µ ( i ) ,σ ( i ) ( y ( i ) ) and p ( i ) =
f µ ( i ) ,σ ( i ) ( y ( i ) )
[Equation]
Now δ can be computed once , so at test time given µ, σ as model prediction, the updated mean after isotonic calibration is µ − δσ .
With this, the time required is reduced from O ( m ) to O (1) .
Also, the construction of recalibration dataset as suggested in (Kuleshov et al., 2018) can result in truncation of the support of updated r.v (see ﬁg. 2d) and see Sec.
B.1 for more on this.
One way to remedy this is to use ( x , ∞ ) to calibration dataset for any x ∈ R n .
So the recalibration dataset becomes { ( c (1) , 1 m +1 ) , . . .
, ( c ( m ) , mn +1 ) , (1 , 1) } .
To illustrate all these , we use Bayesian linear regression with 256 training examples generated from y = 3 x + (cid:15) where (cid:15) ∼ N (0 , 1) .
and x ∈ [ − 4 , 4] randomly sampled and calibration dataset of size 32 .
Q UANTILE R EGULARIZATION
In quantile calibration, we want P (cid:2)
[ M ( X )]( Y ) ≤ p (cid:3) =
p ∀ p ∈ [0 , 1] .
Our method is based on the idea that both right and left hand sides can be viewed as CDFs.
Let R ( p ) =
P (cid:2)
[ M ( X )]( Y ) ≤ p (cid:3) and S ( p ) = p .
Here R can be seen as the CDF of [ M ( X )]
( Y ) while S can be seen as the CDF of Uniform[0,1].
Quantile calibration mandates these two CDFs to be equal.
So, for a perfectly calibrated quantile model M , we have that [ M ( X )]
( Y ) be a uniform distribution.
We seek to penalize the model when this r.v deviates from a uniform distribution which gives us a calibration loss that can be used as a regularizer with any regression loss, achieving highly desirable calibration during training itself.
We name above proposed procedure as Quantile Regularization , hereafter denoted as
QR.
We use the KL divergence as the distance measure.
Note that the KL divergence between any distribution on [0 , 1] and the uniform distribution is negative of the differential entropy, which provides a very intuitive interpretation for the Quantile Regularization (QR).
Essentially, to improve calibration while training, QR maximizes the differential entropy of [ M ( X )]( Y ) i.e., the predicted cumulative density of target value.
We formalize the statement for completeness below.
Claim 4 Let M be any regression model.
Then M is perfectly quantile calibrated iff
[Equation]
[Equation]
[Figure]
4. D IFFERENTIAL E NTROPY E STIMATION
We need the differential entropy estimator for deriving our calibration loss function.
There is a rich literature for entropy estimation.
A brief overview about non-parametric entropy estimation can be found in (Beirlant & Dudewicz, 1997).
We use sample-spacing entropy estimation originally proposed in (Vasicek, 1976).
A k spacing of random variable is deﬁned as the amount of probability mass between ordered samples that are k − 1 samples apart.
Let S be a one-dimensional r.v. with
CDF F and assume we are given n samples { s i } ni =1 ∼ S and k s.t. 1 ≤ k ≤ n .
Sample spacing entropy estimation is based on the following observation of k-spacings of random variables
[Equation]
There are many formulations of sample spacing entropy estimators but we use the one in (LearnedMiller et al.
(2003); Equation 8 ) which is
[Equation]
4. C ALIBRATION L OSS F UNCTION
In our case, the random variable is [ M ( X )]
( Y ) .
Given training data with input-output pairs ( x i , y i ) , we need to get samples [ M ( x i )]
( y i ) , compute the expression ˆ H ( S ) , and maximize it.
Note that, we want to make this part of the training loop to achieve implicit calibration.
To do so, we need ordered samples to compute the Entropy in Eq. 6.
However, inherently, sorting is not a differentiable operation.
We therefore use NeuralSort (Grover et al., 2019) as a differentiable relaxation to sorting.
We summarize our Quantile Regularization algorithm below
Algorithm 1 Quantile Regularization
Precondition: ( x i , y i ) are n i.i.d training instances and µ i , σ i =
MODEL w ( x i ) and DIFFSORT is any differentiable relaxation to sorting operation.
1: function C ALIBRATION L OSS FUNCTION ( y , µ , σ ) 2: 3: for i ← 1 to m do 4: Φ i ← Φ( µ i , σ i ) (cid:46)
Φ : CDF 5: c i ← Φ i
[ y i ] 6: end for 7: s ← DIFFSORT ( c ) 8:
k ← √ n 9: e ← n − k n − k (cid:88) i = log (cid:104) n +k ( s i + k − s i ) (cid:105) 10: return e 11: 12: end function
Assume that X , y is the training data.
Let ( µ w , σ w ) =
MODEL w ( X ) , where w denotes the parameters of the model, (cid:96) ( y , µ w , σ w ) denotes the architecture speciﬁc loss and CL be calibration loss computed by Algorithm 1.
The overall loss function can be written as follows, where the L is the hyperparameter that controls the effect of QR.
[Equation]
4. D EGENERATE B UT P ERFECTLY Q UANTILE C ALIBRATED M ODEL
Every notion of calibration has examples of models such that it is perfectly calibrated according to that speciﬁc notion but is far from the ideal model.
We prove below that Quantile Calibration is no different.
Speciﬁcally, we give conditions under which a model is quantile calibrated and then use it to build a model that is degenerate in the sense that the model does not depend on the inputs while predicting output, but is a perfectly quantile calibrated model.
Claim 5 Let f be the marginal distribution of Y and F x = M [ x ] be the model’s predicted cumulative distribution for x ∈ X and f x be the corresponding predicted probability density then, if following holds, M is Quantile Calibrated
[Equation]
Now if we set f = f x ∀ x , the above condition easily holds.
So, a model that outputs marginal distribution of Y for every input x ∈ X , is perfectly quantile calibrated.
Note that this observation is general that it does not require Gaussian likelihood, for it to be true .
As a simple example, consider f ( x, y )
=
N ( y | 5 x, 1) N ( x | 0 , 4) .
then the marginal distribution of y is f ( y ) =
(cid:82) ∞
−∞ N ( y | 5 x, 1) N ( x | 0 , 4) dx =
N ( y | 5 . 0 , 5 .
5 + 1 2 ) =
N ( y | 0 , 401) so the model which predicts N ( y | 0 , 401) regardless of input is perfectly quantile calibrated, but the true model is
N ( y | 5 x, 1) .
So, a model can predict good conﬁdence intervals despite being far from ideal.
Therefore, we need model to be both well-calibrated and sharp.
E XPERIMENTS
We evaluate our approach on various regression datasets in terms of the calibration error as well as other standard metrics, such as root-mean-squared-error (RMSE) and negative log-likelihood (NLL).
[Table]
5. l 2 Q UANTILE C ALIBRATION E RROR
Given any model M : X → ( Y → [0 , 1]) , we deﬁne the l 2 calibration error as follows.
Let us choose M equidistant points { p i } Mi =1 in (0 , 1] with p M = 1 .
Given a test set { x i , y i } Nn =1 , whose predictions are F n = F ( x n ) , the M-bin estimator of above integral gives us the calibration metric used in (Kuleshov et al., 2018).
[Equation]
5. UCI D ATA E XPERIMENTS
We consider two architectures - Dropout VI (Gal, 2016) and Deep Ensembles(Lakshminarayanan et al., 2017).
The dataset sizes ranges from 308 to 515345 and input feature dimensions ranges from 6 to 91 .
Every dataset, except Year Prediction MSD, is divided into 5 splits whereas for
Year Prediction MSD there is a single split where we train on 463715 points and test onpoints.
This experiment is repeated 3 times and averages are reported except for Year Prediction
MSD.
We use 2 hidden layer network with 128 units with ReLU activation, and trained with Adam
Optimizer with a learning rate of 10 − 2 .
Results are presented in Table 1 and 2.
We use L =for Dropout-VI and L = 5 for Deep Ensembles.
Spacing value is choosen as k = √ n for all datasets except Year Prediction MSD, for which we use k = 3 ∗ √ n for both architectures where n is the batch size.
See Sec.
C.3 and Sec.
C.4 for detailed experiments about how values of L , k inﬂuence calibration error and RMSE.
The code and link to the datasets can be found here:
https: //github.com/occam-ra-zor/QR
5. M ONOCULAR D EPTH E STIMATION
Now we consider problem of Monocular Depth Estimation.
We use architecture present in J´egou et al.
(2017) which combines principles of Dense-nets and U-net for Dense prediction tasks like semantic segmenation and depth estimation.
We use Make3d
Dataset (Saxena et al.
(2005)) which has 400 scenes for training and 134 scenes for testing.
We use 57 and 103 layer Neural Network, which is denoted as FC-DenseNet57, FC-DenseNet103 in J´egou et al.
We set L = 0 .
1 and k = √ n where n is batchsize.
Also, we use pooling layers on cummulative density values to make sure the locality is exploited and to decrease the computational time, while computing calibration loss.
Results are presents in Table.
3 and additional details and experiments in Sec.
C.
D ISCUSSION
Both, in case of Dropout VI and Deep Ensembles, calibration error improves when trained with quantile regularizer.
Table 3 indicates Quantile Regularization is effective in large scale architec-
[Table] [Table]
tures as well.
Tables 4,5 indicate QR-trained model works better than base in post-hoc setting too.
Also in some cases, Isotonic Calibration increases the calibration error (e.g., for dropout VI, see
Concrete Strength, Yacht Hydrodynamics and for Deep Ensembles see Boston Housing and Yacht
Hydrodynamics).
We believe this is due to two reasons
Unlike isotonic calibration for classiﬁcation calibration, recalibration dataset in case of regression calibration already satisﬁes monotonicity constraint (see Sec. 3).
So Isotonic calibration in case of regression calibration has much weaker regularization properties and hence overﬁts 2.
Isotonic calibration is a non-parameteric method that requires large amount of data to work well.
This could be another reason for the poor performance of isotonic regression in some cases.
For large calibration datasets like protein structure (calibration dataset size m = 36 , 584 ) and Year
Prediction MSD ( calibration dataset size m = 463715 ), Isotonic Regression offers better improvements.
Although it can work well in such setting, the PDF after calibration becomes unusable.
QR not only works well on small datasets but also works well on very large datasets, like Year prediction MSD (nearly 60 % improvement on both architectures).
There is a small increase in RMSE and
NLL in models trained with QR, but in many cases it is negligible.
A possible justiﬁcation for this is that just because the model is well calibrated doesn’t necessarily mean it is close to the true model.
Being well0calibrated and being close to true model are two separate things (see Sec. 4.3).
C ONCLUSION
We have proposed a black-box calibration loss function that can be used with any probabilistic regression model.
Unlike current methods for quantile calibration, our method is implicit in nature and does not require an additional calibration dataset and, more importantly, the smoothness of the
PDF is not lost.
We conduct experiments to show effectiveness of our proposed method.
A PPENDIX A PROOFS A. P ROOF OF T HEOREM
Theorem 1 For any Model M : X → ( Y → [0 , 1]) and given canonical calibration mapping
R ( p ) =
P (cid:2)
[ M ( X )]( Y ) ≤ p (cid:3) , R ◦
M is quantile calibrated
Proof: To show that R ◦ M is quantile calibrated.
we need to show that P [( R ◦ M )[ X ][ Y ] ≤ p ] = p , ∀ p ∈ [0 , 1] since we are assuming that R ( p ) is invertible function, which gives us that it is surjective.
An equivalent way of showing this is that P [ ( R ◦ M )
[ X ][ Y ] ≤ R ( p )]
= R ( p ) ∀ p ∈ [0 , 1]
P (cid:20) ( R ◦ M )
[ X ][ Y ] ≤ R ( p ) (cid:21) =
P (cid:20) R − 1 (cid:0) ( R ◦ M )
[ X ][ Y ] (cid:1) ≤ R − 1 (cid:0) R ( p ) (cid:1)(cid:21) R − 1 is strictly increasing
[Equation]
By deﬁnition (cid:3)
A. P ROOF OF CLAIM 1,2,
Claim 1 Let Y be a random variable with CDF F , and let G
= R ◦ F be its CDF after composing with mapping R obtained from isotonic regression characterized by C =
{ c (1) , c (2) , · · · , c ( m ) } .
If there exist i − 1 , i, i +1 ∈ { 0 , m }∧ c ( i ) − c
( i − 1) (cid:54) =
c ( i +1) − c
( i ) then the CDF G is not differentiable and its corresponding probability density function g is not continuous at F − 1 ( c ( i ) )
Proof: First, G can be expressed as follows
[Equation]
Let a = F − 1 ( c (1) ) .
We will show that G not differentiable at a .
Similarly we can show that it is not differentiable at the other m − 2 switching points.
The left derivative is as follows
[Equation]
The right derivative is as follows
[Equation]
Hence G is not differentiable.
Although the CDF is not differentiable at only a ﬁnite number of points, we can still get the PDF by piece-wise differentiation.
[Equation]
Now consider for any i − 1 , i, i + 1 ∈ { 0 , m } s
[Equation]
t c i − c
i − 1 (cid:54) =
c i +1 − c i .
Let a = F − 1 ( c i ) then
[Equation]
Since the right limit and left limit do not coincide and by construction of point a , we have that limit does not exist and therefore g ( x ) is not continuous at a
Note that, most of times, the hypothesis is satisﬁed, so the smoothness is lost.
[Equation]
Claim 2 Let Y iso be transformed random variable after applying isotonic mapping R on random variable Y .
Then the expectation of Y iso is as follows
[Equation]
Proof: Assume that, before transformation, the random variable is distributed X ∼ N ( µ, σ 2 ) so f ( x ) =
[Equation] [Equation]
using linearity
[Equation]
using def of cdf
[Equation]
Lemma 1 Let f µ,σ , F µ,σ , F − 1 µ,σ be density, distribution, and quantile functions, respectively, of the normal distribution with mean µ and std σ .
Then
[Equation]
Proof: We use the following three properties of normally distributed random variables
F µ,σ ( y ) =
F 0 , 1 ( y − µ σ ) 2. f
[Equation]
by using
[Equation]
Claim
[Equation]
Proof: We ﬁrst re-substitute c ( i ) =
F µ ( i +1) ,σ ( i +1)
( y ( i +1) ) , then using the above claim, substituting that f ( F − 1 ( c (0) ))
=
f ( F − 1 (0))
=
lim x →−∞ f ( x ) =µ − σm m (cid:88)
i
=
f ( F − 1 ( c ( i +1) ))
− f ( F − 1 ( c ( i ) ))
( c ( i +1) − c
i ) )
= µ − σm m (cid:88)
i =
f ( F − 1 ( F µ ( i +1) ,σ ( i +1)
( y ( i +1) )))
− f ( F − 1 ( F µ ( i +1) ,σ ( i +1)
( y ( i +1) )))
( c ( i +1) − c
i ) )
= µ − σ m (cid:104) σ (1) p (1) c (1) + m − 1 (cid:88)
i =
σ ( i +1) p ( i +1)
− σ ( i ) p
( i ) c
( i +1)
− c ( i ) (cid:105) by using f ( F − 1 ( c (0) ))
= 0 , c (0) =
= µ − σ m (cid:104) m − 1 (cid:88) i =
σ ( i +1) p ( i +1)
− σ ( i ) p
( i ) c
( i +1)
− c ( i ) (cid:105) σ (0) = 0 , p (0)
= 0 , c (0) =(cid:3)
A. P ROOFS OF CLAIM 4 AND CLAIM
Claim 4 Let M be any regression model.
Then M is perfectly quantile calibrated iff
[Equation]
Proof: (cid:3)
Claim 5 Let f µ,σ be the marginal distribution of Y and (cid:16) F µ x ,σ x = M
[ x ] (cid:17)(cid:12)(cid:12)(cid:12) X
= x be the model’s predicted cumulative distribution for x ∈ X , then if f µ,σ [ F − 1 µ x ,σ x ( p )]
= f µ x ,σ x ( F − 1 µ x
Proof:
[Equation]
Since we have that M [ X ][ Y ] Uniform [0 , 1] we can conclude that M is Perfectly Quantile Calibrated.
(cid:3)
B I MPLEMENTATION D ETAILS B. C ALCULATING N EGATIVE L OG L IKELIHOOD AFTER I SOTONIC C ALIBRATION
Note that we have analytical expression for the updated density function g (see Eq. 10 ).
Given a test input x test , predicted CDF F , corresponding PDF f and target y test , now we describe the procedure to calculate likelihood for y test after isotonic calibration i.e., g ( y test ) .
Recall that c ( i ) ’s are ordered x-coordinates of recalibration dataset.
Now since F − 1 ( c ( i − 1) ) ≤ x < F − 1 ( c ( i ) ) implies that c ( i − 1) ≤ F ( x ) <
c
( i ) as F is monotonic.
We can then do binary search for ﬁnding the correct i
s.t c
( i − 1) ≤ F ( x ) <
c ( i ) and scaling appropriately.
This is summarized below
[Equation]
B. C ALCULATION OF T RUNCATION P OINT
The above algorithm clearly elucidates why there is a possibility of assigning zero likelihood at test time after Isotonic Calibration as discussed in Sec.
If F ( y test ) > c ( m ) then we have that g ( y test )
= 0 .
So truncation point is y trun =
F − 1 ( c ( m ) ) .
Then the support of random variable is reduced from ( −∞ , + ∞ ) to ( −∞ , y trun ] .
so for every point in ( y trun , ∞ ) model assigns zero likelihood, which is extremely undesirable.
A simple way to circumvent this proposed in the discussion in Sec.
C E XPERIMENTS C. B AYESIAN L INEAR R EGRESSION
For Bayesian Linear Regressionm we use sklearn’s
(Pedregosa et al., 2011)
Bayesian Ridge Regression implementation
. C. UCI- EXPERIMENTS C.2. EXPERIMENTAL RESULTS AFTER POST - HOC CALIBRATION
[Table] [Table]
[Figure]
d
[Figure] [Figure]
p r e d i c t
[Figure]
C. V ARYING Q UANTILE R EGULARIZATION P ARAMETER L
In the following sections, we show how quantile regularization parameter L affects both calibration error and Root Mean Square Error (RMSE) for dropout-VI in Sec.
C.3.1 and for deep ensembles in
Sec. C.3.2.
We do so by ﬁxing spacing value to k = √ n , where n is batch-size and varying L
C.3. FOR DROPOUT
5 QR reg parameter L      c a li b r a t
i
o n e rr o r %
[Figure]
[Figure] [Figure]
[Figure] [Figure]
[Figure] [Figure]
c a li
[Figure]
a t i o n e
[Figure]
% fishredwhiteprotein
5 QR reg parameter L
R M S E airfoilbostonconcreteyachtprotein    5 QR reg parameter L 0.
R M S E fishkin8nmredwhite
C.3. F OR D EEP E NSEMBLES
5 QR reg parameter L     c a li b r a t i o n e rr o r % airfoilbostonconcreteyacht    5 QR reg parameter L       c a li b r a t
i
o n e rr o r
% fishkin8nmredwhiteprotein
5 QR reg parameter L
R M S E airfoilbostonconcreteyachtprotein    5 QR reg parameter L 0.
R M S E fishkin8nmredwhite
C. V ARYING S PACING VALUE k
In the following sections, we show how spacing value k affects both calibration error and Root Mean
Square Error (RMSE) for dropout-VI in Sec.
C.4.1 and for deep ensembles in Sec.
C.4.2.
We do so by ﬁxed Quantile Regularization parameter L and varying spacing to different multiplies of √ n .
C.4. D ROPOUT -VI
[Figure] [Figure]
c a li
[Figure]
r a t i o n e rr o r %
[Figure]
[Figure] [Figure]
R M
[Figure]
E
[Figure] [Figure]
R M S E fishkin8nmredwhite
[Figure]
[Figure]
c a li b r a t i o n e rr o r % airfoilbostonconcreteyacht    5 spacing multiplier t    c a li b r a t i o n e rr o r % fishkin8nmredwhiteproteinyear
[Figure]
C. I SOTONIC C ALIBRATION WITH K- FOLD CROSS VALIDATION
Note that, in the UCI experiments, we used the training data as was done in Kuleshov et al.
In this sections this we consider Isotonic Calibration with K-fold cross validation.
It is summarized as below.
FM denotes the ﬁnal model after recalibration that is used at test time.
1: Initialize K Models , M [1] , . . .
, M [ K ] 2: Get K Training data sets, TrainData [1] , . . . ,
TrainData [ K ] 3: Get K calibration data sets, CalibrationDataset [1] , . . .
, CalibrationDataset [ K ] 4: 5: for each i do 6:
M [ i ] =
TRAIN (cid:0) M[i],TrainData[i] (cid:1) 7:
R [ i ] =
GET ISO (cid:0) M[i], CalibrationDataset[i] (cid:1) 8: end for 9: FM =
K (cid:88) i =
R [ i ] ◦ M [ i ]
Heteroscedastic Drooput VI
Dataset
[Table]
Iso
Base with 5-fold
Iso with 5-fold
Air Foil
[Table]
.15 ±
[Table]
15.96 ±
[Table]
9.74 ± 0.
[Table]
93 ±
[Table]
05 Boston Housing
[Table]
35 ±
[Table] [Table]
80 ±
[Table] [Table]
45 ±
[Table] [Table]
69 ±
[Table]
54 Concrete Strength 25.78 ± 2.
34.41 ± 3.
22.68 ±
[Table]
26.09 ± 0.83 Fish Toxicity 3.23 ± 0.
1.39 ± 0.
3.83 ± 0.
1.45 ± 0.20 Red Wine 3.72 ± 0.
3.08 ± 0.
2.84 ± 0.
2.01 ± 0.15 White Wine 4.30 ± 0.
[Table]
[Table]
C. M ONOCULAR D EPTH E STIMATION
We scaled down the images to 115 × 153 .
We used batch size of 4 and learning rate of 5 e − 5 and trained it for 1500 epochs with adam optimizer with step decay of 4.
C.6. U SAGE OF P OOLING LAYERS
Instead of directly using Quantile Regularization as suggested in Alg.
[Table]
we added average pooling layer before computing entropy over cumulative density values.
This is justiﬁed in principle because average of CDF functions is again a valid CDF.
Note that this is serves two purposes.
It exploits locality for better uncertainty propagation
It reduces the computational resources for computing loss
C.6. P OST -H OC C ALIBRATION R ESULTS
[Table] [Table]
[Figure]
r
[Figure]
d i c t e d
[Figure]
[Figure] [Figure]
-DenseNet103 in Fig.
13b and QR represents FCDenseNet103 trained with Quantile Regularization.
Ideal line is y = x line which represents perfect calibration.
The More closer the curve to diagonal line the better.
D D ATASETS D IMENSION
We consider following datasets (size-of-data,num-input-features): AirFoil (1503,6) , Bouston Housing (506,13), Concrete Strength (1030,8),Fish Toxicity (908,7),Kin8nm (8192, 9), Protein Structure (45730, 10), Red Wine (1599, 12), White Wine (4898, 12), Yacht Hydrodynamics (308,6), year prediction MSD (515345,91)
[Figure]
p r
[Figure]
d i c t
[Figure]
[Figure] [Figure]
[Figure]
p r e d i c t e d
[Figure]