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

Rework of Sklearn Metrics #1327

Merged
merged 44 commits into from Jun 10, 2020
Merged

Rework of Sklearn Metrics #1327

merged 44 commits into from Jun 10, 2020

Conversation

justusschock
Copy link
Member

@justusschock justusschock commented Apr 1, 2020

What does this PR do?

Fixes #1305 and is a rework of #1320 based on #1326
Fixes #1295
Fixes #1296
Fixes #1302

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 🙃

@justusschock justusschock added feature Is an improvement or enhancement help wanted Open to be worked on labels Apr 1, 2020
@justusschock justusschock self-assigned this Apr 1, 2020
@justusschock justusschock added this to in Progress in Metrics package via automation Apr 1, 2020
@pep8speaks
Copy link

pep8speaks commented Apr 1, 2020

Hello @justusschock! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-06-09 22:46:37 UTC

@mergify mergify bot requested a review from a team April 1, 2020 15:05
@Borda Borda requested a review from a team April 3, 2020 08:06
@Borda Borda added this to the 0.8.0 milestone Apr 3, 2020
environment.yml Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team April 17, 2020 15:56
@justusschock justusschock mentioned this pull request Apr 27, 2020
@justusschock justusschock marked this pull request as ready for review April 28, 2020 07:32
Metrics package automation moved this from in Progress to Done May 5, 2020
@mergify
Copy link
Contributor

mergify bot commented May 5, 2020

This pull request is now in conflict... :(

@Borda
Copy link
Member

Borda commented May 5, 2020

@williamFalcon why did you close the metrics PR? @justusschock?

@Borda Borda reopened this May 5, 2020
Metrics package automation moved this from Done to in Review May 5, 2020
@mergify
Copy link
Contributor

mergify bot commented May 18, 2020

This pull request is now in conflict... :(

@justusschock justusschock changed the base branch from metrics to master May 19, 2020 15:23
@justusschock
Copy link
Member Author

@Borda any idea, why scipy building fails?

@Borda Borda requested a review from jeremyjordan May 25, 2020 16:23
@mergify mergify bot requested a review from a team May 25, 2020 19:30
@Borda
Copy link
Member

Borda commented May 25, 2020

@justusschock there is also problem with installing the minimal requirements, mind check?
@awaelchli will check the docs, thx

@awaelchli
Copy link
Member

I'm done fixing the docs errors but can't push, permission denied. Is it a setting on this branch?
Otherwise please merge this branch
https://github.com/awaelchli/pytorch-lightning/tree/new_sklearn_metric

@Borda Borda removed the help wanted Open to be worked on label Jun 9, 2020
Copy link
Contributor

@tullie tullie left a comment

Choose a reason for hiding this comment

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

This is looking really good, just one question about the forward implementations before I accept!

Accuracy Score

"""
return super().forward(y_pred=y_pred, y_true=y_true, sample_weight=sample_weight)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need any of these forward functions in this file? It seems like you're implementing what inheritance will already do, i.e. call the superfunction if it's not overriden.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@tullie you're right. But the superfunction takes args and kwargs as arguments. I have explicitly implemented these for documentation and type hinting purposes. But we can also remove them.

But I simply dod not find a better solution to document these arguments

pytorch_lightning/metrics/utils.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #1327 into master will decrease coverage by 0%.
The diff coverage is 74%.

@@           Coverage Diff           @@
##           master   #1327    +/-   ##
=======================================
- Coverage      86%     86%    -0%     
=======================================
  Files          75      78     +3     
  Lines        4788    4917   +129     
=======================================
+ Hits         4134    4229    +95     
- Misses        654     688    +34     

@mergify mergify bot requested a review from a team June 9, 2020 22:31
Co-authored-by: Tullie Murrell <tulliemurrell@gmail.com>
@Borda Borda requested a review from tullie June 10, 2020 08:42
Copy link
Contributor

@tullie tullie left a comment

Choose a reason for hiding this comment

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

Cool makes sense with the forward functions

@Borda Borda merged commit bd49b07 into master Jun 10, 2020
Metrics package automation moved this from in Review to Done Jun 10, 2020
@Borda Borda deleted the new_sklearn_metric branch June 10, 2020 13:43
Borda pushed a commit that referenced this pull request Jun 10, 2020
* Create utils.py

* Create __init__.py

* redo sklearn metrics

* add some more metrics

* add sklearn metrics

* Create __init__.py

* redo sklearn metrics

* New metric classes (#1326)

* Create metrics package

* Create metric.py

* Create utils.py

* Create __init__.py

* add tests for metric utils

* add docstrings for metrics utils

* add function to recursively apply other function to collection

* add tests for this function

* update test

* Update pytorch_lightning/metrics/metric.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* update metric name

* remove example docs

* fix tests

* add metric tests

* fix to tensor conversion

* fix apply to collection

* Update CHANGELOG.md

* Update pytorch_lightning/metrics/metric.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* remove tests from init

* add missing type annotations

* rename utils to convertors

* Create metrics.rst

* Update index.rst

* Update index.rst

* Update pytorch_lightning/metrics/convertors.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* Update pytorch_lightning/metrics/convertors.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* add doctest example

* rename file and fix imports

* added parametrized test

* replace lambda with inlined function

* rename apply_to_collection to apply_func

* Separated class description from init args

* Apply suggestions from code review

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* adjust random values

* suppress output when seeding

* remove gpu from doctest

* Add requested changes and add ellipsis for doctest

* forgot to push these files...

* add explicit check for dtype to convert to

* fix ddp tests

* remove explicit ddp destruction

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>

* add sklearn metrics

* start adding sklearn tests

* fix typo

* return x and y only for curves

* fix typo

* add missing tests for sklearn funcs

* imports

* __all__

* imports

* fix sklearn arguments

* fix imports

* update requirements

* Update CHANGELOG.md

* Update test_sklearn_metrics.py

* formatting

* formatting

* format

* fix all warnings and formatting problems

* Update environment.yml

* Update requirements-extra.txt

* Update environment.yml

* Update requirements-extra.txt

* fix all warnings and formatting problems

* Update CHANGELOG.md

* docs

* inherit

* docs inherit.

* docs

* Apply suggestions from code review

Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>

* docs

* req

* min

* Apply suggestions from code review

Co-authored-by: Tullie Murrell <tulliemurrell@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka <jirka@pytorchlightning.ai>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
Co-authored-by: Tullie Murrell <tulliemurrell@gmail.com>
(cherry picked from commit bd49b07)
@Borda Borda mentioned this pull request Jun 10, 2020
8 tasks
justusschock added a commit that referenced this pull request Jun 29, 2020
* Create utils.py

* Create __init__.py

* redo sklearn metrics

* add some more metrics

* add sklearn metrics

* Create __init__.py

* redo sklearn metrics

* New metric classes (#1326)

* Create metrics package

* Create metric.py

* Create utils.py

* Create __init__.py

* add tests for metric utils

* add docstrings for metrics utils

* add function to recursively apply other function to collection

* add tests for this function

* update test

* Update pytorch_lightning/metrics/metric.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* update metric name

* remove example docs

* fix tests

* add metric tests

* fix to tensor conversion

* fix apply to collection

* Update CHANGELOG.md

* Update pytorch_lightning/metrics/metric.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* remove tests from init

* add missing type annotations

* rename utils to convertors

* Create metrics.rst

* Update index.rst

* Update index.rst

* Update pytorch_lightning/metrics/convertors.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* Update pytorch_lightning/metrics/convertors.py

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* add doctest example

* rename file and fix imports

* added parametrized test

* replace lambda with inlined function

* rename apply_to_collection to apply_func

* Separated class description from init args

* Apply suggestions from code review

Co-Authored-By: Jirka Borovec <Borda@users.noreply.github.com>

* adjust random values

* suppress output when seeding

* remove gpu from doctest

* Add requested changes and add ellipsis for doctest

* forgot to push these files...

* add explicit check for dtype to convert to

* fix ddp tests

* remove explicit ddp destruction

Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>

* add sklearn metrics

* start adding sklearn tests

* fix typo

* return x and y only for curves

* fix typo

* add missing tests for sklearn funcs

* imports

* __all__

* imports

* fix sklearn arguments

* fix imports

* update requirements

* Update CHANGELOG.md

* Update test_sklearn_metrics.py

* formatting

* formatting

* format

* fix all warnings and formatting problems

* Update environment.yml

* Update requirements-extra.txt

* Update environment.yml

* Update requirements-extra.txt

* fix all warnings and formatting problems

* Update CHANGELOG.md

* docs

* inherit

* docs inherit.

* docs

* Apply suggestions from code review

Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>

* docs

* req

* min

* Apply suggestions from code review

Co-authored-by: Tullie Murrell <tulliemurrell@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Jirka <jirka@pytorchlightning.ai>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: Nicki Skafte <skaftenicki@gmail.com>
Co-authored-by: Tullie Murrell <tulliemurrell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Is an improvement or enhancement ready PRs ready to be merged
Projects
No open projects
9 participants