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

[Refactor] Classification 5/n #1159

Merged
merged 28 commits into from
Aug 5, 2022

Conversation

SkafteNicki
Copy link
Member

@SkafteNicki SkafteNicki commented Jul 22, 2022

What does this PR do?

Continues work on classification refactor #1001
Prior work:

This PR takes care of accuracy metric. Old implementation had an argument subset_accuracy to determine if subset accuracy (known as exact match also) should be calculated. To standardize with the rest of the metrics, this argument has been split into its own metric exact_match. This metric is then only implemented in the multilabel case, where this kind of evaluation is used.

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?

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 enhancement New feature or request Priority Critical task/issue refactoring refactoring and code health labels Jul 22, 2022
@SkafteNicki SkafteNicki added this to the v0.10 milestone Jul 22, 2022
@SkafteNicki SkafteNicki changed the base branch from master to devel/classification July 22, 2022 13:19
@SkafteNicki SkafteNicki marked this pull request as ready for review July 24, 2022 16:04
@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #1159 (7a3943a) into devel/classification (84d9f26) will decrease coverage by 0%.
The diff coverage is 100%.

@@                  Coverage Diff                  @@
##           devel/classification   #1159    +/-   ##
=====================================================
- Coverage                    92%     91%    -0%     
=====================================================
  Files                       185     187     +2     
  Lines                      9513    9642   +129     
=====================================================
+ Hits                       8731    8805    +74     
- Misses                      782     837    +55     

@SkafteNicki SkafteNicki mentioned this pull request Jul 28, 2022
4 tasks
@SkafteNicki SkafteNicki mentioned this pull request Aug 1, 2022
4 tasks
@mergify mergify bot added the ready label Aug 1, 2022
src/torchmetrics/classification/accuracy.py Show resolved Hide resolved
preds = preds.reshape(*preds.shape[:2], -1)
target = target.reshape(*target.shape[:2], -1)

if multidim_average == "global":
Copy link
Member

Choose a reason for hiding this comment

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

Can we split as two functions as they effectively are...

assert torch.allclose(noneavg["res1"], result1, equal_nan=True)
result2 = acc(noneavg["pred2"], noneavg["target2"])
assert torch.allclose(noneavg["res2"], result2, equal_nan=True)
# -------------------------- Old stuff --------------------------
Copy link
Member

Choose a reason for hiding this comment

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

let's add todo for removal after merging back to master...

@mergify mergify bot added the has conflicts label Aug 3, 2022
@mergify mergify bot removed the has conflicts label Aug 3, 2022
@mergify mergify bot removed the ready label Aug 5, 2022
@SkafteNicki SkafteNicki mentioned this pull request Aug 5, 2022
4 tasks
@mergify mergify bot added the ready label Aug 5, 2022
@SkafteNicki SkafteNicki merged commit e93d66e into devel/classification Aug 5, 2022
@SkafteNicki SkafteNicki deleted the refactor/classification_5 branch August 5, 2022 14:06
@SkafteNicki SkafteNicki mentioned this pull request Aug 20, 2022
4 tasks
Borda added a commit that referenced this pull request Aug 26, 2022
* base structure

* partly working accuracy

* init files

* working accuracy

* exact match

* mix mistake

* exact matching

* init files

* fix doctest

* mypy

* fix docs

* fix integer division

* try fixing test dependency

* fix f-string

* fix integer division

* fix integer division

* fix?

* try again

* fix pep8

* docs

* try something

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@SkafteNicki SkafteNicki mentioned this pull request Aug 28, 2022
4 tasks
Borda added a commit that referenced this pull request Sep 12, 2022
* base structure

* partly working accuracy

* init files

* working accuracy

* exact match

* mix mistake

* exact matching

* init files

* fix doctest

* mypy

* fix docs

* fix integer division

* try fixing test dependency

* fix f-string

* fix integer division

* fix integer division

* fix?

* try again

* fix pep8

* docs

* try something

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Borda added a commit that referenced this pull request Sep 12, 2022
* base structure

* partly working accuracy

* init files

* working accuracy

* exact match

* mix mistake

* exact matching

* init files

* fix doctest

* mypy

* fix docs

* fix integer division

* try fixing test dependency

* fix f-string

* fix integer division

* fix integer division

* fix?

* try again

* fix pep8

* docs

* try something

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Borda added a commit that referenced this pull request Sep 13, 2022
* base structure

* partly working accuracy

* init files

* working accuracy

* exact match

* mix mistake

* exact matching

* init files

* fix doctest

* mypy

* fix docs

* fix integer division

* try fixing test dependency

* fix f-string

* fix integer division

* fix integer division

* fix?

* try again

* fix pep8

* docs

* try something

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Borda added a commit that referenced this pull request Sep 13, 2022
* base structure

* partly working accuracy

* init files

* working accuracy

* exact match

* mix mistake

* exact matching

* init files

* fix doctest

* mypy

* fix docs

* fix integer division

* try fixing test dependency

* fix f-string

* fix integer division

* fix integer division

* fix?

* try again

* fix pep8

* docs

* try something

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority Critical task/issue ready refactoring refactoring and code health
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants