10000 FEAT SLEP6: scorers by adrinjalali · Pull Request #22757 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 17 commits into from
Mar 24, 2022
Merged

Conversation

adrinjalali
Copy link
Member

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 the main branch.

cc @jnothman @lorentzenchr @thomasjpfan

@adrinjalali
Copy link
Member Author

CI is green. This is ready for review.

@adrinjalali adrinjalali added this to the 1.1 milestone Mar 11, 2022
@adrinjalali adrinjalali added Waiting for Reviewer High Priority High priority issues and pull requests labels Mar 11, 2022
Copy link
Member
@lorentzenchr lorentzenchr left a 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:

Copy link
Member Author
@adrinjalali adrinjalali left a 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 😝

Copy link
Member
@lorentzenchr lorentzenchr left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member
@jnothman jnothman left a 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())
Copy link
Member

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?

Copy link
Member Author

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.

@adrinjalali
Copy link
Member Author
  • 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?)

Thanks for that, it made me realize _passthrough_scorer is not actually a router and that its implementation should rather be special. I've updated the routing there and test the implementation now. Since it's not a normal case, I've left the common test you mention for later.

I think this is now ready for hopefully a final review.

Copy link
Member
@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM :)

@adrinjalali
Copy link
Member Author

@thomasjpfan shall we merge?

Copy link
Member
@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan merged commit c963068 into scikit-learn:sample-props Mar 24, 2022
@adrinjalali adrinjalali deleted the slep6-scorers branch March 24, 2022 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0