-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FEAT SLEP6: scorers #22757
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
FEAT SLEP6: scorers #22757
Conversation
CI is green. This is ready for review. |
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.
What a lousy review of mine, only docstring suggestions:blush:
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.
I'm happy if this is all I had to change 😝
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.
LGTM
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.
Should we add:
- a test for
_passthrough_scorer
where the estimator requests a score param? (Can we use a mock estimator and a generic test to avoid reinventing such tests for every simple router?) - documentation for implementing a custom scorer with a request here?
@@ -1140,3 +1144,34 @@ def test_scorer_no_op_multiclass_select_proba(): | |||
labels=lr.classes_, | |||
) | |||
scorer(lr, X_test, y_test) | |||
|
|||
|
|||
@pytest.mark.parametrize("name, scorer", SCORERS.items()) |
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.
do we really need to test them all? I suppose it's not expensive?
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.
yeah:
$ time pytest -x sklearn/metrics/tests/test_score_objects.py -k test_scorer_metadata_request
============================================================================ test session starts ============================================================================
platform linux -- Python 3.10.2, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/adrin/Projects/sklearn/scikit-learn, configfile: setup.cfg
plugins: xdist-2.5.0, typeguard-2.13.3, forked-1.4.0
collected 187 items / 135 deselected / 52 selected
sklearn/metrics/tests/test_score_objects.py .................................................... [100%]
==================================================================== 52 passed, 135 deselected in 0.17s =====================================================================
pytest -x sklearn/metrics/tests/test_score_objects.py -k 1.84s user 1.38s system 329% cpu 0.974 total
and most of that time is spent collecting the tests.
Thanks for that, it made me realize I think this is now ready for hopefully a final review. |
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.
Otherwise LGTM :)
@thomasjpfan shall we merge? |
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.
LGTM
This PR adds metadata routing methods to scorers.
It is a small and contained PR since it only touches scorers, and doesn't touch objects which use scorers. It only tests that putting a scorer which requests a metadata is correctly in routing.
Note: This PR is to be merged into the
sample-props
and not themain
branch.cc @jnothman @lorentzenchr @thomasjpfan