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

Proper multilabel support for confmat #134

Merged
merged 20 commits into from
Mar 29, 2021
Merged

Proper multilabel support for confmat #134

merged 20 commits into from
Mar 29, 2021

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented Mar 26, 2021

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Fixes #100
Currently using confusion matrix with multilabel data will smash it all together as one big binary classification problem, which is really not wanted. Instead we should probably go for something similar to what sklearn does in that case (https://scikit-learn.org/stable/modules/generated/sklearn.metrics.multilabel_confusion_matrix.html). Instead of having a specialized metric for this case, this PR adds a is_multilabel flag and implements the same logic as sklearn.

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@SkafteNicki SkafteNicki added the enhancement New feature or request label Mar 26, 2021
@SkafteNicki SkafteNicki added this to the 0.3 milestone Mar 26, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #134 (484b9fb) into master (19b77cc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #134   +/-   ##
=======================================
  Coverage   96.76%   96.77%           
=======================================
  Files         156      156           
  Lines        4826     4837   +11     
=======================================
+ Hits         4670     4681   +11     
  Misses        156      156           
Flag Coverage Δ
Linux 79.26% <93.33%> (-0.02%) ⬇️
Windows 79.26% <93.33%> (-0.02%) ⬇️
cpu 96.77% <100.00%> (+<0.01%) ⬆️
gpu 96.77% <ø> (+0.01%) ⬆️
macOS 96.77% <100.00%> (+<0.01%) ⬆️
pytest 96.77% <100.00%> (+<0.01%) ⬆️
python3.6 96.77% <100.00%> (+0.01%) ⬆️
python3.8 ?
python3.9 ?
torch1.3.1 95.57% <100.00%> (+0.01%) ⬆️
torch1.4.0 ?
torch1.8.1 96.77% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
torchmetrics/classification/confusion_matrix.py 100.00% <100.00%> (ø)
...rics/functional/classification/confusion_matrix.py 100.00% <100.00%> (ø)
torchmetrics/metric.py 95.00% <0.00%> (-0.08%) ⬇️
torchmetrics/utilities/prints.py 100.00% <0.00%> (ø)
.../s/torchmetrics/classification/confusion_matrix.py 100.00% <0.00%> (ø)
...rics/functional/classification/confusion_matrix.py 100.00% <0.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 19b77cc...484b9fb. Read the comment docs.

@Borda Borda added the ready label Mar 29, 2021
Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

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

just not sure about the is_multilabel sound unnatural to me... (as an argument, it would be fine as property or attribute)

torchmetrics/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
tests/classification/test_confusion_matrix.py Outdated Show resolved Hide resolved
tests/classification/test_confusion_matrix.py Outdated Show resolved Hide resolved
tests/classification/test_confusion_matrix.py Outdated Show resolved Hide resolved
tests/classification/test_confusion_matrix.py Outdated Show resolved Hide resolved
tests/classification/test_confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
torchmetrics/functional/classification/confusion_matrix.py Outdated Show resolved Hide resolved
@SkafteNicki
Copy link
Member Author

@Borda I have changed the arg to just multilabel, as you are right it makes more sense

@Borda Borda enabled auto-merge (squash) March 29, 2021 11:46
CHANGELOG.md Show resolved Hide resolved
@Borda Borda merged commit d1af80f into master Mar 29, 2021
@Borda Borda deleted the confmat_multilabel branch March 29, 2021 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Functional Confusion Matrix with Multi-Label
3 participants