arXiv:2611.09120cs.CVNov 2026

Manuscript Offprint

arXiv:2611.09120

Finite-sample Calibration Guarantees for Binary Segmentation

Bruno Viti, Martin Holler

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Machine learning-based segmentation models are frequently miscalibrated, producing for each pixel a label prediction whose associated confidence does not accurately reflect the true underlying probability. This limitation is particularly critical in high-stakes applications such as medical image segmentation. Although several calibration methods have been proposed, only a small subset of them provides theoretical guarantees on the calibration error, i.e., they do not typically ensure that, with high probability, the model exhibits a low calibration error. In this work, we develop a post-hoc calibration method for which formal calibration guarantees can be established. To achieve this, we derive from standard concentration inequalities an improved theoretical bound that explicitly accounts for the spatial dependence inherent in binary segmentation outputs. We empirically demonstrate that the proposed calibrator satisfies the derived guarantee and outperforms existing post-hoc calibration approaches.

1 Introduction

The calibration of a segmentation model is a fundamental task in machine learning that needs to be addressed in order to align the predicted confidence of a model with the true reliability of its prediction. It is essential to obtain reliable models for real-world applications. In the context of deep learning, the confidence of a model refers to the probability it assigns to its predicted output. Ideally, this confidence should faithfully reflect the true likelihood of correctness. However, modern neural networks tend to be overconfident, which means that their predicted confidence scores are poorly aligned with the actual accuracy (Guo et al., 2017; Ovadia et al., 2019). This misalignment becomes particularly crucial in critical-domain applications such as medical image segmentation, where erroneous predictions can have severe consequences. In such settings, a miscalibrated model may assign high confidence to incorrect segmentations, leading practitioners to place unwarranted trust in flawed outputs. In contrast, a well-calibrated model ensures that a predicted confidence of, say, 90% corresponds in the long run to a true correctness rate of approximately 90% (Dawid, 1982).

The calibration problem has been extensively studied, and existing approaches can broadly be categorized into three groups (Wang et al., 2023). Post-hoc calibration methods operate after training, adjusting the model's output probabilities without modifying its parameters. Classical techniques include Platt scaling (Platt et al., 1999), Temperature Scaling (Guo et al., 2017), Dirichlet calibration (Kull et al., 2019), Histogram Binning (Zadrozny & Elkan, 2001), Meta-cal (Ma & Blaschko, 2021), and Isotonic Regression (Zadrozny & Elkan, 2002). Although originally introduced for classification, these methods can be applied to segmentation by treating each pixel independently. Moreover, there are also spatially aware extensions, such as (Ding et al., 2021; Rousseau et al., 2025; Küppers et al., 2022). The second group, Train-time calibration, has also been widely explored. Mixup (Zhang et al., 2018), CutMix (Yun et al., 2019), and label smoothing (Szegedy et al., 2016; Müller et al., 2019) regularize confidence by exposing the model to soft

*MH is also a member of NAWI Graz www.navigraz.at and BioTechMed Graz https://biotechmedgraz.at/de/ or interpolated targets. This group also includes methods that modify the training loss to penalize miscalibration: representative examples in the classification setting include Focal Loss (Lin et al., 2017), FLSD (Mukhoti et al., 2020), MMCE (Kumar et al., 2018), and DECE (Bohdal et al., 2023), all of which encourage the model to reduce overconfidence while preserving discriminative performance. Several approaches have also been developed specifically for segmentation tasks, such as MDCA (Hebbalaguppe et al., 2022), as well as methods tailored to the medical imaging domain (Barfoot et al., 2024; 2026; Murugesan et al., 2025; 2023). The third group of calibration approaches are uncertainty estimation methods, which includes Monte Carlo dropout techniques (Gal & Ghahramani, 2016; Kendall & Gal, 2017) and Deep Ensemble Networks (Lakshminarayanan et al., 2017; Mehrtash et al., 2020). However, these methods, rather than recalibrating the model, primarily identify and highlight regions of high uncertainty.

In contrast to the works mentioned so far, which are purely empirical, methods that use calibration data to equip a pre-trained machine learning model with theoretical guarantees have seen a strong interest in the past years. Rooted in the work of Vovk et al. (2005), several works leverage statistical learning theory, and in particular conformal prediction, to provide coverage guarantees for segmentation models (Brunekreef et al., 2024; Mossina & Friedrich, 2025; Viti et al., 2026; Bereska et al., 2025; Teng et al., 2023; Liu et al., 2025). An interesting connection between conformal prediction and confidence calibration is developed by Xi et al. (2025). The authors first show that standard calibration approaches fail to improve conformal prediction, then propose a tailored calibration method designed to enhance prediction set efficiency. These works, however, focus primarily on constructing reliable prediction sets, rather than recalibrating pre-trained models with provable guarantees on the calibration error itself.

A notable exception is the work of Gupta et al. (2020); Gupta & Ramdas (2021), which endows histogram-binning calibration with finite-sample statistical guarantees for classification tasks. Following their notation, let the feature and label space be X\mathcal{X} and Y={0,1}\mathcal{Y} = \{0,1\}. We have at our disposal a pre-trained predictor f:X→[0,1]f: \mathcal{X} \to [0,1], where f(X)f(X) is the (uncalibrated) predicted probability that Y=1Y=1, and a calibration dataset Dcal={(X(i),Y(i))}i=1Ncal\mathcal{D}_{cal} = \{(X^{(i)}, Y^{(i)})\}_{i=1}^{N_{cal}}. The pre-trained model ff belongs to the space of all measurable functions F\mathcal{F} from X→[0,1]\mathcal{X} \to [0,1]. We would like to construct a calibrator H:F×Dcal→FH: \mathcal{F} \times \mathcal{D}_{cal} \to \mathcal{F}, that recalibrates f∈Ff \in \mathcal{F} given the dataset Dcal\mathcal{D}_{cal}. We denote the calibrated predictor as h:=H(f,Dcal)h := H(f, \mathcal{D}_{cal}). A predictor is perfectly calibrated if E[Y∣h(X)]=h(X)\mathbb{E}[Y|h(X)] = h(X), which, in the binary case, corresponds to P(Y=1∣h(X))=h(X)\mathbb{P}(Y=1 \mid h(X)) = h(X). While the latter condition is impossible to guarantee in a finite-sample setting, we would like to have a guarantee on the calibration error using the following notions:

Definition 1.1. (Marginal calibration). Let ε>0\varepsilon > 0 and α∈[0,1]\alpha \in [0,1]. A calibrator HH is said to be (ε,α)(\varepsilon, \alpha)-marginally calibrated if for every predictor f∈Ff \in \mathcal{F} and distribution P\mathbb{P} over X×[0,1]\mathcal{X} \times [0,1]

P(∣E[Y∣h(X)]−h(X)∣≤ε)≥1−α.\mathbb{P}(|\mathbb{E}[Y\mid h(X)]-h(X)|\leq\varepsilon)\geq 1-\alpha.

Definition 1.2. (Conditional calibration). Let ε>0\varepsilon > 0 and α∈[0,1]\alpha \in [0,1]. A calibrator HH is said to be (ε,α)(\varepsilon, \alpha)-conditionally calibrated if for every predictor f∈Ff \in \mathcal{F} and distribution P\mathbb{P} over X×[0,1]\mathcal{X} \times [0,1]

P(∀r∈Range(h):∣E[Y∣h(X)=r]−r∣≤ε)≥1−α.\mathbb{P}(\forall r\in R a n g e(h):|\mathbb{E}[Y\mid h(X)=r]-r|\leq\varepsilon)\geq 1-\alpha.

The fundamental distinction between the two definitions is that in the marginal case the probability is taken over both XX and Dcal\mathcal{D}_{cal}, meaning that the probability holds only on average over h(X)h(X). Conditional calibration instead, which implies marginal, requires the bound to hold uniformly in rr.

The seminal work of Gupta et al. (2020); Gupta & Ramdas (2021) remains confined to the classification setting. Our contribution builds directly on this line of work and extends it beyond classification. To the best of our knowledge, no existing work provides marginal and conditional guarantees in the segmentation setting. One reason is that standard approaches require large amounts of independent and exchangeable calibration data — an assumption that breaks down in segmentation, where pixel-wise predictions within an image are spatially correlated. This paper fills this gap by leveraging concentration inequalities, specifically adapted to account for spatial pixel correlation in our setting, to derive calibration guarantees for segmentation models.

The main theoretical tool used in (Gupta et al., 2020; Gupta & Ramdas, 2021) to bound the calibration error is Hoeffding's inequality (Hoeffding, 1963), which provides concentration for sums of bounded i.i.d. random variables. In segmentation, however, the predictor outputs a probability for each pixel, and the spatial correlation between pixels violates the i.i.d. assumption, making such inequalities inapplicable. While extensions to the non-i.i.d. setting exist — including martingale-based results such as Azuma (1967) and Freedman (1975) inequalities, and concentration under β\beta-mixing conditions (Yu, 1994; Mohri & Rostamizadeh, 2010) — these do not capture the structured spatial dependencies inherent to segmentation outputs.

Image segmentation outputs can naturally be modeled as random fields: each pixel label depends not only on its own features but also on the label of its spatial neighbors, inducing dependencies across the output map that are well captured by random field models such as Markov Random Fields (Li, 2009; Zoltan & Josiane, 2012). Bounding the calibration error in this setting therefore requires concentration inequalities that explicitly account for such spatial dependencies. Early approaches to random fields relied on information-theoretic tools: Marton (1998; 2003) and Samson (2000) established concentration results for Φ\Phi-mixing processes using transportation and Pinsker inequalities, albeit restricted to exponential bounds. A significant step forward was achieved by Chazottes et al. (2007), who proposed a coupling-based framework for random fields indexed by Zd\mathbb{Z}^d that yields concentration inequalities depending on the strength of spatial dependence. A parallel martingale-based approach was developed in (Kontorovich & Ramanan, 2008), yielding concentration bounds for Markov and hidden Markov chains in terms of mixing coefficients. More recently, Garnier & Langhendries (2022) established a Hoeffding-type inequality specifically for non-causal random fields. Finally, Chazottes et al. (2026) provides sharp Gaussian concentration criteria for Gibbs measures and Markov random fields on Zd\mathbb{Z}^d.

Our contribution In this work, we address the problem of calibration for binary segmentation models. We first derive an improved concentration inequality tailored to variables exhibiting the structured spatial dependence of binary segmentation outputs. Building upon the framework of (Chazottes et al., 2007), we model the spatial relationship between pixels and obtain a tighter theoretical bound. We then apply the bound to the calibration setting: we construct a calibrator HH following the idea of Gupta & Ramdas (2021), and establish that the calibrator satisfies the theoretical guarantees provided by our bound. This result formally justifies its application in the segmentation setting. A key insight is that treating each individual pixel prediction as a data point vastly increases the effective size of the calibration set. As a result, our method achieves tight statistical guarantees with a comparably small number of calibration images — even with only 50 images — making it practical for real-world applications where calibration data is scarce. Beyond providing theoretical guarantees, we also show that the calibrator HH even practically outperforms other post-hoc calibration approaches that do not come with such guarantees.

The outline of the paper is the following: In Section 2 we derive the improved theoretical bound and in Section 3 we show how the bound can be exploited to obtain statistical guarantees for calibration errors in the segmentation setting. Finally, in Section 4 we show how to estimate the bound and in Section 5 we empirically show the validity of our approach.