Coverage by Class: Visualizing Conformal Prediction Performance
This example demonstrates how to use plot_conformal_coverage_by_class to visualize the performance of conformal prediction across different confidence levels, broken down by true class.
The plot shows:
Stacked areas: Proportion of each prediction outcome type (correct single prediction, incorrect single prediction, two-class sets, empty sets) separated by true class (0 and 1).
Black line: Empirical coverage (proportion of times the true label is in the prediction set).
Red dashed line: Ideal coverage (should match confidence level).
Orange dashed line: Optional cutoff for decision-making.
This visualization helps identify:
At which confidence levels the model makes reliable single-class predictions
How prediction set sizes vary with confidence
Whether coverage guarantees hold across different confidence levels
Setup and Data Loading
We use the breast cancer dataset, a classic binary classification problem.
(<Figure size 960x672 with 1 Axes>,
<Axes: title={'center': 'Coverage and Prediction Set Types by Class (Mondrian)'}, xlabel='Confidence Level (1 - α)', ylabel='Proportion'>)