plots.plot_prediction_profiles_by_feature_class
plots.plot_prediction_profiles_by_feature_class(
feature_values,
prediction_sets,
y_true,
bins=10,
split_by='true',
title=None,
figsize=(14, 5),
show_histogram=True,
ax=None,
)Plot prediction set profiles by feature bins, split by predicted or true class.
This visualization shows how the distribution of prediction set types (correct, incorrect, two-class, empty) varies across different values of a numeric feature, with separate subplots for each class.
Parameters
feature_values : array-like of shape (n_samples,)-
Numeric feature values used to bin the data.
prediction_sets : list of sets or lists-
Prediction sets for each instance.
y_true : array-like of shape (n_samples,)-
True class labels (binary: 0 or 1).
bins : int = 10-
Number of bins for the feature.
split_by : (true, predicted) = "true"-
How to split the subplots: - “true”: Split by true class (y=0 vs y=1) - “predicted”: Split by predicted class (pred=0 vs pred=1, including two-class sets in both)
title : str = None-
Main title. If None, uses a default based on
split_by. figsize : tuple = (14, 5)-
Figure size.
show_histogram : bool = True-
If True, show a background histogram of sample counts per bin.
ax : array of matplotlib.axes.Axes = None-
If provided, must be an array of 2 axes to plot on.
Returns
fig : matplotlib.figure.Figure-
The figure object.
axes : array of matplotlib.axes.Axes-
The axes objects.
Examples
>>> fig, axes = plot_prediction_profiles_by_feature_class(
... X_test["income"],
... prediction_sets,
... y_test,
... split_by="true",
... )Notes
The plot shows six categories with distinct styles:
- One Correct (solid green): Singleton sets with correct prediction
- One Incorrect (solid red): Singleton sets with wrong prediction
- Two-Class (aligned) (dashed green): Two-class sets shown in the subplot matching the true label
- Two-Class (other) (dashed red): Two-class sets shown in the other subplot
- Empty (class 0/1) (dotted gray): Empty sets by true class