Skip to content

[MRG+1] more explicit error message when multiple scores passed #11008

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 6 commits into from
Apr 22, 2018
Merged

[MRG+1] more explicit error message when multiple scores passed #11008

merged 6 commits into from
Apr 22, 2018

Conversation

minggli
Copy link
Contributor

@minggli minggli commented Apr 22, 2018

Reference Issues/PRs

Fixes #11006. See also #3456.

What does this implement/fix? Explain your changes.

Add a more explicit message when one of below is passed to scoring= keyword in cross_val_score: list, set, tuple, dict. It prompts user to use cross_validate for multiple metrics evaluation.

Any other comments?

@rth
Copy link
Member

rth commented Apr 22, 2018

Thanks for the PR @minggli !

There is one test failing in test_fit_grid_point that used to check that providing a non scalar object as the scorer raises an exception (cee Appveyor CI log). You need to change the error message there.

@minggli
Copy link
Contributor Author

minggli commented Apr 22, 2018

thanks! fixed. 😀

@rth
Copy link
Member

rth commented Apr 22, 2018

LGTM.

@rth rth changed the title [MRG] more explicit error message when multiple scores passed [MRG+1] more explicit error message when multiple scores passed Apr 22, 2018
@@ -300,6 +300,10 @@ def check_scoring(estimator, scoring=None, allow_none=False):
"If no scoring is specified, the estimator passed should "
"have a 'score' method. The estimator %r does not."
% estimator)
elif isinstance(scoring, (list, tuple, set, dict)):
Copy link
Member

@glemaitre glemaitre Apr 22, 2018

Choose a reason for hiding this comment

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

Can be more permissive and ducktype:

from collections import Iterable

...
elif isinstance(scoring, Iterable):

...

@glemaitre
Copy link
Member

And add an entry in the what's new as well.

@@ -204,6 +204,10 @@ Model evaluation and meta-estimators
return estimators fitted on each split. :issue:`9686` by :user:`Aurélien Bellet
<bellet>`.

- Add improved error message in :func:`model_selection.cross_val_score` when
Copy link
Member

Choose a reason for hiding this comment

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

This should be in the Bug Fixes section instead

@glemaitre glemaitre merged commit 7124d87 into scikit-learn:master Apr 22, 2018
@glemaitre
Copy link
Member

LGTM

@glemaitre
Copy link
Member

Thanks @minggli

@minggli minggli deleted the error/cross_val_score branch April 22, 2018 12:16
@minggli
Copy link
Contributor Author

minggli commented Apr 22, 2018

happy to contribute!

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.

cross_val_score handling of multiple metrics
3 participants