Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API get_scorer returns a copy and introduce get_scorer_names #22866

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 5 commits into from
Mar 19, 2022

Conversation

adrinjalali
Copy link
Member

@adrinjalali adrinjalali commented Mar 16, 2022

EDIT: This PR now introduces a new get_scorer_names, makes get_metric to return a copy, and deprecated SCORERS.

OLD:

This PR makes SCORERS[scorer_name] to return a copy rather than the original object. This also means get_scorer returns a copy each time.

cc @thomasjpfan @jnothman @glemaitre @lorentzenchr

Note that this is to be merged into main.

Closes #17942

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.

I'm happy with this approach.

I think this PR also resolves #17942

@jnothman
Copy link
Member

This makes the code of get_scorer less readable since the usual lookup semantics aren’t followed. At a minimum get_scorer needs an update to its docs and probably a comment.

Might also be worth reconsidering if this is too hacky and we would be better off deprecating SCORERS and adding get_scorer_names, providing less magic with a public/private distinction. I’m not sure to what extent users/ third parties update SCORERS.

@thomasjpfan
Copy link
Member

This makes the code of get_scorer less readable since the usual lookup semantics aren’t followed.

This is a valid point.

Might also be worth reconsidering if this is too hacky and we would be better off deprecating SCORERS and adding get_scorer_names, providing less magic with a public/private distinction.

I would greatly prefer adding a get_scorer_names and deprecate SCORERS.

@adrinjalali
Copy link
Member Author

Ok, I've introduced get_scorer_names here and deprecate SCORERS. This should make us happy now :)

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.

Thanks for the update. Title for the PR needs to be updated too.

@jnothman
Copy link
Member

classes.rst should also be updated

@adrinjalali adrinjalali changed the title MNT make SCORERS.__getitem__ return a copy API get_scorer returns a copy and introduce get_scorer_names Mar 18, 2022
Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM!

@adrinjalali
Copy link
Member Author

@jnothman happy to merge?

@jnothman
Copy link
Member

Ping @glemaitre

@jnothman jnothman closed this Mar 19, 2022
@adrinjalali
Copy link
Member Author

@jnothman did you mean to close or merge?

@jnothman jnothman reopened this Mar 19, 2022
@jnothman jnothman merged commit 7dc97a3 into scikit-learn:main Mar 19, 2022
@jnothman
Copy link
Member

To merge! :|

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.

Should get_scorer return a deep copy of the scorer object
4 participants