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

Add error case in normalize_matrix #640

Merged
merged 4 commits into from
Apr 14, 2020
Merged

Conversation

jeremyliweishih
Copy link
Contributor

Fixes #311.

@codecov
Copy link

codecov bot commented Apr 14, 2020

Codecov Report

Merging #640 into master will increase coverage by 0.00%.
The diff coverage is 95.23%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #640   +/-   ##
=======================================
  Coverage   98.96%   98.96%           
=======================================
  Files         133      133           
  Lines        4545     4553    +8     
=======================================
+ Hits         4498     4506    +8     
  Misses         47       47           
Impacted Files Coverage Δ
evalml/utils/gen_utils.py 98.27% <91.66%> (ø)
evalml/tests/utils_tests/test_gen_utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f9d9f2...00a3648. Read the comment docs.

conf_mat = conf_mat.astype('float') / conf_mat.sum().sum()

if w and "invalid value encountered in" in str(w[0].message):
raise ValueError("Sum of given axis is 0 and normalization is not possible. Please select another option.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

normalize_confusion_matrix(conf_mat, 'pred')

with pytest.raises(ValueError, match="Sum of given axis is 0"):
normalize_confusion_matrix(conf_mat, 'all')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please also add a clause for 'true' just for completeness? Lol

Copy link
Contributor

@dsherry dsherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment, good stuff! ⛴️

@jeremyliweishih jeremyliweishih merged commit e1a4c35 into master Apr 14, 2020
@dsherry dsherry deleted the js_311_testwarning branch October 29, 2020 23:49
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.

Warning messages in unit test: "invalid value encountered in double_scalars" and others
2 participants