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

lightweight explained variance #68

Merged
merged 8 commits into from
Mar 15, 2021

Conversation

thomasgaudelet
Copy link
Contributor

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?

Propose a lightweight version of explained variance without storing all predictions and ground truth up to compute.

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
Copy link
Member

@thomasgaudelet could you please explain the intention behind this PR?

@thomasgaudelet
Copy link
Contributor Author

Sorry thought this was sufficient Propose a lightweight version of explained variance without storing all predictions and ground truth up to compute.

The issue with the current version of explained variance is that it stores all predictions and ground truths until the compute step (as shown by the RankZero warning). This is fine for small datasets but it doesn't scale. The PR replaces storing potentially large vectors with just tracking 5 sums. It's in a similar spirit to the current implementation of MSE and the likes.

@SkafteNicki
Copy link
Member

@thomasgaudelet, thanks for the extra explaination, great improvement :]
Could you please check the failing tests?

thomasgaudelet added 2 commits March 13, 2021 15:42
@codecov
Copy link

codecov bot commented Mar 13, 2021

Codecov Report

Merging #68 (ee45fb3) into master (179117b) will decrease coverage by 18.44%.
The diff coverage is 96.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #68       +/-   ##
===========================================
- Coverage   97.07%   78.62%   -18.45%     
===========================================
  Files         118       59       -59     
  Lines        3898     1951     -1947     
===========================================
- Hits         3784     1534     -2250     
- Misses        114      417      +303     
Flag Coverage Δ
Linux 78.62% <96.66%> (+0.07%) ⬆️
Windows 78.62% <96.66%> (+0.07%) ⬆️
cpu 78.62% <96.66%> (-18.45%) ⬇️
gpu ?
macOS 78.62% <96.66%> (-18.45%) ⬇️
pytest 78.62% <96.66%> (-18.45%) ⬇️
python3.6 ?
python3.8 ?
python3.9 ?
torch1.3.1 ?
torch1.4.0 ?
torch1.8.0 ?

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

Impacted Files Coverage Δ
...etrics/functional/regression/explained_variance.py 90.62% <94.11%> (-9.38%) ⬇️
torchmetrics/regression/explained_variance.py 96.00% <100.00%> (+0.34%) ⬆️
torchmetrics/utilities/distributed.py 38.23% <0.00%> (-58.83%) ⬇️
torchmetrics/classification/auc.py 45.00% <0.00%> (-55.00%) ⬇️
torchmetrics/functional/classification/auroc.py 45.90% <0.00%> (-39.35%) ⬇️
torchmetrics/metric.py 55.07% <0.00%> (-39.16%) ⬇️
torchmetrics/functional/regression/psnr.py 61.29% <0.00%> (-35.49%) ⬇️
...chmetrics/functional/classification/stat_scores.py 64.91% <0.00%> (-35.09%) ⬇️
torchmetrics/classification/checks.py 65.44% <0.00%> (-34.56%) ⬇️
torchmetrics/functional/classification/accuracy.py 66.66% <0.00%> (-33.34%) ⬇️
... and 81 more

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 179117b...ee45fb3. Read the comment docs.

@thomasgaudelet
Copy link
Contributor Author

@SkafteNicki done, there was a couple things mishandled but seems to pass all now

@Borda Borda added the enhancement New feature or request label Mar 13, 2021
Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

Could you also add entry under the Changed section in changelog?
Something like:
"Changed ExplainedVariance from storing all preds/targets to tracking 5 statistics..."

torchmetrics/regression/explained_variance.py Show resolved Hide resolved
Copy link
Member

@SkafteNicki SkafteNicki left a comment

Choose a reason for hiding this comment

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

LGTM

@SkafteNicki SkafteNicki enabled auto-merge (squash) March 14, 2021 08:27
@SkafteNicki SkafteNicki merged commit 8002ddc into Lightning-AI:master Mar 15, 2021
@Borda Borda added this to the 0.3 milestone Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants