-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
FIX cross_validate
with multimetric scoring returns the non-failed scorers results if there is a failing scorer
#23101
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
FIX cross_validate
with multimetric scoring returns the non-failed scorers results if there is a failing scorer
#23101
Conversation
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.
Thank you for the PR!
Do we need a test for the one-failing scorer case for the cross_validate function?
Yes we need to test the new behavior. One as a non-regression test for cross_validate
and another one for _MultimetricScorer
itself.
Note: Changing the behavior of _MultimetricScorer
to not raise anymore may require updating some unit tests. This is okay since _MultimetricScorer
is a private class.
…one to the new parts.
…ssage will show up there.
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.
Thanks for the update!
This PR still requires a non-regression test for the original issue and test to test the behavior of _MultimetricScorer
returning a dictionary with exceptions.
…O: a non-regression test for the original issue.
…n-failing multimetric case.
Updated the |
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.
Please add an entry to the change log at doc/whats_new/v1.1.rst
with tag |Fix|. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
.
…s is controlled by the new bool parameter. The _score function is changed accordingly. The test for the _MultimetricScorer which tested the exception returning case is replaced with the test_multimetric_scorer_exception_handling test. The test_cross_validate_failing_scorer function needs no modification.
…itional (dict) instead of a depacked dict using **.
…oss_validate_failing_scorer: checking for '_score_2' instead of 'score_2'.
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.
Thanks for the update. I'm mostly okay with using a string to send the exception information back to the caller. Note other reviewers, may have a different opinion on the matter.
@thomasjpfan I do not understand the failing test. Do you know what is the issue there? |
Merging with |
@thomasjpfan how do you see, do we need any more modification to the changes? |
Assuming you ran this to set the remote url: git remote add upstream [email protected]:scikit-learn/scikit-learn.git you can update this PR to fix the circleci issue: git checkout cross_validate__with_multiple_scorer_nan_issue
git fetch upstream
git merge upstream/main |
…h_multiple_scorer_nan_issue
Thank you, it wokred! |
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.
Thank you for the update! I am mostly on board with this. Let's see what other reviewers think.
if self._raise_exc: | ||
raise e | ||
else: | ||
scores[name] = format_exc() |
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.
For future reviewers, a string is used to pass the information back to the caller.
@thomasjpfan could you please mark this as "waiting 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.
Since the changes that I requested are only about style, I merged them directly and put my +1.
I will merge when the CI turns green. Thanks @simonandras
…scorers results even if some fail (scikit-learn#23101) Co-authored-by: Guillaume Lemaitre <[email protected]>
…scorers results even if some fail (scikit-learn#23101) Co-authored-by: Guillaume Lemaitre <[email protected]>
…scorers results even if some fail (scikit-learn#23101) Co-authored-by: Guillaume Lemaitre <[email protected]>
…scorers results even if some fail (scikit-learn#23101) Co-authored-by: Guillaume Lemaitre <[email protected]>
…scorers results even if some fail (#23101) Co-authored-by: Guillaume Lemaitre <[email protected]>
Reference Issues/PRs
Fixes #22969.
What does this implement/fix? Explain your changes.
In
_scorer.py
in the_MultimetricScorer
class the__call__
method is updated. Now instead of raising an exception of a failing scorer it passes the exception to thescores
to handle later.In
_validation.py
in the_score
function the exception is handled at the line 789, based on the suggestion of @thomasjpfan.Any other comments?
Do we need a test for the one-failing scorer case for the
cross_validate
function?