-
-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
API Deprecates the fit_grid_point function #16401
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.
This needs a test to make sure the deprecation is raised with the expected message.
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.
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.
Actually not completely good:
- the fit_grid_point is deprecated in version 0.23 and will be removed in 0.25
- there is a training whitespace that breaks the linter: https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=13337&view=logs&j=32e2e1bb-a28f-5b18-6cfc-3f01273f5609&t=f370d024-dfa6-536d-2b2d-766ea2a2900c
0.22 was already released. The next release will be 0.23.
|
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.
Add a comment above test_fit_grid_point
to remove it in 0.25.
We will squash your PR when it is merge. There is no need to push force push your changes.
with pytest.warns(FutureWarning, match=msg): | ||
for params in ({'C': 0.1}, {'C': 0.01}, {'C': 0.001}): | ||
for train, test in cv.split(X, y): | ||
this_scores, this_params, n_test_samples = fit_grid_point( |
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.
Move the pytest.warns
here to be specific where the warning comes from.
with pytest.warns(...):
this_scores, this_params, =
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.
It will also raise deprecation warning on this code
assert_raise_message(ValueError, "For evaluating multiple scores, use "
"sklearn.model_selection.cross_validate instead.",
fit_grid_point, X, y, svc, params, train, test,
{'score': scorer}, verbose=True)
and make the azure test pipeline failed
should I applied pytest.warns(FutureWarning, match=msg)
twice? (1 inside training loop and another before assert_raise_message
)
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.
Lets not change this test and ignore the FutureWarning
:
# FIXME Remove when fit_grid_point is deprecated in 0.25
@ignore_warnings(category=FutureWarning)
def test_fit_grid_point():
...
And add another tests that only tests the deprecation:
# FIXME Remove when fit_grid_point is deprecated in 0.25
def test_fit_grid_point_deprecated():
with pytest.warns(FutureWarning, ...):
...
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.
done
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/v0.23.rst
with tag API
. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
.
Also update doc/modules/classes.rst
and move model_selection.fit_grid_point
to the deprecated section.
"fit_grid_point is deprecated in version 0.23 " | ||
"and will be removed in version 0.25") | ||
params = {'C': 0.1} | ||
train, test = next(cv.split(X, y)) |
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.
Nit:
train, test = next(cv.split(X, y)) | |
train, test = next(StratifiedKFold().split(X, y)) |
and remove the cv definition above.
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.
done
train, test = next(cv.split(X, y)) | ||
|
||
with pytest.warns(FutureWarning, match=msg): | ||
fit_grid_point( |
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.
Nit: (fits in one line < 80)
fit_grid_point( | |
fit_grid_point(X, y, svc, params, train, test, scorer, verbose=False) |
cv = StratifiedKFold() | ||
svc = LinearSVC(random_state=0) | ||
scorer = make_scorer(accuracy_score) | ||
msg = ( |
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.
Nit: No new line needed
msg = ( | |
msg = ("fit_grid_point is deprecated in version 0.23 " | |
"and will be removed in version 0.25") |
doc/modules/classes.rst
Outdated
|
||
.. autosummary:: | ||
:toctree: generated/ | ||
:template: deprecated_function.rst |
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.
.. autosummary::
:toctree: generated/
:template: deprecated_function.rst
model_selection.fit_grid_point
utils.safe_indexing
svc = LinearSVC(random_state=0) | ||
scorer = make_scorer(accuracy_score) | ||
msg = ("fit_grid_point is deprecated in version 0.23 " | ||
"and will be removed in version 0.25") |
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.
Linting:
"and will be removed in version 0.25") | |
"and will be removed in version 0.25") |
Thank you @ariepratama ! |
sorry to give you headache when reviewing my codes @thomasjpfan |
Reference Issues/PRs
Fixes #16391
What does this implement/fix? Explain your changes.
Add deprecation notice to
fit_grid_point
function because it is not used anywhere except testAny other comments?