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

add SklearnCallback as integration with sklearn metrics #1198

Merged
merged 17 commits into from May 31, 2021

Conversation

y-ksenia
Copy link
Contributor

@y-ksenia y-ksenia commented Apr 29, 2021

Before submitting (checklist)

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contribution guide?
  • Did you check the code style? catalyst-make-codestyle && catalyst-check-codestyle (pip install -U catalyst-codestyle).
  • Did you make sure to update the docs? We use Google format for all the methods and classes.
  • Did you check the docs with make check-docs?
  • Did you write any new necessary tests?
  • Did you check that your code passes the unit tests pytest . ?
  • Did you add your new functionality to the docs?
  • Did you update the CHANGELOG?
  • Did you run colab minimal CI/CD with latest and minimal requirements?

Description

Work on #1183

Related Issue

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

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.

FAQ

Please review the FAQ before submitting an issue:

@y-ksenia y-ksenia changed the title added SklearnCallback as integration with sklearn metrics add SklearnCallback as integration with sklearn metrics Apr 29, 2021
Copy link
Member

@Scitator Scitator 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 please integrate the Callback to a minimal example to check the performance?

catalyst/callbacks/metrics/sklearn.py Outdated Show resolved Hide resolved
from catalyst.metrics import FunctionalBatchMetric


class SklearnCallback(FunctionalBatchMetricCallback):
Copy link
Member

Choose a reason for hiding this comment

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

is it possible to also add loader-based sklearn metrics into the separate Callback?
we could not compute AUCs in per-batch mode

Copy link
Member

Choose a reason for hiding this comment

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

nevertheless, we could just filter the loader-based metrics during metric_fn check for now
to simplify the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should I filter by name?.. or how?

catalyst/callbacks/metrics/__init__.py Outdated Show resolved Hide resolved
catalyst/callbacks/metrics/scikit_learn.py Outdated Show resolved Hide resolved
@ditwoo
Copy link
Contributor

ditwoo commented May 13, 2021

@y-ksenia btw you can test SklearnCallback emulating experiment flow (without executing the whole experiment).

Copy link
Member

@Scitator Scitator 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 please also update Config API example with extra SklearnCallback?

Comment on lines 132 to 141
callbacks["f1_score"] = dl.SklearnCallback(
keys={
"y_pred": "labels",
"y_true": "targets",
"average": "micro",
"zero_division": 1,
},
metric_fn="f1_score",
metric_key="f1_score",
)
Copy link
Member

Choose a reason for hiding this comment

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

could you please add this example to the callbacks docs? it's very interesting, that you could also pass metrics **kwargs through the keys

@mergify
Copy link

mergify bot commented May 18, 2021

This pull request is now in conflicts. @y-ksenia, could you fix it? 🙏

@pep8speaks
Copy link

pep8speaks commented May 26, 2021

Hello @y-ksenia! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

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

Comment last updated at 2021-05-30 20:39:17 UTC

@Scitator Scitator self-requested a review May 26, 2021 17:28
Scitator
Scitator previously approved these changes May 26, 2021
Copy link
Member

@Scitator Scitator left a comment

Choose a reason for hiding this comment

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

looks like only changelog.md update required :)

docs/api/callbacks.rst Outdated Show resolved Hide resolved
@mergify mergify bot dismissed Scitator’s stale review May 27, 2021 12:47

Pull request has been modified.

@mergify
Copy link

mergify bot commented May 30, 2021

This pull request is now in conflicts. @y-ksenia, could you fix it? 🙏

@Scitator Scitator changed the base branch from master to develop May 31, 2021 05:40
@Scitator Scitator merged commit 8bcf87d into catalyst-team:develop May 31, 2021
Scitator added a commit that referenced this pull request May 31, 2021
* Update CHANGELOG.md

* Add Registry to batch transform callback (#1209)

* add registry

* fix docs

* fix docs and codestyle. Add example

* fix line length :)

* add registry.py

* codestyle

* fix

* add partial and kwargs

* Fix data: imports (#1211)

* notebooks update v1

* notebooks update v2

* notebooks update v2

* notebooks update v2

* minimal RL

* minimal RL

* minimal RL 2

* rl update

* rl update

* demo update

* demo update

* demo update

* demo update

* tests update

* tests update

* import fix

* readme

* Change layerwise to layerwise_params (#1210)

* Change layerwise to layerwise_params (rus version)

At the old version was incorrect key layerwise to set lr, weight_decay and other params for different model layers.
Also add example how to add extra params to DataLoader

* Change layerwise to layerwise_params (eng version)

At the old version was incorrect key layerwise to set lr, weight_decay and other params for different model layers.
Also add example how to add extra params to DataLoader

* [WIP] faq docs (#1202)

* initial

* docs: engines initial

* docs: engines initial

* fix: python api; feature: config api example

* docs: reverted back

* docs: spelling; engine functions explained

* fix: note in changelog about faq docs

* Update CHANGELOG.md (#1216)

* fix: to_numpy wrapper for `AdditiveValueMetric` added (#1214)

* tests update + readme (#1215)

* tests update + readme

* readme

* workflows changed

* workflows

* readme

* Fix compute method (#1206)

* add DynamicBalanceClassSampler

* add DynamicBalanceClassSampler: add usage example

* add DynamicBalanceClassSampler: add tests

* Update catalyst/data/tests/test_sampler.py

* Update catalyst/data/tests/test_sampler.py

* add DynamicBalanceClassSampler: debag tests

* update sampler: add mode

* add example notebook

* sampler: fixes

* samler: docs

* DynamicBalanceClassSampler: fixes

* change import order

* change import order

* Fix compute problem

* Delete sampler

* Replace compute method

* Update segmentation tests

* Codestyle

* Add test for compute

* Add examples

Co-authored-by: Sergey Kolesnikov <scitator@gmail.com>

* Update ddt.rst (#1217)

Change in Case-3 code, Now running the code under name==__main__ (due to python's multiprocessing logic)

* docker update (#1218)

* docker update

* docker update

* docs update (#1219)

* Updated NeptuneLogger docstrings (#1223)

* fixed import in example, changed .ml -> .ai

* fixed long lines, added NeptuneLogger Callback

* fixed NeptuneLogger imports

* fixed newline formating

* fixed line length and import order

* fixed bad quotes

* fixed bad quotes

* vanilla impl [WIP]

* fixed hparams

* applied new structure to run

* corrected log image path

* added log_artifact to catalyst

* Updated log_artifact docstring

* simplified logger, added log artifact

* log to 'experiment' scope is scope is None

* fixed artifact logging

* better structure of the run

* code style adjustments

* added neptune requirements to the workflow

* typo fix

* dropped repetition in requirements

* codestyle fixes

* filename fix

* Corrected docstring to be 1-liner.

* Update catalyst/loggers/neptune.py

Co-authored-by: Sergey Kolesnikov <scitator@gmail.com>

* Final touches & test fixes

* Checkstyle fixes

* Missed code style

* Revert stop to wait

* Fix failing test

* Comment indentation

* fix tests

* Fix

* Fix

* fix

* Fix

* Updated CHANGELOG and loggers docs

* Fix

* Update setup.py

Co-authored-by: Sergey Kolesnikov <scitator@gmail.com>

* updated neptune docstrings

* style fixed

* updated changelog

* typo fix

Co-authored-by: Jakub Czakon <czakon.jakub@gmail.com>
Co-authored-by: Sergey Kolesnikov <scitator@gmail.com>
Co-authored-by: Hubert Jaworski <hubert.jaworski@neptune.ai>
Co-authored-by: Marcin Mycek <herudaio@gmail.com>

* remove unnecessary thing

* Update catalyst/callbacks/batch_transform.py

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Sergey Kolesnikov <scitator@gmail.com>
Co-authored-by: MrNightSky <39031563+MrNightSky@users.noreply.github.com>
Co-authored-by: Dmytro Doroshenko <dimdoroshenko@gmail.com>
Co-authored-by: Yauheni Kachan <19803638+bagxi@users.noreply.github.com>
Co-authored-by: Dokholyan <37542142+Dokholyan@users.noreply.github.com>
Co-authored-by: Riyasat Ohib <riyasat.ohib@gmail.com>
Co-authored-by: Kamil A. Kaczmarek <kamil.kaczmarek@neptune.ml>
Co-authored-by: Jakub Czakon <czakon.jakub@gmail.com>
Co-authored-by: Hubert Jaworski <hubert.jaworski@neptune.ai>
Co-authored-by: Marcin Mycek <herudaio@gmail.com>

* add SklearnCallback as integration with sklearn metrics (#1198)

* added SklearnCallback as integration with sklearn metrics

* codestyle

* renamed script to exclude error in imports; added option to add params to sklearn score

* added import if sklearn is available in extensions

* added test

* docstrings

* updated docstring: added example for pass metrics kwargs as keys

* added note to callback

* added FunctionalLoaderMetric and SklearnLoaderCallback; modified the way of passing arguments into metric_fn

* codestyle fixes

* fixed test for new version of SklearnBatchCallback

* added __all__

* added classes to docs

* codestyle

* fixed docs; and small pep8-bugs

* updated changelog

* codestyle

* codestyle2

Co-authored-by: Nikita Balagansky <37884009+elephantmipt@users.noreply.github.com>
Co-authored-by: MrNightSky <39031563+MrNightSky@users.noreply.github.com>
Co-authored-by: Dmytro Doroshenko <dimdoroshenko@gmail.com>
Co-authored-by: Yauheni Kachan <19803638+bagxi@users.noreply.github.com>
Co-authored-by: Dokholyan <37542142+Dokholyan@users.noreply.github.com>
Co-authored-by: Riyasat Ohib <riyasat.ohib@gmail.com>
Co-authored-by: Kamil A. Kaczmarek <kamil.kaczmarek@neptune.ml>
Co-authored-by: Jakub Czakon <czakon.jakub@gmail.com>
Co-authored-by: Hubert Jaworski <hubert.jaworski@neptune.ai>
Co-authored-by: Marcin Mycek <herudaio@gmail.com>
Co-authored-by: Kseniia Iagafarova <xeniayagafarova@gmail.com>
@y-ksenia y-ksenia deleted the sklearn_callback branch June 1, 2021 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants