plots.plot_prediction_set_profiles_by_category
plots.plot_prediction_set_profiles_by_category(
cat_values,
prediction_sets,
y_true,
category_order='freq',
include_types=('one_correct', 'one_incorrect', 'two_class', 'no_set'),
top_n=None,
min_count=None,
other_label='Other',
style='grouped',
figsize=(12, 6),
title='Prediction Set Profiles by Category',
colors=None,
rotate_xticks=45,
y_mode='fraction',
)Plot distribution of prediction set types per category.
Parameters
cat_values : array-like of shape (n_samples,)-
Category label per sample.
prediction_sets : list of list or set-
Prediction sets for each instance.
y_true : array-like of shape (n_samples,)-
True class labels.
category_order : str or list = "freq"-
How to order categories: - “freq”: by sample count (descending) - “alpha”: alphabetically - list: explicit order - “by:
”: sort by metric (e.g., “by:one_correct”, “by:-one_correct”) include_types : tuple = ("one_correct", "one_incorrect", "two_class", "no_set")-
Which prediction set types to include in the plot.
top_n : int = None-
Keep only top-N categories by count, collapse others.
min_count : int = None-
Keep only categories with at least this many samples.
other_label : str = "Other"-
Label for collapsed categories.
style : str = "grouped"-
“grouped” for side-by-side bars, “stacked” for stacked bars.
figsize : tuple = (12, 6)-
Figure size.
title : str = "Prediction Set Profiles by Category"-
Plot title.
colors : dict = None-
Override colors, e.g., {“one_correct”: “#2ca02c”}.
rotate_xticks : int = 45-
Rotation angle for x-axis labels.
y_mode : str = "fraction"-
“fraction” for proportions, “count” for absolute counts.
Returns
fig : matplotlib.figure.Figure-
The figure object.
ax1 : matplotlib.axes.Axes-
Primary axes object.
ax2 : matplotlib.axes.Axes-
Secondary axes object (for sample count).
Examples
>>> fig, ax1, ax2 = plot_prediction_set_profiles_by_category(
... X_test["home_ownership"].values,
... prediction_sets,
... y_test,
... top_n=5
... )