-
Notifications
You must be signed in to change notification settings - Fork 413
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 MetricInputTransformer
#2392
Conversation
for more information, see https://pre-commit.ci
MetricInputTransformer
* origin/master: [pre-commit.ci] auto fixes from pre-commit.com hooks # Conflicts: # src/torchmetrics/wrappers/transformations.py # tests/unittests/wrappers/test_transformations.py
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2392 +/- ##
========================================
- Coverage 69% 35% -35%
========================================
Files 313 314 +1
Lines 17615 17664 +49
========================================
- Hits 12161 6096 -6065
- Misses 5454 11568 +6114 |
* origin/master: [pre-commit.ci] auto fixes from pre-commit.com hooks
Unsure what to do about the failing mypy test - assigning the lambdas to overwrite the original class methods seems to be the most straightforward solution to supplying user-defined behaviour here; I would add the file to |
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.
overall looks good to me :)
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 good :)
Co-authored-by: Bas Krahmer <[email protected]>
Co-authored-by: Bas Krahmer <[email protected]>
for more information, see https://pre-commit.ci
@lgienapp I just fixed some typing, but suddenly, all tests are failing, Do you mind checking what is wrong... 🦩 |
Some unit tests check for error messages via regexes, and these had to be adapted to the typo fixes as well. Should all pass now. |
Co-authored-by: Daniel Stancl <[email protected]>
for more information, see https://pre-commit.ci
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.
Nice work, thanks for the addition!
What does this PR do?
Fixes #2371
This PR adds a new kind of metric wrapper for data transformations. Transformations allow for modifications to the input a metric receives by wrapping its
pred
andtarget
arguments. Transformations can be implemented by either subclassing theMetricInputTransformer
base class and overriding the.transform_pred()
and/or.transform_target()
functions, or by supplying a lambda function via theLambdaInputTransformer
. ABinaryTargetTransformer
which casts target labels to 0/1 given a threshold is provided for convenience.Before submitting
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.
📚 Documentation preview 📚: https://torchmetrics--2392.org.readthedocs.build/en/2392/