Class-Conditional Conformal Prediction with Many Classes

Tiffany Ding, Anastasios Nikolas Angelopoulos, Stephen Bates, Michael Jordan, Ryan Tibshirani

Standard conformal prediction guarantees that a model is right "on average," but it often fails on specific classes—especially rare or difficult ones. This paper introduces Clustered Conformal Prediction, a method that groups similar classes together to provide better class-specific reliability without generating the massive, unusable prediction sets caused by traditional class-by-class calibration.

The Shortcomings of Standard Conformal Prediction

Imagine a medical AI trained to identify brain conditions from CT scans. It might boast 90% accuracy overall, but a closer look reveals it is 99% accurate on common issues like concussions while completely missing rare, fatal hemorrhages. In the world of Conformal Prediction (CP)—a statistical framework that turns point predictions into sets of likely labels—this is a failure of "marginal coverage."

Standard CP guarantees that the true label will be in the predicted set a user-specified percentage of the time (e.g., 90%). However, this is an average across the entire dataset. In "many-class" settings, such as ImageNet's 1,000 categories, the model often achieves this average by over-covering easy classes and under-covering hard ones.

The obvious fix is "Classwise CP," where a calibration threshold is set for every single class. But there’s a catch: if you only have 10 examples of a specific class, your statistical estimate will be incredibly noisy. To guarantee coverage with such high variance, the method is forced to output massive, practically useless prediction sets.

The "Goldilocks" Solution: Clustered Conformal Prediction

To tackle this "limited-data, many-class" regime, the authors propose Clustered Conformal Prediction. It strikes a balance between the stability of the global approach and the granularity of the classwise approach.

The variance-granularity tradeoff in conformal prediction.

The algorithm operates in two main stages:

  1. Quantile-Based Clustering: A small portion of the calibration data is used to summarize how each class "behaves" based on its score distribution. Each class is assigned an embedding based on its score quantiles. Classes with similar distributions are then grouped using a weighted k-means algorithm. Crucially, classes do not need to be semantically similar (e.g., "cats" and "dogs") to be clustered; they just need to have similar conformal scores.
  2. Cluster-Level Calibration: The remaining calibration data is pooled within each cluster. Instead of one threshold for everyone (Standard CP) or 1,000 thresholds for 1,000 classes (Classwise CP), the method calculates one threshold per cluster.

The method also includes a "null cluster" for extremely rare classes that lack enough data to be reliably clustered, reverting them to the standard global threshold to maintain stability.

Experimental Validation and Key Results

The researchers evaluated their method on four large-scale image classification benchmarks: ImageNet (1,000 classes), CIFAR-100 (100 classes), Places365 (365 classes), and iNaturalist (663 highly imbalanced classes). They tested these across different score functions, including Softmax and APS.

The primary metric used was CovGap (Average Class Coverage Gap), which measures how far off the actual coverage is from the target coverage across all classes. Lower is better.

CovGap performance across datasets and scoring functions.
  • Superior Performance in Low-Data Regimes: When classes had between 20 and 75 calibration examples, Clustered CP consistently achieved a lower CovGap than both Standard and Classwise methods.
  • Smaller, More Useful Sets: In the highly imbalanced iNaturalist dataset, Classwise CP produced massive prediction sets for rare classes to meet coverage targets. Clustered CP kept set sizes significantly smaller and more practical by leveraging data from similar, more common classes.
  • Robustness: The method outperformed the baselines across all four datasets and multiple scoring functions, proving its broad applicability.

Limitations and Future Work

While Clustered CP offers a strong middle ground, the authors acknowledge a few hurdles. Choosing hyperparameters like the number of clusters ($M$) and the data split ratio ($\gamma$) currently relies on simple heuristics; automated tuning would be a valuable improvement. Additionally, the method's performance heavily depends on the quality of the initial clustering—if the score embeddings are poor, the calibration benefits diminish. Finally, the authors note that this clustering methodology could potentially generalize to other "group-conditional" problems, such as ensuring fairness across different demographic groups.

Summary updated

BibTeX
@inproceedings{ding2023class,
  author = {Tiffany Ding and Anastasios Nikolas Angelopoulos and Stephen Bates and Michael Jordan and Ryan Tibshirani},
  title = {{Class-Conditional Conformal Prediction with Many Classes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=mYz6ApeU4J},
}
Figure