API Deprecates the fit_grid_point function - #16401
Conversation
thomasjpfan
left a comment
There was a problem hiding this comment.
This needs a test to make sure the deprecation is raised with the expected message.
There was a problem hiding this comment.
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.
|
thomasjpfan
left a comment
There was a problem hiding this comment.
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.
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.
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.
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, ...):
...
thomasjpfan
left a comment
There was a problem hiding this comment.
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.
Nit:
| train, test = next(cv.split(X, y)) | |
| train, test = next(StratifiedKFold().split(X, y)) |
and remove the cv definition above.
| train, test = next(cv.split(X, y)) | ||
|
|
||
| with pytest.warns(FutureWarning, match=msg): | ||
| fit_grid_point( |
There was a problem hiding this comment.
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.
Nit: No new line needed
| msg = ( | |
| msg = ("fit_grid_point is deprecated in version 0.23 " | |
| "and will be removed in version 0.25") |
|
|
||
| .. autosummary:: | ||
| :toctree: generated/ | ||
| :template: deprecated_function.rst |
There was a problem hiding this comment.
.. 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.
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_pointfunction because it is not used anywhere except testAny other comments?