Real-world machine learning models need to know when to say "I don't know." Historically, abstaining from a prediction has been studied in two disjoint fields: Selective Classification (SC), which focuses on rejecting "hard" or ambiguous in-distribution (ID) samples, and Out-of-Distribution (OOD) Detection, which focuses on rejecting anomalous samples drawn from a completely different distribution.
In real-world deployments, models encounter both types of samples. The unified problem—Selective Classification with OOD Detection (SCOD)—is relatively new. Existing techniques for SCOD often rely on heuristic ways of combining SC and OOD scores. This paper provides a rigorous mathematical foundation for SCOD, demonstrating why standard baselines fail and introducing theoretically grounded plug-in estimators to make optimal rejection decisions.
The Mathematical Foundation of SCOD
The authors first formulate SCOD statistically to derive the Bayes-optimal rejection rule. They find that the optimal decision relies on comparing two key quantities: the maximum inlier class probability (confidence in the label) and the density ratio between the OOD and ID distributions (confidence that the sample is an inlier).
Instead of relying on heuristics, they propose plug-in estimators that directly approximate this Bayes-optimal rule. They apply this in two practical settings:
- Black-box SCOD (Only ID Data): This approach takes any off-the-shelf SC score (e.g., Maximum Softmax Probability) and any OOD score (e.g., gradient norm) trained only on ID data, and combines them using the derived optimal formula.
- Loss-based SCOD (ID + Unlabeled "Wild" Data): This setting assumes access to ID data plus an unlabeled mixture of ID and OOD data collected "in the wild." The authors propose a decoupled loss function that jointly trains a classifier and a rejector to estimate the necessary probabilities and density ratios directly.
Key Insights: Why Baselines Fail
A major contribution of this work is formally proving that standard baselines are mathematically insufficient for the joint SCOD problem. For example, Maximum Softmax Probability (MSP)—a gold standard baseline for both SC and OOD—can fail arbitrarily badly. Even in seemingly favorable setups, MSP fails because it relies on normalized inlier probabilities and completely ignores the actual OOD density.
Furthermore, prior state-of-the-art methods for SCOD (like SIRC) heuristically multiplied SC and OOD scores together. The Bayes-optimal derivation reveals that the mathematically correct combination is actually an additive thresholding of the confidence error and the density ratio.
Empirical Results
The proposed plug-in estimators were evaluated using Area Under the Risk-Coverage Curve (AUC-RC), which measures the joint risk of misclassification and OOD acceptance at various abstention budgets. Lower AUC-RC indicates better performance. The models were tested on ID datasets like CIFAR-100 and ImageNet against a wide variety of OOD datasets (SVHN, Places365, LSUN, Texture, etc.).
Across the board, the proposed plug-in estimators consistently achieved the lowest AUC-RC. For instance, on CIFAR-100 tested against OpenImages, the Black-Box Plug-in achieved an AUC-RC of 0.222, significantly outperforming the SIRC baseline (0.316) and standard MSP (0.342). On ImageNet using a pre-trained BiT ResNet-101, the Black-Box plug-in yielded notable gains on 5 out of 8 OOD datasets.
The experiments also revealed an interesting dynamic regarding training data: the Loss-Based plug-in (which uses wild data) performed best when the OOD data in the training mixture matched the test OOD data. However, when the wild data did not match the test data, the Black-Box method often proved more robust.
Limitations and Future Directions
While highly effective, the proposed plug-in rejectors are inherently dependent on the quality of the underlying OOD/density ratio estimators they use; if the chosen OOD scorer is weak on a specific dataset, overall SCOD performance will suffer. Additionally, the authors note a known limitation in selective classification: optimizing for overall accuracy can sometimes magnify accuracy disparities among smaller demographic sub-groups.
Future work will explore better ways to estimate the density ratio and apply these rejection strategies to "adaptive inference" (early-exit models), allowing large models to save compute by exiting early on obvious OOD samples as well as easy ID samples.
Summary updated