Skip to content

Confusion matrix axis label order is not intuitive #2861

@auguste-probabl

Description

@auguste-probabl

Running

import pandas as pd

from sklearn.dummy import DummyClassifier
from skore import evaluate

X = pd.DataFrame(
    [
        [7.0, 0.27, 0.36],
        [6.3, 0.30, 0.34],
        [8.1, 0.28, 0.40],
        [7.0, 0.27, 0.36],
        [6.3, 0.30, 0.34],
        [8.1, 0.28, 0.40],
    ]
)
y = pd.Categorical(
    ["low", "low", "medium", "medium", "high", "high"],
    ordered=True,
    categories=["low", "medium", "high"],
)

report_dummy = evaluate(DummyClassifier(), X, y)

display = report_dummy.metrics.confusion_matrix()
fig = display.plot()
fig

results in

Image

where the x-axis is "high", "low", "medium". I would expect the order to be the one set in the Categorical call.

Environment

System:
    python: 3.13.0 (main, Oct 16 2024, 03:23:02) [Clang 18.1.8 ]
executable: /home/auguste/Desktop/work/skore/.venv/bin/python3
   machine: Linux-7.0.1-x86_64-with-glibc2.42

Python dependencies:
        skore: 1000
          pip: None
       jinja2: 3.1.6
       joblib: 1.5.3
   matplotlib: 3.10.8
        numpy: 2.4.4
       pandas: 2.3.3
       plotly: 6.7.0
         rich: 15.0.0
 scikit-learn: 1.8.0
      seaborn: 0.13.2
 skore[local]: None
        skrub: 0.8.0
skore-hub-project: 1000
xgboost-cpu; (platform_system: None
xgboost; (platform_system: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions