Skip to content

Classification report shows classes inverted if passed from sklearn label encoder #1313

@alessandrofilisetti

Description

@alessandrofilisetti

Describe the bug
The same classes passed through sklearn label encoder are shown inverted in classification report. I tried the same with confusion matrix and classes are correctly shown

To Reproduce

 # CLASSIFICATION REPORT
  visualizer = ClassificationReport(
      pipeline,
      classes = label_encoder.classes_,
      cmap="YlGn", 
      support=True
  )
  visualizer.fit(X_train, y_train)
  visualizer.score(X_test, y_test) 

  # CONFUSION MATRIX
  cm = ConfusionMatrix(
      pipeline, 
      classes= label_encoder.classes_,
      cmap='Greens'
  )
  
  cm.fit(X_train, y_train)
  cm.score(X_test, y_test)

Dataset
Whatever dataset you prefer

Expected behavior
Coherent classes visualization

Desktop (please complete the following information):

  • OS: Cloud Jupiter notebook
  • Python Version 3.11
  • Yellowbrick Version 1.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions