Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unreadable labels in plot_confusion_matrix in case of imbalanced data and show_normed=True #504

Merged
merged 3 commits into from
Feb 12, 2019

Conversation

dynobo
Copy link
Contributor

@dynobo dynobo commented Feb 12, 2019

Change

If show_normed is True, use the normed conf mat for background coloring instead of the absolute conf matrix, because label coloring (black/white) also follows normed conf matrix. This fixes unreadable labels that can occur with imbalanced datasets.

Description

If arg show_absolute=True and show_normed=True the background-color is choosen by the absolute value, while the label color is chosen by the normed value. This can lead to unreadable labels for imbalanced dataset.

Before / After:
Example

Related issues or pull requests

n/a

Pull Request Checklist

  • Added a note about the modification or contribution to the ./docs/sources/CHANGELOG.md file (if applicable)
  • Added appropriate unit test functions in the ./mlxtend/*/tests directories (if applicable)
  • Modify documentation in the corresponding Jupyter Notebook under mlxtend/docs/sources/ (if applicable)
  • Ran nosetests ./mlxtend -sv and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., nosetests ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv)
  • Checked for style issues by running flake8 ./mlxtend

Use the normed conf mat for background, if normed is set, as label coloring also follows normed conf matrix.
Fixes unreadable labels in imbalanced datasets.
@coveralls
Copy link

coveralls commented Feb 12, 2019

Coverage Status

Coverage remained the same at 91.596% when pulling 2a36c91 on dynobo:master into cce9e60 on rasbt:master.

docs/sources/CHANGELOG.md Outdated Show resolved Hide resolved
@rasbt
Copy link
Owner

rasbt commented Feb 12, 2019

Great catch, thanks a lot!

@dynobo
Copy link
Contributor Author

dynobo commented Feb 12, 2019

Typo fixed and also added link to PR

@rasbt
Copy link
Owner

rasbt commented Feb 12, 2019

LGTM! Thanks a lot!

@rasbt rasbt merged commit 6b57a73 into rasbt:master Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants