-
Notifications
You must be signed in to change notification settings - Fork 82
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #640 +/- ##
=======================================
Coverage 98.96% 98.96%
=======================================
Files 133 133
Lines 4545 4553 +8
=======================================
+ Hits 4498 4506 +8
Misses 47 47
Continue to review full report at Codecov.
|
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.") |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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
There was a problem hiding this 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! ⛴️
Fixes #311.