{'fraction_non_alphanumeric': 0.025914758373400702, 'fraction_numerical': 0.006763914921359302, 'mean_word_length': 4.931367810536491, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Evaluating Predictive Uncertainty and Robustness to Distributional Shift Using Real World Data

Most machine learning models operate under the assumption that the training, testing and deployment data is independent and identically distributed (i.i.d.). This assumption doesn't generally hold true in a natural setting. Usually, the deployment data is subject to various types of distributional shifts. The magnitude of a model's performance is proportional to this shift in the distribution of the dataset. Thus it becomes necessary to evaluate a model's uncertainty and robustness to distributional shifts to get a realistic estimate of its expected performance on real-world data. Present methods to evaluate uncertainty and model's robustness are lacking and often fail to paint the full picture. Moreover, most analysis so far has primarily focused on classification tasks. In this paper, we propose more insightful metrics for general regression tasks using the Shifts Weather Prediction Dataset. We also present an evaluation of the baseline methods using these metrics.


Introduction
Recent times have seen the growing deployment of machine learning models and deep neural networks in many mission-critical tasks such as medical image diagnosis [6], banking systems [2] and autonomous vehicles [15]. A prevalent assumption in machine learning is that the data the model sees after the development phase is independent and identically distributed (i.i.d). This implies that if a model performs well during the development phase it will be able to interpolate that performance to deployment. This however is seldom the case. Most data available to models in the real world is often out of the distribution of the data on which the models were trained and tested. When dealing with critical applications, the model's inability to generalize to the out of distribution deployment data can have disastrous consequences. Therefore, such tasks require not only for models to make accurate predictions but also a precise quantification of predictive uncertainty [1]. Thus, it is imperative to properly assess a model's robustness to distribution shift and its estimation of predictive uncertainty.
While the problem is apparent, yet there are limited resources and datasets that allow for proper evaluation of uncertainty estimates and robustness to distributional shift emulating real-world data. Most of the available datasets such as Imagenet -C [3], A [5], R [4], O [5] and WILDS [7] focus primarily on image classification tasks. The recently introduced Shifts Dataset [13] provides a favourable data setting. It is composed of three parts each corresponding to a different data modality: tabular weather prediction data, machine translation data and self-driving car data. All the data modalities are affected by distributional shift and pose challenges with respect to evaluating uncertainty predictions and robustness against distributional shift.
In this work, we present novel evaluation metrics for predictions on the tabular data related to weather prediction in the Shifts Dataset [13]. We introduce metrics for effectively evaluating both uncertainty predictions and robustness to distributional shift for regression tasks. We believe these metrics will be a much needed addition to the scarce pool of metrics available presently for regression tasks. In addition to this, we also validate the proposed metrics by evaluating the performance of baselines for predicting the temperature at a particular latitude/longitude and time, given all available measurements and climate model predictions. 2

Evaluation Metrics
We believe a model with lower degradation in performance on shifted data is more robust to distribution shift. The quality of predictive uncertainty is governed by the model's ability to discriminate between i.i.d. and out of distribution data. We present metrics for the joint evaluation of predictive uncertainty and robustness to distributional shift. We validate our proposed metrics using the baseline Gradient Boosted Decision Trees (GBDT) models as used in [13].
To build baseline gradient boosted decision trees for the temperature prediction regression task, the open-source CatBoost gradient boosting library [16] is used. Similar to Malinin et. al [13], we consider an ensemble-based approach to uncertainty estimation for GBDT models [17]. We use a pre-trained ensemble of ten models on the train data from the canonical partition of the Weather Prediction dataset with different random seeds. The models are optimized with the loss function RMSEWithUncertainty [17] which predicts mean and variance of the normal distribution by optimizing the negative log-likelihood. Hyperparameter tuning is performed on the in-domain development data. Each model is constructed with a depth of 8 and is then trained for 20,000 iterations with a learning rate of 0.3.

RMSE/RMV Ratio
The root mean squared error (RMSE) and the root mean variance (RMV) can be viewed as indicators of the model accuracy and uncertainty respectively.
where σ 2 b is the variance, |B| is the bin size and y b −ŷ b is the error between the model's prediction and the ground truth value for example b B. The ratio of the two should be as close to one as possible. We reason this inference by considering the following paradigm: If the error (RMSE) for a prediction is high then the model's uncertainty (RMV) about that prediction should also be high.
When plotting the retention curve [12][9] for the RMSE/RMV ratio, an ideal scenario would be a horizontal line close to one. This would indicate that RMSE is roughly equal to RMV. Figure 1(a) shows the RMSE/RMV retention curves (R3-curves) for single and ensemble models. The ensemble model clearly displays a more linear relationship between RMSE and RMV compared to the single model. The RMSE/RMV ratio is also much closer to one for the ensemble model compared to the single model.

Logarithmic Expected Normalized Calibration Error (LENCE)
Levi et al. [10] propose a definition for calibration for regression by replacing mis-classification probability with mean squared error. This is called Expected Normalized Calibration Error (ENCE).  This is an improvement over the existing definition of calibrated regression uncertainty [8]. To calculate ENCE we arrange the data in increasing order of variance. Then we create bins of size S such that S divides the total number of examples into N bins. Each resulting bin represents an interval in the standard deviation axis. These intervals are non-overlapping and their boundary values are in increasing order [10]. This measure is now analogous to the Expected Calibration Error (ECE) [14] used in the case of classification problems. For finding the error in calibration of the model, we use the following formulation for ENCE: where N is the total number of bins. A shortcoming of ENCE is that if the model were to predict a homogeneous uncertainty for each example and that happened to match the model's empirical uncertainty for the entire population then ENCE would be zero. However, it would not be a correct evaluation of the models uncertainty or generalization ability. Levi et. al [10] propose using the Variation Coefficient of Standard Deviation, C v as a secondary diagnostic tool with ENCE.
where µ σ = 1 T T t=1 σ t and T is the number of training examples. Evaluating two separate metrics and drawing relative inferences is complex and hence we propose the Logarithmic ENCE (LENCE). We incorporate C v as a measure of dispersion of the uncertainty predictions by the model and ENCE as a measure of the calibration error into a single evaluation metric. We define LENCE as: Ideally, the uncertainty values will be well dispersed and C v would be high. Then LENCE will approximately be log|EN CE|. In the absolute worst case when EN CE = 0 and C v → 0; LEN CE → ∞. ENCE, C v and LENCE values for single and ensemble models are presented in Table 1. A lower LENCE value for the ensemble model indicates its superiority.

LL-Fisher Uncertainty (LL-FU)
We introduce the LL-Fisher metric as a joint measure of uncertainty and robustness to distributional shift. The LL-Fisher metric measures the localisation of a probability distribution function [18]. This  metric can be used to evaluate how well a prediction represents the distribution of data that the model used to make the prediction itself. Inspired by log-loss used for calculating Fisher Information [11] for a prediction x with mean µ and variance σ 2 following a continuous distribution.
We propose the LL-Fisher Uncertainty as follows: We plot the F1-retention curve Figure 2(b), the MSE-retention curve Figure 2(c) and calculate the summary statistics: F1-AUC and R-AUC for the evaluation of our metric. We use F1@95 score to jointly evaluate uncertainty and robustness. A good uncertainty measure should achieve low R-AUC, high F1-AUC and high F1@95 scores [13]. We calculated these metrics for various uncertainty measures of prediction using a GBDT model as well as an ensemble of these models.
Results using ensemble and single models for various uncertainty measures are depicted in Table 2 and Table 3 showing superiority of our uncertainty measure. We compare both scores for ensemble and single model for LLFU. The scores for ensemble are better than the single model indicating the superiority of the ensembling approach. These results are presented in Table 4 . We observe that for out of distribution data, as the error of prediction increases, the lower bound of uncertainty (LL-FU) also increases. This validates the idea that with increasing shift in data distribution, not only does the likelihood of an error increase but so does the uncertainty corresponding to the prediction. We believe that LL-FU is unique in capturing this property when compared to other uncertainty metrics [13] as reflected in Figure 2(a).

Mean Weighted Squared Error (MWSE)
Intuitively, a model should be increasingly uncertain about it's prediction as the magnitude of distributional shift increases and hence will make more erroneous decisions. The error-retention curves [12] [9] do not directly evaluate the uncertainty estimates of the model and only take into account the correlation between error and uncertainty estimates. To more resiliently evaluate robustness and also take into account the magnitude of estimated uncertainty, we introduce MWSE. We propose MWSE as a secondary metric only to gain more insight into the models' behaviour by analysing their relative divergence.
whereŷ i and y is the predicted and true value respectively and UNC is model's uncertainty estimate for each prediction.
Ideally datapoints with low MSE should have low uncertainty and those with high MSE should have high uncertainty which would mean their product would be very low or very high respectively. In Figure 1(c) the ensemble diverges more than the single model. As the retention fraction increases, the ensemble shows a greater divergence from the single model. From this observation we infer that the ensemble is comparatively more responsive to distributional shift than the single model. MWSE assesses the sensitivity of a model to distribution shift by using error and uncertainty in conjunction with one another. The MWSE-retention curve when studied in tandem with the MSE-retention curve gives more insight into the quality of estimated uncertainty.

Conclusion and Future Work
This work presents three primary metrics (RMSE/RMV ratio, LENCE and LL-FU) to quantify and evaluate predictive uncertainty under dataset shift. We used the Shifts Weather Prediction Dataset [13] for validation of the proposed metrics. Through these metrics we aimed to jointly evaluate predictive uncertainty and robustness of a model and its performance under dataset shift. While we focused only on regression tasks, we believe there is potential for these metrics to be extrapolated to classification as well as machine translation tasks. Another avenue of future research can be to incorporate the memory and computational efficiency of different methods into the evaluation metrics. We hope our work helps the community and inspires further research on evaluation metrics for shifted multi-modal data.