Introduction
When machine learning models are deployed in real-world environments, they frequently encounter data that differs from their training distribution—a phenomenon known as covariate shift. For safety-critical applications such as autonomous driving or medical diagnostics, it is vital to monitor a model's accuracy in real-time. However, ground-truth labels are typically unavailable during deployment, necessitating the use of performance estimation techniques.
Existing estimation methods often rely on a model's internal confidence (softmax scores) or the level of disagreement within an ensemble. A significant limitation of these approaches is that neural networks are notoriously overconfident when processing out-of-distribution (OOD) data. When a model encounters an input it does not "understand," its confidence score becomes an unreliable proxy for accuracy, leading current estimators to drastically overestimate performance. This paper addresses this gap by introducing a simple, modular "distance check" to filter out alien samples before performance estimation occurs.
Methodology
The authors propose a plug-and-play distance-based filter that can be integrated with existing estimators like Average Thresholded Confidence (ATC) or Generalised Disagreement Equality (GDE). Instead of relying on the final output layer, the method analyzes the model's penultimate layer—the embedding space.
The Distance Check Algorithm
- Embedding Extraction: The method extracts feature embeddings for the in-distribution (ID) training set.
- K-NN Calibration: A K-Nearest Neighbors (K-NN) algorithm is fitted to these ID embeddings. Using an ID validation set, the system calculates the average distance of each sample to its $K$ nearest neighbors. A threshold is then set at the 99th percentile of these distances.
- Test-Time Filtering: For every new, unlabelled sample at test time, the K-NN distance is calculated. If the distance exceeds the pre-calibrated threshold, the sample is flagged as "too far" from the known distribution and is automatically assumed to be misclassified.
- Hybrid Estimation: For samples that pass the distance check, standard confidence-based rules (like ATC) are applied to estimate the final accuracy.
The authors further refine this with ATC-DistCS, a class-specific variant that calculates unique distance thresholds for every predicted class. This accounts for the fact that different categories may have varying cluster densities in the embedding space.
Experimental Setup and Results
The proposed method was evaluated across 13 image classification tasks encompassing synthetic corruptions, acquisition shifts, and natural subpopulation shifts. These included the ImageNet family (Sketch, Adversarial, V2), CIFAR10-C, the BREEDS subpopulation benchmarks, and the WILDS real-world benchmark (Camelyon17, iCam, FMoW, RxRx1).
Key Findings
- State-of-the-Art Performance: The
ATC-DistCSvariant achieved state-of-the-art performance estimation on 10 out of the 13 evaluated tasks. - Significant Error Reduction: Across hundreds of models, the distance-augmented approach achieved a median relative Mean Absolute Error (MAE) improvement of 30% over standard ATC and a 27% improvement over Confidence Optimal Transport (COT).
- Computational Efficiency: Unlike complex regression-based or transport-based estimators, the K-NN distance check is highly scalable. On an ImageNet ResNet150 model, the method generated estimates in approximately 300 seconds, compared to 3500 seconds for COT.
- Versatility: The distance check proved effective as a general-purpose filter, improving both confidence-based and agreement-based (ensemble) estimation methods.
Discussion and Limitations
A primary advantage of this method is that it requires no OOD data for calibration; it relies solely on the ID training and validation sets. This makes it a practical post-hoc solution for existing models.
However, the method's efficacy is tied to the quality of the ID validation set. In scenarios with extreme class imbalance where some classes are underrepresented in the validation data, the distance thresholds may become sub-optimal. Additionally, the method can be overly conservative—assuming all distant points are incorrect—which may lead to underestimating accuracy on datasets with "easy" stylistic shifts (e.g., the PACS dataset). The authors argue that in safety-critical systems, this conservative bias is preferable to the silent failure of overestimating performance.
Conclusion
By combining embedding-space distance with traditional confidence metrics, this research provides a robust framework for monitoring AI performance under distribution shift. The "distance check" effectively patches the blind spot of neural network overconfidence, offering a scalable and accurate solution for real-world model monitoring.
Summary updated