-
Notifications
You must be signed in to change notification settings - Fork 373
Open
Labels
Description
Description
When using plot_confusion_matrix with integer class labels that are not contiguous (e.g., [1, 2, 10]), the function incorrectly interprets them as a continuous numeric range rather than as categorical labels.
As a result, the confusion matrix displays empty intermediate classes (e.g., 3β9), creating unwanted spacing in the visualization.
Integer labels should be treated as categorical values, not as numeric intervals.
π Minimal Reproducible Example
from shapash.plots.plot_evaluation_metrics import plot_confusion_matrix
# Example lists of integer class labels
y_true_labels = [1, 2, 1, 10, 2, 1, 10, 2]
y_pred_labels = [1, 1, 1, 10, 2, 2, 10, 1]
plot_confusion_matrix(
y_true=y_true_labels,
y_pred=y_pred_labels,
width=500,
height=400
)β Current Behavior
- The confusion matrix assumes labels are continuous integers.
- Intermediate class values (e.g., 3, 4, 5, 6, 7, 8, 9) are implicitly considered.
- The resulting plot contains large empty gaps between actual labels (2 β 10).
β Expected Behavior
- Labels should be treated as categorical values.
- Only observed unique labels should appear in the confusion matrix.
- No artificial gaps between 2 and 10.

Reactions are currently unavailable