scikit-learn-contrib / imbalanced-learn

A Python Package to Tackle the Curse of Imbalanced Datasets in Machine Learning
https://imbalanced-learn.org
MIT License
6.85k stars 1.29k forks source link

[MRG] Fix classification_report_imbalanced output_dict keys to target_names #986

Closed AYY7 closed 1 year ago

AYY7 commented 1 year ago

Reference Issue

Fixes https://github.com/scikit-learn-contrib/imbalanced-learn/issues/863

What does this implement/fix? Explain your changes.

When output_dict=True and target_names is given, set the keys of the output_dict to the corresponding target_names

{'label 1': {'pre':0.5,
             'rec':1.0,
             ...
            },
 'label 2': { ... },
  ...
}

When output_dict=True and target_names is not given, set the keys of the output_dict to the corresponding labels in str format

{'0': {'pre':0.5,
             'rec':1.0,
             ...
            },
 '1': { ... },
  ...
}

Any other comments?