Visualize how prediction set types (correct, incorrect, two-class, empty) distribute across different categories.
Code
plot_prediction_set_profiles_by_category( cat_test, prediction_sets, y_test, title="Prediction Set Profiles by Risk Category", category_order="freq", # Order by frequency)
(<Figure size 1152x576 with 2 Axes>,
<Axes: ylabel='Fraction per Type'>,
<Axes: ylabel='Sample Count'>)
Plot Profiles by Category (Stacked)
The same plot with stacked bars for a different perspective.
Code
plot_prediction_set_profiles_by_category( cat_test, prediction_sets, y_test, title="Prediction Set Profiles by Risk Category (Stacked)", style="stacked",)
(<Figure size 1152x576 with 2 Axes>,
<Axes: ylabel='Fraction per Type'>,
<Axes: ylabel='Sample Count'>)
Plot Profiles by Category (Count Mode)
Show absolute counts instead of fractions.
Code
plot_prediction_set_profiles_by_category( cat_test, prediction_sets, y_test, title="Prediction Set Counts by Risk Category", y_mode="count",)
(<Figure size 1152x576 with 2 Axes>,
<Axes: ylabel='Number of Samples'>,
<Axes: ylabel='Sample Count'>)
Plot Profiles by Numeric Feature
Visualize how prediction behavior changes across a numeric feature’s range.
Code
# Use first feature as examplefeature_values = X_test[:, 0]plot_prediction_set_profiles_by_feature( feature_values, prediction_sets, y_test, bins=10, title="Prediction Set Profiles by Feature 0",)
(<Figure size 1152x576 with 2 Axes>,
<Axes: xlabel='Feature Value (binned)', ylabel='Fraction per Type'>,
<Axes: ylabel='Sample Count'>)
Plot Profiles Split by True Label
Create separate subplots for each true class to see class-specific patterns.
Code
plot_prediction_set_profiles_split_by_true( cat_test, prediction_sets, y_test, label_names={0: "Class 0 (Majority)", 1: "Class 1 (Minority)"}, title="Prediction Set Profiles by Category — Split by True Label", ncols=2,)
(<Figure size 1612.8x691.2 with 4 Axes>,
array([[<Axes: title={'center': 'True label = Class 0 (Majority) (n=271)'}, ylabel='Fraction per Type'>,
<Axes: title={'center': 'True label = Class 1 (Minority) (n=129)'}, ylabel='Fraction per Type'>]],
dtype=object))
Interpretation
These plots reveal important patterns:
One-Class Correct (green): Model made a confident, correct prediction
One-Class Incorrect (red): Model was confident but wrong
Two-Class Sets (blue): Model was uncertain, included both classes
No Sets (gray): Very rare at typical α levels
Key insights:
Categories with more “red” need attention - the model is confidently wrong
Categories with more “blue” indicate uncertainty - may need more training data
The split-by-true-label view shows if issues are class-specific