Abstract
We introduce the Kernel Calibration Conditional Stein Discrepancy test (KCCSD test), a nonparametric, kernel-based test for assessing the calibration of probabilistic models with well-defined scores. In contrast to previous methods, our test avoids the need for possibly expensive expectation approximations while providing control over its type-I error. We achieve these improvements by using a new family of kernels for score-based probabilities that can be estimated without probability density samples, and by using a Conditional Goodness of Fit criterion for the KCCSD test's U-statistic. We demonstrate the properties of our test on various synthetic settings.
Introduction
A "calibrated" model is one whose predicted probabilities accurately reflect the true likelihood of outcomes. For instance, if a model predicts a 70% chance of rain, it should rain in exactly 70% of such instances. While testing calibration in simple classification is straightforward, it becomes significantly more challenging for continuous, multi-dimensional outputs.
Existing state-of-the-art methods, such as the Squared Kernel Calibration Error (SKCE), often require computing complex expectations over the model's distribution. For "unnormalized" models—where the density is known only up to a scaling factor—researchers must rely on expensive and potentially biased Markov Chain Monte Carlo (MCMC) sampling. This paper introduces the Kernel Calibration Conditional Stein Discrepancy (KCCSD) test, a mathematically rigorous and computationally efficient alternative that bypasses these limitations.
Methodology: The KCCSD Test
The KCCSD test reframes calibration as a Conditional Goodness-of-Fit (CGOF) problem. By employing the "Stein trick," the authors transform intractable integration problems into simpler differentiation tasks. The core innovation is the development of two new families of score-based kernels:
- Generalized Fisher Divergence (GFD) Kernel: This kernel compares models based on their score function (the gradient of the log-density). Since the gradient of a constant is zero, the unknown normalizing constant (partition function) vanishes.
- Kernelized GFD (KGFD) Kernel: A smoothed variant of the GFD that utilizes an integral operator to enhance performance in higher-dimensional spaces.
These kernels are used within a U-statistic estimator, allowing the test statistic to be evaluated using only the model's scores and validation data. A "wild bootstrap" method is then applied to determine the threshold for rejecting the null hypothesis (that the model is calibrated), ensuring tight control over Type-I errors.
Experimental Evaluation
The KCCSD test was evaluated using several synthetic benchmarks designed to simulate various model failures:
- Mean Gaussian Model (MGM): Tests for shifts in the distribution mean.
- Linear Gaussian Model (LGM): A standard regression-style setup.
- Heteroscedastic Gaussian Model (HGM): Evaluates if the model captures varying noise levels across the input space.
- Quadratic Gaussian Model (QGM): A non-linear setup testing kernel robustness.
These benchmarks allow for precise control over the "degree of miscalibration" ($\delta$), facilitating a rigorous assessment of test sensitivity.
Results and Discussion
A critical finding is the vulnerability of traditional MCMC-based tests. When using MCMC to approximate integrals in tests like SKCE, a poorly tuned sampler can introduce bias, leading the test to incorrectly reject perfectly calibrated models (inflated Type-I error). As shown in Figure 1, the rejection rate for SKCE variants only approaches the nominal level as the number of MCMC warm-up steps increases.
In contrast, the KCCSD test avoids this failure mode entirely by bypassing MCMC sampling. Experimental results demonstrate that KCCSD variants maintain a reliable Type-I error rate (around the target 5%) while achieving high power for miscalibrated models.
Key insights from the evaluation include:
- Score-Based Efficiency: KCCSD provides "first-class support" for complex models where only the score function is accessible, such as Energy-Based Models.
- Robustness: While traditional tests fail or slow down for unnormalized models, KCCSD remains fast and accurate.
- Theoretical Links: The authors establish a connection between the KGFD kernel and the Fokker-Planck equation, relating the metric to distributional evolution under diffusion.
Limitations and Future Work
Despite its advantages, the KCCSD test has some limitations. The GFD kernels require selecting a "base measure" ($\nu$), which can influence sensitivity. Additionally, like other score-based methods, it may struggle with distributions containing widely separated modes, as the score function provides little information about the relative weights of distant "islands" of probability.
Future research could explore using KCCSD as a regularizer during neural network training to maintain calibration dynamically. Its differentiability and computational efficiency make it a promising candidate for improving the reliability of modern machine learning models in real-time.
Summary updated