SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Shang Liu*
Imperial College Business School
s.liu21@imperial.ac.uk
Zhongze Cai*
z.cai22@imperial.ac.uk
Xiaocheng Li
xiaocheng.li@imperial.ac.uk
In this paper, we consider the uncertainty quantification problem for regression models. Specifically, we consider an individual calibration objective for characterizing the quantiles of the prediction model. While such an objective is well-motivated from downstream tasks such as newsvendor cost, the existing methods have been largely heuristic and lack of statistical guarantee in terms of individual calibration. We show via simple examples that the existing methods focusing on population-level calibration guarantees such as average calibration or sharpness can lead to harmful and unexpected results. We propose simple nonparametric calibration methods that are agnostic of the underlying prediction model and enjoy both computational efficiency and statistical consistency. Our approach enables a better understanding of the possibility of individual calibration, and we establish matching upper and lower bounds for the calibration error of our proposed methods. Technically, our analysis combines the nonparametric analysis with a covering number argument for parametric analysis, which advances the existing theoretical analyses in the literature of nonparametric density estimation and quantile bandit problems. Importantly, the nonparametric perspective sheds new theoretical insights into regression calibration in terms of the curse of dimensionality and reconciles the existing results on the impossibility of individual calibration. To our knowledge, we make the first effort to reach both individual calibration and finite-sample guarantee with minimal assumptions in terms of conformal prediction. Numerical experiments show the advantage of such a simple approach under various metrics, and also under covariates shift. We hope our work provides a simple benchmark and a starting point of theoretical ground for future research on regression calibration.
Modern machine learning methods have witnessed great success on a wide range of tasks in the past decade for their high accuracy in dealing with various kinds of complicated data. Uncertainty quantification has played an important role in the interpretation and risk assessment of machine learning models for downstream tasks such as optimization and decision-making. People observe
that the output of deep learning models tends to be over over-confident [Guo et al., 2017, Amodei et al., 2016], which inspires many recent works on uncertainty calibration for classification problems [Kumar et al., 2019, Wenger et al., 2020, Luo et al., 2022]. Comparatively, there has been less systematic theoretical understanding of the uncertainty calibration for regression problems. For a regression problem, the output of a prediction model can be the prediction of the conditional mean (by minimizing mean squared error) or of the conditional median (by minimizing mean absolute error). But such a single-point prediction cannot characterize the uncertainty, which motivates the development of uncertainty calibration methods for regression problems. Some efforts have been made in order to estimate the entire distribution, which includes Bayesian ways [MacKay, 1992, Damianou and Lawrence, 2013], the frequentists' ways [Kendall and Gal, 2017, Lakshminarayanan et al., 2017, Cui et al., 2020, Zhao et al., 2020], and the nonparametric ways [Lei and Wasserman, 2014, Lei et al., 2018, Bilodeau et al., 2021, Song et al., 2019]. Another easier task is to predict the quantiles rather than the whole distribution. Existing ways mainly focus on completing the task of quantile prediction in one go [Pearce et al., 2018, Thiagarajan et al., 2020, Chung et al., 2021, Takeuchi et al., 2006, Stainwart and Christmann, 2011]. However, all those methods suffer from either statistical inconsistency under model misspecification or computational intractability during the training phase, or sometimes even both (see the detailed review in Appendix A).
In this paper, we suggest that previous ways of training a new quantile prediction model from scratch while discarding the pre-trained (mean) regression model may not be the best way for a quantile calibration objective, because the pre-trained model (though designed for a mean estimation objective) can be helpful for the quantile calibration. We propose a simple, natural, but theoretically non-trivial method that divides the whole quantile calibration task into two steps: (i) train a good regression model and (ii) estimate the conditional quantiles of its prediction error. Although a similar idea is applied in split conformal prediction[Papadopoulos et al., 2002, Vovk et al., 2005, Lei et al., 2018], the theoretical justification is still in a lack since the conformal prediction only requires an average calibration guarantee (see Definition 1) that can also be achieved without this first training step at all (where the detailed review is given in Appendix A). By a careful analysis of the individual calibration objective (see Definition 3), we capture the intuition behind the two-step procedure and formalize it in a mathematical guarantee. After a comprehensive numerical experiment on real-world datasets against existing benchmark algorithms, we suggest that one neither needs to estimate the whole distribution nor to train a new quantile model from scratch, while a pre-trained regression model and a split-and-subtract suffice, both theoretically and empirically. Our contribution can be summarized below:
First, we propose a simple algorithm that can estimate all percent conditional quantiles simultaneously. We provide the individual consistency of our algorithm and prove the minimax optimal convergence rate with respect to the mean squared error (Theorem 1 and 2). Our analysis is new and it largely relaxes the assumptions in the existing literature on kernel density estimation and order statistics. By showing the necessity of the Lipschitz assumption (Theorem 6), our result uses minimal assumptions to reach both finite sample guarantee and individual calibration, and our paper is the first to keep the latter two goals simultaneously up to our knowledge.
Second, we propose a two-step procedure of estimating "mean + quantile of error" rather than directly estimating the conditional quantiles, which enables a faster convergence rate both theoretically and empirically. Specifically, our convergence rate is of order  $\tilde{O}\left(L^{\frac{2d}{d+2}}n^{-\frac{2}{d+2}}\right)$ , where  $L$  is the Lipschitz constant of the conditional quantile with respect to the features,  $n$  is the number of samples, and  $d$  is the dimension of feature. Since the conditional mean function and the conditional quantile function are highly correlated, one can greatly reduce the Lipschitz constant by subtracting the mean from the quantile.
Moreover, we construct several simple examples to show the unexpected behavior of the existing calibration methods, suggesting that a population-level criterion such as sharpness or MMD can be misleading. As our analysis works as a positive result on individual calibration, we also provide a detailed discussion about the existing results on the impossibility of individual calibration, illustrating that their definitions of individual calibration are either impractical or too conservative.
Consider the regression calibration problem for a given pre-trained model  $\hat{f}$ . We are given a dataset  $\{(X_i, Y_i)\}_{i=1}^n \in \mathcal{X} \times \mathcal{Y}$  independent of the original data that trains  $\hat{f}(x)$ . Here  $\mathcal{X} \in [0,1]^d \subset \mathbb{R}^d$  denotes the covariate/feature space and  $\mathcal{Y} \subset \mathbb{R}$  denotes the response/label space. The i.i.d. samples  $\{(X_i, Y_i)\}_{i=1}^n$  follow an unknown distribution  $\mathcal{P}$  on  $\mathcal{X} \times \mathcal{Y}$ . We aim to characterize the uncertainty of the regression error  $U_i := Y_i - \hat{f}(X_i)$  in a model agnostic manner, i.e., without any further restriction on the choice of the underlying prediction model  $\hat{f}$ .
Now we introduce several common notions of regression calibration considered in the literature. We first state all the definitions with respect to the error  $U_{i}$  and then establish equivalence with respect to the original  $Y_{i}$ . Define the  $\tau^{\text{th}}$  quantile of a random variable  $Z$  as  $Q_{\tau}(Z) \coloneqq \inf \{t : F(t) \geq \tau\}$  for any  $\tau \in [0,1]$  where  $F$  is the c.d.f. of  $Z$ . Accordingly, the quantile of the conditional distribution  $U|X = x$  is denoted by  $Q_{\tau}(U|X = x)$ . A quantile prediction/calibration model is denoted by  $\hat{Q}_{\tau}(x) : \mathcal{X} \to \mathbb{R}$  which gives the  $\tau$ -quantile prediction of  $U$  given  $X = x$ .
Definition 1 (Marginal/Average Calibration). The model  $\hat{Q}_{\tau}(x)$  is marginally calibrated if
$$
\mathbb {P} (U \leq \hat {Q} _ {\tau} (X)) = \tau
$$
for any  $\tau \in [0,1]$ . Here the probability distribution is with respect to the joint distribution of  $(U,X)$ .
As noted by existing works, the marginal calibration requirement is too weak to achieve the goal of uncertainty quantification. A predictor that always predicts the marginal quantile of  $U$  for any  $X = x$ , i.e.,  $\hat{Q}_{\tau}(x) \equiv Q_{\tau}(U)$ , is always marginally calibrated, but such a model does not capture the heteroscedasticity of the output variable  $Y$  or the error  $U$  with respect to  $X$ .
Definition 2 (Group Calibration). For some pre-specified partition  $\mathcal{X} = \mathcal{X}_1 \cup \dots \cup \mathcal{X}_K$ , the model  $\hat{Q}_{\tau}(x)$  is group calibrated if
$$
\mathbb {P} (U \leq \hat {Q} _ {\tau} (X) | X \in \mathcal {X} _ {k}) = \tau
$$
for any  $\tau \in [0,1]$  and  $k = 1,\dots,K$
Group calibration is a stronger notion of calibration than marginal calibrations. It is often considered in a related but different problem called conformal prediction [Vovk, 2012, Lei and Wasserman, 2014, Alaa et al., 2023] where the goal is to give a sharp covering set  $\hat{C}(X)$  (or covering band if unimodality is assumed) such that  $\mathbb{P}(Y \in \hat{C}(X) | X \in \mathcal{X}_k) \geq 1 - \alpha, \forall k$ . Foygel Barber et al. [2021] consider the case where the guarantee is made for all  $\mathbb{P}(X \in \mathcal{X}_k) \geq \delta$  for some  $\delta > 0$ .
Definition 3 (Individual Calibration). The model  $\hat{Q}_{\tau}(x)$  is individually calibrated if
$$
\mathbb {P} (U \leq \hat {Q} _ {\tau} (X) | X = x) = \tau
$$
for any  $\tau \in [0,1]$  and  $x\in \mathcal{X}$ . Here the probability distribution is with respect to the conditional distribution  $U|X$ .
In this paper, we consider the criteria of individual calibration, an even stronger notion of calibration than the previous two. It requires the calibration condition to hold with respect to any  $x \in \mathcal{X}$  in a pointwise manner. The difference between the conformal prediction problem with group calibration and the regression calibration problem with individual calibration is that conformal prediction does not make any assumptions on the data distribution, while our lower bound result of Theorem 6 suggests that without any assumption, the convergence rate of the conditional quantile estimator can be arbitrarily slow. The conformal prediction literature considers a weaker notion of calibration than the individual calibration setting considered in this paper where some mild assumptions are made.
Finally, the following proposition says that any quantile prediction model on the error  $U$  is equivalent to a corresponding quantile prediction on  $Y$ . The result is stated for the individual calibration, while a similar statement can be made for marginal calibration and group calibration as well.
Proposition 1. For any predictor  $\hat{Q}_{\tau}(x)$  on the  $\tau^{-th}$  quantile of  $U|X = x$ , we have
$$
\mathbb {P} \left(Y \leq \hat {f} (X) + \hat {Q} _ {\tau} (X) | X = x\right) = \mathbb {P} \left(U \leq \hat {Q} _ {\tau} (X) | X = x\right).
$$
Figure 1: Synthetic data where the underlying distribution is obtained by a combination of sine functions. The solid lines denote predicted means, the shaded area denotes predicted intervals between  $97.5\%$  and  $2.5\%$  quantiles, and the yellow dots denote a subset of real observations. The leftmost plot gives the real mean as well as oracle quantile values, while the rest two plots are predictions from different calibration models. The middle plot is produced by a Deep Ensemble [Lakshminarayanan et al., 2017] of 5 HNNs trained with 40,000 samples, which is both a common benchmark and a building block for several regression calibration methods. The rightmost plot is produced by our proposed nonparametric calibration method – Algorithm 2 NRC of which the base regression model is an ordinary feed-forward regression network. The detailed setup is given in Appendix E.2.
2.1 Motivating examples
In addition to the above calibration objective, existing literature also considers sharpness (the average length of confidence intervals [Zhao et al., 2020, Chung et al., 2021]) and maximum mean discrepancy (MMD) principle [Cui et al., 2020]. To the best of our knowledge, all the existing works consider population-level objectives such as marginal calibration, sharpness, and MMD when training the calibration model, while we are the first work that directly aims for individual calibration. Here we use a simple example to illustrate that such population-level objectives may lead to undesirable calibration results, and in Appendix B, we elaborate with more examples on the inappropriateness of existing methods for regression calibration.
Example 1. Consider  $X \sim \mathrm{Unif}[0,1]$  and the conditional distribution  $Y|X = x \sim \mathrm{Unif}[0,x]$ . Then if one aims for  $\tau = 90\%$ , the outcome from sharpness maximization subject to marginal calibration is to  $\hat{Q}_{\tau}(x) = x$  for  $x \in [0,0.9]$  and  $\hat{Q}_{\tau}(x) = 0$  for  $x \in (0.9,1]$ . Consequently, the quantile prediction has a  $100\%$  coverage over  $x \in [0,0.9]$  but  $0\%$  coverage over  $x \in (0.9,1]$ .
Generally, the population-level criteria such as sharpness or MMD may serve as performance metrics to monitor the quality of a calibration outcome. However, the inclusion of such criteria in the objective function will encourage the calibration result to be over-conservative for the low variance region  $(x\in [0,0.9])$  while giving up the high variance  $(x\in (0.9,1])$ , which is highly undesirable for risk-sensitive applications and/or fairness considerations.
Besides, individual calibration is sometimes also necessitated by the downstream application. For example, in some decision-making problems, regression calibration serves as a downstream task where loss is measured by the pinball loss; say, the newsvendor problem [Kuleshov et al., 2018, Ban and Rudin, 2019] in economics and operations research uses pinball loss to trade-off the backorder cost and the inventory cost.
Proposition 2. The pinball loss with respect to  $\tau$  is defined by
$$
l _ {\tau} \left(u _ {1}, u _ {2}\right) := (1 - \tau) \left(u _ {1} - u _ {2}\right) \cdot \mathbb {1} \left\{u _ {1} > u _ {2} \right\} + \tau \left(u _ {2} - u _ {1}\right) \cdot \mathbb {1} \left\{u _ {1} <   u _ {2} \right\}.
$$
$$
Q_{\tau}(Y|X = x) = \hat{f} (x) + Q_{\tau}(U|X = x)\in \operatorname *{arg  min}_{y\in \mathbb{R}}\mathbb{E}[l_{\tau}(y,Y)|X = x].
$$
Proposition 2 serves as the original justification of pinball loss for quantile regression. More importantly, it says that a calibration method that is inconsistent with respect to individual calibration can be substantially suboptimal for downstream tasks such as the newsvendor problem.
3.1 Generic nonparametric quantile estimator
In this subsection, we present and analyze a simple algorithm of a nonparametric quantile estimator, which can be of independent interest itself and will be used as a building block for the regression calibration. The algorithm takes the dataset  $\{(X_i,U_i)\}_{i = 1}^n$  as input and outputs a  $\tau$ -quantile estimation of the conditional distribution  $U|X = x$  for any  $\tau$  and  $x$ .
Algorithm 1 Simple Nonparametric Quantile Estimator
Input:  $\tau \in (0,1)$ , dataset  $\{(X_i,U_i)\}_{i = 1}^n$ , kernel choice  $\kappa_{h}(\cdot ,\cdot)$
1: Estimate the distribution of  $U|X = x$  by (where  $\delta_{u}$  is a point mass distribution at  $u$ )
$$
\hat {\mathcal {P}} _ {U | X = x} = \frac {\sum_ {i = 1} ^ {n} \kappa_ {h} (x , X _ {i}) \delta_ {U _ {i}}}{\sum_ {i = 1} ^ {n} \kappa_ {h} (x , X _ {i})}.
$$
2: Output the conditional  $\tau^{-\mathrm{th}}$  quantile by minimizing the pinball loss on  $\hat{\mathcal{P}}_{U|X = x}$
$$
\hat {Q} _ {\tau} ^ {\mathrm {S N Q}} (x) = \underset {u} {\arg \min } \mathbb {E} _ {U \sim \hat {\mathcal {P}} _ {U | X = x}} [ l _ {\tau} (u, U) ]. \tag {1}
$$
The minimum of the optimization problem in Algorithm 1 is indeed achieved by the  $\tau$ -quantile of the empirical distribution  $\hat{\mathcal{P}}_{U|X = x}$ . In the following, we analyze the theoretical properties of the algorithm under the naive kernel
$$
\kappa_ {h} (x _ {1}, x _ {2}) = \mathbb {1} \{\| x _ {1} - x _ {2} \| \leq h \}.
$$
where  $h$  is the hyper-parameter for window size, and  $\| x_{1} - x_{2}\|$  denotes Euclidean distance.
Assumption 1. We assume the following on the joint distribution  $(U,X)$  and  $\tau \in (0,1)$  of interest:
(a) (Lipschitzness). The conditional quantile function is  $L$ -Lipschitz with respect to  $x$ ,
$$
\left| Q _ {\tau} \left(U | X = x _ {1}\right) - Q _ {\tau} \left(U | X = x _ {2}\right) \right| \leq L \| x _ {1} - x _ {2} \|, \quad \forall x _ {1}, x _ {2} \in \mathcal {X}.
$$
(b) (Boundedness). The quantile  $Q_{\tau}(U|X = x)$  is bounded within  $[-M, M]$  for all  $x \in \mathcal{X}$ .
(c) (Density). There exists a density function  $p_x(u)$  for the conditional probability distribution  $U|X = x$ , and the density function is uniformly bounded away from zero in a neighborhood of the interested quantile. That is, there exist constants  $\underline{p}$  and  $\underline{r}$ ,
$$
p _ {x} (u) \geq \underline {{p}}, \quad \forall x \in \mathcal {X} a n d | u - Q _ {\tau} (U | X = x) | \leq \underline {{r}}.
$$
In Assumption 1, part (a) and part (b) impose Lipschitzness and boundedness for the conditional quantile, respectively. Part (c) requires the existence of a density function and a lower bound for the density function around the quantile of interest. Its aim is to ensure a locally strong convexity for the expected risk  $\mathbb{E}_{U\sim \mathcal{P}_{U|X = x}}[l_{\tau}(u,U)]$ . Under Assumption 1, we establish consistency and convergence rate for Algorithm 1.
Theorem 1. Under Assumption 1, Algorithm 1 is statistically consistent, i.e., for any  $\epsilon >0$
$$
\lim  _ {n \to \infty} \mathbb {P} \left(\left| \hat {Q} _ {\tau} ^ {S N Q} (X) - Q _ {\tau} (U | X) \right| \geq \epsilon\right) = 0.
$$
Furthermore, by choosing  $h = \Theta \left( L^{\frac{2}{d + 2}} n^{-\frac{1}{d + 2}} \right)$ , we have for sufficiently large  $n \geq C$ , when  $L > 0$ ,
$$
\mathbb {E} \left[ \left| \hat {Q} _ {\tau} ^ {S N Q} (X) - Q _ {\tau} (U | X) \right| ^ {2} \right] \leq C ^ {\prime} L ^ {\frac {2 d}{d + 2}} n ^ {- \frac {2}{d + 2}},
$$
where  $C$  and  $C'$  depends polynomially on  $\frac{1}{p}, \frac{1}{r}, M,$  and  $\log(n)$ . In addition, when  $L = 0$ , the right-hand-side becomes  $\tilde{O}\left(\frac{1}{n}\right)$ .
While Algorithm 1 seems to be a natural algorithm for nonparametric quantile regression, Theorem 1 provides the first convergence rate for such a nonparametric quantile estimator, to the best of our knowledge, in the literature of nonparametric regression; also, it is the first theoretical guarantee towards individual calibration for regression calibration. The standard analysis of nonparametric mean estimation [Györfi et al., 2002] cannot be applied here directly because the algorithm involves a local optimization (1). Even more challenging, the optimization problem (1) aims to optimize the quantile of the conditional distribution  $U|X = x$  but the samples used in (1) are from distributions  $U|X = x_{i}$ , which causes a non-i.i.d. issue. To resolve these issues, we combine the idea of bias and variance decomposition in nonparametric analysis with a covering concentration argument for the local optimization problem. The detailed proof is deferred to Appendix H.
Theorem 1 also complements the existing results on finite-sample analysis for quantile estimators. One line of literature [Szorenyi et al., 2015, Altschuler et al., 2019] establishes the quantile convergence from the convergence of empirical processes, and this requires additional assumptions on the density function and does not permit the non-i.i.d. structure here. The quantile bandits problem also entails the convergence analysis of quantile estimators; for example, Zhang and Ong [2021] utilize the analysis of order statistics [Boucheron and Thomas, 2012], and the analysis inevitably requires a non-decreasing hazard rate for the underlying distribution. Other works [Bilodeau et al., 2021] that follow the kernel density estimation approach require even stronger conditions such as realizability. We refer to Appendix D for more detailed discussions. In comparison to these existing analyses, our analysis is new, and it only requires a minimal set of assumptions. The necessity of the assumptions can be justified from the following lower bound.
Theorem 2 rephrases the lower bound result in the nonparametric (mean) regression literature [Györfi et al., 2002] for the quantile estimation problem. It states that the convergence rate in Theorem 1 is minimax optimal (up to poly-logarithmic terms). It is easy to verify that the class  $\mathcal{P}^L$  satisfies Assumption 1. In this light, Theorem 1 and Theorem 2 establish the criticalness of Assumption 1. Furthermore, in Theorem 6 in Appendix C, we establish that the convergence rate of any estimator can be arbitrarily slow without any Lipschitzness assumption on the conditional statistics.
Theorem 2. Let  $\mathcal{P}^L$  be the class of distributions of  $(X,U)$  such that  $X\sim \mathrm{Uniform}[0,1]^d$ ,  $U = \mu(X) + N$ , and  $\mu(x)$  is  $L$ -Lipschitz where  $N$  is an independent standard Gaussian random variable. For any algorithm, there exists a distribution in the class  $\mathcal{P}^L$  such that the convergence rate of the algorithm is  $\Omega(L^{\frac{2d}{d+2}}n^{-\frac{2}{d+2}})$ .
Our result here provides a guarantee for the estimation of  $Q_{\tau}(U|X)$  and thus a positive result for individual calibration with respect to a specific  $\tau$ . We note that the result does not contradict the negative results on individual calibration [Zhao et al., 2020, Lei and Wasserman, 2014]. Zhao et al. [2020] measure the quality of individual calibration via the closeness of the distribution  $\hat{F}_X(Y)$  to the uniform distribution. In fact, such a measurement is only meaningful for a continuous distribution of  $Y|X$ , but they prove the impossibility result based on a discrete distribution of  $Y|X$ . So, their negative result on individual calibration does not exclude the possibility of individual calibration for a continuous  $Y|X$ . Lei and Wasserman [2014] require an almost surely guarantee based on finite observations and prove an impossibility result. This is a very strong criterion; our results in Theorem 1 are established for two weaker but more practical settings: either the strong consistency in the asymptotic case as  $n \to \infty$  or a mean squared error guarantee under finite-sample. We defer more discussions to Appendix C.
3.2 Regression calibration
Now we return to regression calibration and build a calibrated model from scratch. Specifically, Algorithm 2 splits the data into two parts; it uses the first part to train a prediction model and the second part to calibrate the model with Algorithm 1. The first part can be skipped if there is already a well-trained model  $\hat{f}$  where it becomes a recalibration problem.