Source-linked AI summary
On Calibration and Out-of-domain Generalization
Yoav Wald, Amir Feder, Daniel Greenfeld, Uri Shalit
TL;DR
OOD generalization remains difficult because models can rely on correlations that fail in unseen domains. This paper connects multi-domain calibration to invariant representations, proves the connection under linear-Gaussian conditions, and introduces practical calibration methods. Across WILDS and Colored MNIST experiments, tuning models for multi-domain calibration improves unseen-domain performance, while the theory remains limited in scope.
Problem
Models trained on in-domain data can fail on unseen domains, motivating methods that avoid spurious correlations and learn invariant representations.
Method
The paper treats multi-domain calibration as a measurable surrogate for OOD performance and develops model selection, post-processing, and calibration-objective methods.
Results
Theoretical and empirical results show that multi-domain calibration removes spurious correlations under stated conditions and improves performance on unseen domains across WILDS and Colored MNIST.
Takeaways & Limitations
Multi-domain calibration can serve as a practical criterion for tuning or selecting classifiers intended to generalize beyond their training domains.
Takeaways & Limitations
The theoretical findings are limited to linear models in a population setting, so they motivate rather than fully justify practical use of multi-domain calibration.
Abstract
from arXiv · showhide
Out-of-domain (OOD) generalization is a significant challenge for machine learning models. Many techniques have been proposed to overcome this challenge, often focused on learning models with certain invariance properties. In this work, we draw a link between OOD performance and model calibration, arguing that calibration across multiple domains can be viewed as a special case of an invariant representation leading to better OOD generalization. Specifically, we show that under certain conditions, models which achieve \emph{multi-domain calibration} are provably free of spurious correlations. This leads us to propose multi-domain calibration as a measurable and trainable surrogate for the OOD performance of a classifier. We therefore introduce methods that are easy to apply and allow practitioners to improve multi-domain calibration by training or modifying an existing model, leading to better performance on unseen domains. Using four datasets from the recently proposed WILDS OOD benchmark, as well as the Colored MNIST dataset, we demonstrate that training or tuning models so they are calibrated across multiple domains leads to significantly improved performance on unseen test domains. We believe this intriguing connection between calibration and OOD generalization is promising from both a practical and theoretical point of view.
1 Introduction
OOD generalization is difficult because models trained on in-domain data can fail under unobserved conditions. The paper proposes multi-domain calibration as an observable route toward invariant representations and better unseen-domain performance.
- Motivation: Models often fail on out-of-domain data despite strong in-domain performance, creating deployment risks in settings such as hospitals.The paper highlights medical diagnosis across hospitals as a motivating example.
- Motivation: Existing approaches seek invariance and robustness to spurious correlations, but have had limited success on realistic high-dimensional data.
- Core idea: Multi-domain calibration is proposed as an observable indicator of favorable performance on unseen domains.Calibration requires predicted probabilities to match true probabilities across domains.
- Contributions: The paper proves that, under Gaussian-linear and general-position conditions, concurrent calibration across enough domains eliminates spurious correlations.
- Contributions: Three practical approaches target multi-domain calibration: model selection, robust isotonic regression, and direct optimization of deep networks.
- Contributions: Experiments on WILDS datasets and Colored MNIST report improved performance on unseen test domains after models are trained or tuned for multi-domain calibration.
2 Calibration and Invariant Classifiers
The paper frames OOD learning as finding predictions stable across environments and connects this goal to calibration across multiple domains. It argues that calibrated predictions correspond to invariant classifiers, while calibration alone must be balanced with accuracy.
- Problem setting: Because training covers only a finite set of environments, the goal is to learn classifiers whose per-instance outputs remain stable across unseen environments.
- Problem setting: The causal setup distinguishes causal features from anti-causal features that are either environment-dependent spurious variables or invariant variables.
- Problem setting: A representation contains a spurious correlation when the label remains dependent on the environment after conditioning on that representation.
- Calibration: Multi-domain calibration requires predicted probabilities to equal conditional outcome probabilities within every training environment.
- Invariance: An invariant classifier has the same conditional label expectation at each prediction value across training environments.
- Invariance and calibration: If a classifier is calibrated across all training environments, it is invariant; conversely, an invariant classifier can be recalibrated without increasing mean squared error.
- Calibration and sharpness: Calibration alone does not ensure accuracy, so the proposed CLOvE regularizer combines multi-domain calibration with standard empirical losses to preserve sharpness.
3 Motivation: a Linear-Gaussian Model
The theoretical analysis uses linear-Gaussian environments to study when multi-domain calibration removes spurious features. Under sufficient domain diversity and mild conditions, calibrated predictors recover invariant relationships and generalize across environments.
- Linear-Gaussian setup: The analysis parameterizes environments by Gaussian feature means and positive-definite covariance matrices.
- Main theoretical result: Across two theoretical scenarios, calibration over a number of environments linear in the feature count removes spurious features and generalizes calibration to all environments.
- Scenario (a): In scenario (a), invariant and spurious anti-causal features differ because only the spurious features can change their conditional distribution across environments.
- Scenario (a): A linear classifier using spurious features can suffer arbitrarily high loss in an unseen environment because correlations may reverse and intensify.
- Scenario (a): With k > 2d_sp training environments in general position, calibration forces the coefficients of spurious features to zero.
- Conclusion: Together, the results show that multi-domain calibration can imply avoidance of spurious correlations and cross-environment calibration under the stated conditions.
- Scenario (b): With causal covariate shift, calibrated linear regression uses the invariant causal mechanism and discards spurious anti-causal features.
4 Related Work
Prior OOD work largely seeks invariant representations, but many methods struggle to recover invariant relations on realistic high-dimensional data. This paper positions multi-domain calibration as a simpler, measurable form of invariance, especially for proactive settings without target-domain samples.
- OOD research often targets invariant models that avoid spurious correlations under distribution shifts.
- Many invariance-based approaches still struggle to find invariant relations in important cases.The cited work also highlights the difficulty of model selection for OOD generalization.
- Proactive OOD generalization addresses deployment when no target-domain samples are available.
- Calibration is also studied for uncertainty estimation, subgroup fairness, and multi-calibration, creating connections to domain generalization.
5 Proactively Achieving Multi-Domain Calibration
The paper proposes evaluating and improving OOD-oriented models through multi-domain calibration, using model selection, post-processing, or direct calibration-aware training. Its CLOvE objective aggregates calibration errors across environments, with zero loss characterizing perfect calibration on every training domain.
- Three practical approaches target multi-domain calibration: model selection, post-processing calibration, and direct calibration-objective training.The approaches range from easy-to-apply procedures to a more powerful training objective.
- The paper evaluates calibration with Expected Calibration Error, defined as the average deviation between model accuracy and confidence.
- Model selection should balance ID validation error with a calibration-based surrogate for stability across distribution shifts.Selecting solely by ID error can remove the advantage of domain-generalization methods when ID and OOD accuracy conflict.
- 5.2 Post-Processing Calibration: Robust calibration extends isotonic regression to control worst-case miscalibration across individual training environments.Naive calibration pools validation data and may be calibrated overall while remaining miscalibrated within particular environments.
- 5.3 Learning with Multi-Domain Calibration Error: CLOvE aggregates MMCE across training domains as a regularizer for directly optimizing multi-domain calibration.MMCE uses universal kernels to express calibration error as an integral probability measure.
- 5.3 Learning with Multi-Domain Calibration Error: CLOvE equals zero if and only if the classifier is perfectly calibrated on every training domain.This follows from its status as a proper scoring rule and the correspondence between MMCE and perfect calibration.
6 Experiments and Results
Experiments on Colored MNIST and WILDS evaluate calibration-based model selection, post-processing, and training for improving out-of-domain performance. Across the reported settings, calibration—especially CLOvE—improves OOD accuracy or stability, although gains vary by dataset and task.
- Colored MNIST and Two-Bit Environments: On Colored MNIST, IRMv1 can select a domain-invariant-looking solution that retains a spurious correlation, whereas CLOvE retrieves the optimal invariant classifier.The IRMv1-selected solution has the lowest training empirical loss but higher loss on the test environment; CLOvE discards the spurious feature in this setting.
- Colored MNIST and Two-Bit Environments: Average ECE over training environments is proposed for model selection because ID ECE shows a stronger correlation with OOD accuracy than ID IRMv1.The reported Pearson correlations are -0.92 for ID ECE and -0.59 for ID IRMv1.
- WILDS Benchmarks: On FMoW and Camelyon17, CLOvE improves performance over the strongest alternative by 7% and 2.8% absolute, respectively.Compared with the original model, CLOvE improves performance by more than 10% on FMoW and 6% on Camelyon17.
- WILDS Benchmarks: Figure 4 associates improved ID calibration with better OOD performance on Camelyon17, while post-processing is generally less effective than directly optimizing multi-domain calibration.When post-processing does not improve OOD performance, the experiments often also fail to substantially improve ID calibration.
- WILDS Benchmarks: On CivilComments, calibration improves worst-case performance by an average of 21.5% across training algorithms, while CLOvE’s gain is smaller than on FMoW and Camelyon17.The reported CivilComments result concerns average group accuracy on the test set.
- WILDS Benchmarks: In PovertyMap, robust calibration improves OOD performance across experiments but CLOvE cannot be used because the task is regression; calibration also produces more stable results.For models pretrained by IRM, robust calibration improves OOD performance by 0.08% absolute over the original model.
7 Conclusion
The paper connects multi-domain calibration with invariant representations and OOD generalization, combining theoretical guarantees with practical calibration methods. It concludes that calibration can serve as a measurable surrogate for unseen-domain performance, while acknowledging that the theory remains limited in scope.
- Multi-domain calibration is presented as an invariant representation linked to improved OOD generalization.
- In linear settings, models calibrated across multiple domains are free of spurious correlations and generalize out of domain.
- The paper proposes multi-domain calibration as a practical, measurable surrogate for a classifier’s OOD performance.
- The theoretical findings are limited to linear models in a population setting, so they motivate rather than fully justify practical use.
- The supplementary material extends calibration definitions to regression and provides proofs of the paper’s theorems.
A.2 Details about ECE, MMCE and Post-Processing Methods
This section defines calibration metrics and describes post-processing methods for improving calibration. It emphasizes that pooled calibration can differ from simultaneous calibration across individual domains, motivating a robust alternative.
- Calibration metrics: ECE and MMCE are used to evaluate and optimize calibration in multi-domain settings.
- Calibration metrics: ECE bins predictions by confidence, compares accuracy with average confidence, and summarizes deviations from calibration.
- Calibration metrics: MMCE is a training-time calibration method whose value is zero if and only if the classifier is calibrated under the stated conditions.
- Post-processing: Vanilla isotonic regression minimizes the Brier score through monotonic post-processing, primarily reducing calibration error while largely preserving refinement.
- Post-processing: Pooled isotonic regression may calibrate the combined dataset perfectly while remaining miscalibrated within individual environments.
- Post-processing: Robust isotonic regression minimizes worst-environment Brier error, trading off errors across environments to better target simultaneous calibration.
A.4 Classification with Invariant Features
The invariant-features analysis shows how calibration constraints eliminate spurious-feature coefficients under non-degeneracy and general-position assumptions. The proof reduces calibrated predictors to systems whose nonzero spurious solutions are ruled out.
- Setup: The classification analysis models environments through Gaussian parameters governing spurious features and uses linear classifiers.
- Calibration constraints: Calibration across environments imposes algebraic constraints on invariant and spurious coefficients, with either zero weights or a constrained nonzero solution.
- Comparison with IRM: In the isotropic-covariance special case, calibration requires one more environment than IRM to discard all spurious features.
- Calibration constraints: Under the non-degeneracy condition, the relevant linear system has no nonzero solution for the spurious coefficients.
- General position: With environments in general position, every classifier calibrated across environments satisfies wsp = 0.
- General position: The proof further shows that generic environments are in general position because the exceptional non-general-position set has measure zero.
A.5 Regression Under Covariate Shift and Spurious Features
This section analyzes regression under covariate shift, showing how calibration constraints across environments restrict causal and spurious feature weights. Under rank and non-degeneracy conditions, sufficiently many calibrated environments force spurious weights to zero.
- Setup: The analysis considers an invariant conditional mechanism across environments, with regressors decomposed into causal and spurious features.The estimate of the mean is linear, while the variance estimate is constant.
- Calibration constraints: Calibration requires the conditional mean relationships to have equal slopes and intercepts across environments.The proof obtains these constraints by writing the conditional distribution of Y given the prediction.
- Mean calibration: With dc + dsp + 1 non-degenerate environments whose environment vectors span the relevant space, the resulting linear system has only the zero solution for adjusted causal and spurious weights.This establishes the key rank-based step in the proof.
- Conclusion: Calibration finally requires the remaining proportionality factor to equal one, yielding the correct causal coefficient and excluding spurious correlations.The argument also extends to anti-causal non-spurious features through an equivalent Gaussian structural-equation representation.
B Dataset Statistics and Models
The experiments use four WILDS tasks spanning countries, hospitals, demographic identities, and time or geography, with separate in-domain and out-of-domain splits. Models are trained and calibrated using standard architectures and multiple training algorithms, including calibration-based methods.
- PovertyMap: PovertyMap predicts asset wealth from multispectral satellite images across countries and urban or rural areas, targeting cross-country and subpopulation generalization.The dataset contains images and survey data from 23 African countries collected between 2009 and 2016.
- Camelyon17: Camelyon17 identifies tumors in histopathological patches across hospitals, training and validating on four hospitals and testing on an unseen fifth hospital.The dataset contains 450000 patches from 50 whole-slide images across five Dutch hospitals.
- CivilComments: CivilComments classifies toxicity across eight demographic-identity subpopulations, evaluating average and worst-case performance across groups.The dataset comprises 450000 comments annotated for toxicity and demographic mentions.
- FMoW: FMoW classifies 62 building or land-use categories across geographic regions and time periods, targeting temporal and regional generalization.The experiments use time-range domains from 2002–2018 and five geographic regions.
- Models and training: The study compares ERM, IRM, DeepCORAL, calibration methods, and neural models including BERT and DenseNet across these experiments.Models are trained four times with different random seeds, with averages and standard deviations reported.
C.1 Performance of CLOvE
The Colored MNIST experiments compare CLOvE with ERM and IRMv1 under settings where either color or digit is invariant. CLOvE can approach the optimal invariant classifier, but digit-recognition error limits exact recovery when digit is invariant.
- Experimental setup: The experiments train 100 models per algorithm and environment setting, using ERM, IRM, and CLOvE on Colored MNIST.The training environments are represented by tuples of digit and color correlations.
- Color-invariant setting: When color is invariant and digit is spurious, most CLOvE models achieve test log-loss close to the optimal invariant classifier.The selected CLOvE model with the lowest training objective is close to the optimal invariant classifier in test loss.
- Color-invariant setting: In the same setting, the IRMv1-selected model has test loss close to the OPTIRMv1 solution, while CLOvE approaches the optimal invariant solution.The comparison uses models trained on environments with correlations (0.1, 0.05) and (0.2, 0.05), tested at (0.9, 0.05).
- Digit-invariant setting: When digit is invariant, MLP digit-recognition error makes exact invariant-classifier recovery difficult because it is close to the 0.05 correlation magnitude.The authors identify average ECE as a better invariance measure than the IRMv1 objective in this failure case.
- Alternative setting: In an alternative setting where IRMv1 can learn the optimal invariant classifier, both CLOvE and IRMv1 produce models close to the optimum.IRMv1 finds more such models during the hyperparameter sweep, although CLOvE still obtains some close-to-optimal models.
C.2 Model Selection Experiments
The model-selection experiments select candidates by minimizing multi-domain ECE subject to an in-domain accuracy threshold. This criterion trades in-domain accuracy for stability and can differ from IRMv1-based selection, especially in IRM failure settings.
- Selection procedure: For each candidate, the procedure recalibrates predictions, computes in-domain validation error and average training-environment ECE, then selects the lowest-ECE model meeting the accuracy threshold.The selected candidate solves arg min over models whose in-domain validation accuracy reaches ThrID.
- Accuracy–stability tradeoff: Minimal-ECE selection explicitly trades off in-domain accuracy against stability across training environments.The candidate pool combines models trained with ERM, IRMv1, and CLOvE.
- Accuracy constraint: Requiring more than 75% in-domain accuracy causes a sharp decline toward the OOD accuracy of a purely empirical-error-minimizing classifier, whereas relaxing the threshold yields 64.98%(±2.67)% OOD accuracy.The 75% threshold corresponds to the in-domain error of an optimal invariant classifier.
- Comparison with IRMv1: In one setting, ECE- and IRMv1-based selection are broadly comparable, except at high desired in-domain accuracies where IRMv1 fails to rank ERM candidates by OOD accuracy.The comparison uses training environments (0.25, 0.1) and (0.25, 0.2), with test environment (0.25, 0.9).
- Comparison with IRMv1: In the IRM failure setting, model selection using the IRMv1 penalty is expected to fail at capturing invariance, motivating comparison with average ECE.The corresponding environments are (0.05, 0.1), (0.05, 0.2), and (0.05, 0.9).