Selective Classification Under Distribution Shifts

Hengyue Liang, Le Peng, Ju Sun

This paper, published in Transactions on Machine Learning Research, introduces a unified approach to making machine learning models safer in the real world by allowing them to say "I don't know" when faced with unfamiliar or confusing data.

TL;DR

The authors propose Generalized Selective Classification, a framework that enables models to abstain from predictions not just on difficult in-distribution data, but also on samples affected by covariate and label shifts. They identify a critical scale-sensitivity flaw in standard softmax-based confidence scores and introduce two novel, scale-invariant margin-based scores that significantly improve reliability in high-stakes scenarios.

What Problem Does This Paper Address?

In high-stakes fields like healthcare or autonomous driving, a wrong prediction is often worse than no prediction at all. Selective Classification (SC) addresses this by allowing a model to "abstain" from uncertain cases, deferring them to a human expert.

However, traditional SC assumes the "i.i.d. setting"—that the data seen during deployment looks exactly like the training data. In reality, models face distribution shifts:

  • Type A (In-Distribution Errors): The model is just wrong on "normal" data.
  • Type B (Label Shifts/OOD): The model sees a category it was never trained on (e.g., a cat classifier seeing a toaster).
  • Type C (Covariate Shifts): The model sees known categories but in a new context (e.g., medical images from a different hospital's scanner).

Existing research usually treats these as separate problems (SC vs. OOD detection). This paper argues that for a system to be truly reliable, it must handle all three error types jointly in a single, unified framework.

Methods

The authors focus on non-training-based (post-hoc) methods, which are essential for modern foundation models that are too expensive to retrain.

The Softmax Flaw

Most current SC methods rely on Softmax Responses (SR). The authors demonstrate that SR-based scores are highly sensitive to the scale of the raw logit outputs. As shown in Figure 2, simply multiplying the logits by a constant factor—which doesn't change the model's actual prediction—can drastically change the model's "confidence" ranking and its resulting performance curve.

Figure 2: RC curves for (b) SRmax, (c) SRdoctor, and (d) SRent, calculated based on scaled (by factor 0.1, 1.0, 2.0, and 4.0, respectively) raw logits from the optimal 4-class linear classifier using data shown in (a). The RC curves for RLconf-M and spost are also plotted for reference, where RLconf-M is one of our proposed confidence-score functions.

Margin-Based Scores

To fix this, the authors propose two scores based on the raw logits (the values before the softmax layer):

  1. $RL_{conf-M}$ (Confidence Margin): The difference between the highest and second-highest raw logit.
  2. $RL_{geo-M}$ (Geometric Margin): The difference between the distances to the two closest decision hyperplanes in the feature space.

These scores are scale-invariant, meaning their performance doesn't fluctuate based on arbitrary logit scaling.

Datasets

The framework was tested across diverse tasks and shifts:

  • ImageNet: Evaluated with ImageNet-C (synthetic corruptions for covariate shift) and OpenImage-O (disjoint labels for label shift).
  • iWildCam: A wildlife monitoring dataset featuring natural covariate shifts due to different camera locations.
  • Amazon: A sentiment analysis task with shifts across different users.
  • CIFAR-10/100: Standard benchmarks used to compare against training-based SC methods like SelectiveNet.

Key Insights and Ideas

  • Unified Evaluation: The authors advocate for using the Risk-Coverage (RC) curve and the Area Under the Risk-Coverage curve (AURC) as the primary metrics for generalized SC. This measures how the error rate (risk) drops as we allow the model to abstain more (lower coverage).
  • Rejection Patterns: Margin-based scores have a "favorable" rejection pattern. In toy experiments, they prioritized rejecting samples near decision boundaries (where the model is truly uncertain), whereas softmax-based scores often rejected samples based on their distance from the origin, which is less relevant to classification accuracy.
  • OOD Detection is a Subset: The paper argues that OOD detection is essentially a "weak form" of generalized SC. If the goal is reliable classification, it's better to optimize for the final accuracy on accepted samples rather than just trying to separate "in-distribution" from "out-of-distribution."

Key Results

The proposed margin-based scores consistently outperformed or matched state-of-the-art methods across all tested models (EVA, ConvNext, ResNext, etc.).

Figure 4: RC curves on the EVA model for ImageNet. The proposed margin-based scores (solid lines) achieve lower risk across various combinations of distribution shifts.

On ImageNet, when In-D, covariate-shifted, and label-shifted samples were mixed, $RL_{conf-M}$ and $RL_{geo-M}$ provided the most stable and significant risk reduction. Notably, they performed better than complex training-based methods like ScNet, proving that a well-designed post-hoc score can be more effective than specialized training.

Limitations and Future Work

  • Class Weighting: The current framework treats all classes equally. In medicine, missing a rare but deadly disease is worse than missing a common cold. Future work could incorporate class-specific rejection costs.
  • Threshold Selection: While the paper identifies which scores are best, it doesn't focus on how to set the optimal rejection threshold ($\gamma$) in a shifting environment without a large calibration set.
  • Training Alignment: The authors suggest that future research could look into training models specifically to maximize these margin-based scores, potentially leading to even more robust selective classifiers.

Summary updated

BibTeX
@article{liang2024selective,
  author = {Hengyue Liang and Le Peng and Ju Sun},
  title = {{Selective Classification Under Distribution Shifts}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=dmxMGW6J7N},
}
Figure