Skip to content

Commit

Permalink
Fix unreadable labels in plot_confusion_matrix in case of imbalanced …
Browse files Browse the repository at this point in the history
…data and show_normed=True (#504)

* Change bg color to follow normed values like label

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.

* Add bugfix description

* Fix typo & add link to PR
  • Loading branch information
dynobo authored and rasbt committed Feb 12, 2019
1 parent cce9e60 commit 6b57a73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The CHANGELOG for the current development version is available at

##### Bug Fixes

- Fix unreadable labels in `plot_confusion_matrix` for imbalanced datasets if `show_absolute=True` and `show_normed=True`. ([#504](https://github.com/rasbt/mlxtend/pull/504))

- Raises a more informative error if a `SparseDataFrame` is passed to `apriori` and the dataframe has integer column names that don't start with `0` due to current limitations of the `SparseDataFrame` implementation in pandas. ([#503](https://github.com/rasbt/mlxtend/pull/503))

### Version 0.15.0 (01-19-2019)
Expand Down
6 changes: 3 additions & 3 deletions mlxtend/plotting/plot_confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def plot_confusion_matrix(conf_mat,
if figsize is None:
figsize = (len(conf_mat)*1.25, len(conf_mat)*1.25)

if show_absolute:
matshow = ax.matshow(conf_mat, cmap=cmap)
else:
if show_normed:
matshow = ax.matshow(normed_conf_mat, cmap=cmap)
else:
matshow = ax.matshow(conf_mat, cmap=cmap)

if colorbar:
fig.colorbar(matshow)
Expand Down

0 comments on commit 6b57a73

Please sign in to comment.