- Notifications
You must be signed in to change notification settings - Fork 25.8k
ENH Raises warning when getting non-finite score in SearchCV#18266
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
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.
Please add an entry to the change log at doc/whats_new/v*.rst
. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
.
In addition to yourself, please add @Nirvan101@ArthurBook as contributors to this PR.
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Can you solve the linting issue: https://app.circleci.com/pipelines/github/scikit-learn/scikit-learn/7266/workflows/6e341ac6-b7dc-498a-9133-59690fcef076/jobs/118045
|
@glemaitre, thanks for the review. I've resolved the linting issues. |
@@ -26,6 +26,7 @@ | |||
from scipy.stats import bernoulli, expon, uniform | |||
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.
You don't need this extra return line
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.
Just 2 small fixes otherwise LGTM.
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
@thomasjpfan@adrinjalali Do you want to have a look? |
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 @subrat93 !
@@ -1750,6 +1750,43 @@ def get_n_splits(self, *args, **kw): | |||
ridge.fit(X[:train_size], y[:train_size]) | |||
@pytest.mark.parametrize("return_train_score", [False, True]) | |||
def test_gridsearchcv_raise_warning_with_non_finite_score(return_train_score): |
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.
We can also check for RandomSearchCV
here as well:
@pytest.mark.parametrize("return_train_score", [False, True])@pytest.mark.parametrize("SearchCV, specialized_params", [(GridSearchCV, {"param_grid": {"max_depth": [2, 3]}}), (RandomizedSearchCV, {"param_distributions": {"max_depth": [2, 3]}, "n_iter": 2})])deftest_searchcv_raise_warning_with_non_finite_score( SearchCV, specialized_params, return_train_score): ... grid=SearchCV( DecisionTreeClassifier(), scoring=FailingScorer(), cv=3, return_train_score=return_train_score, **specialized_params )
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
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 Thank you @subrat93 !
Thanks @subrat93 |
Thanks a lot @glemaitre and @thomasjpfan for your support!! I look forward to contributing more. |
…learn#18266) Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
Fixes#10529
Supersedes and closes#10546
Supersedes and closes#15469
What does this implement/fix? Explain your changes.
The fix checks for the presence of any inf/-inf values in the mean score calculated after GridSearchCV.
If yes, it raises a warning - "One or more of the test scores are infinite"
Any other comments?