Skip to content

API Deprecates the fit_grid_point function - #16401

Merged
thomasjpfan merged 14 commits into
scikit-learn:masterfrom
ariepratama:fix_16391
Feb 14, 2020
Merged

API Deprecates the fit_grid_point function#16401
thomasjpfan merged 14 commits into
scikit-learn:masterfrom
ariepratama:fix_16391

Conversation

@ariepratama

Copy link
Copy Markdown
Contributor

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 test

Any other comments?

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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.

Comment thread sklearn/model_selection/_search.py Outdated

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually not completely good:

0.22 was already released. The next release will be 0.23.

@ariepratama

Copy link
Copy Markdown
Contributor Author

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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(

Copy link
Copy Markdown
Member

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, =

@ariepratama ariepratama Feb 10, 2020

Copy link
Copy Markdown
Contributor Author

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)

Copy link
Copy Markdown
Member

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, ...):
		...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
train, test = next(cv.split(X, y))
train, test = next(StratifiedKFold().split(X, y))

and remove the cv definition above.

Copy link
Copy Markdown
Contributor Author

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(

Copy link
Copy Markdown
Member

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)

Suggested change
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 = (

Copy link
Copy Markdown
Member

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

Suggested change
msg = (
msg = ("fit_grid_point is deprecated in version 0.23 "
"and will be removed in version 0.25")

Comment thread doc/modules/classes.rst Outdated

.. autosummary::
:toctree: generated/
:template: deprecated_function.rst

Copy link
Copy Markdown
Member

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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Linting:

Suggested change
"and will be removed in version 0.25")
"and will be removed in version 0.25")

@thomasjpfan thomasjpfan changed the title FIX add deprecation to function fit_grid_point API Deprecates the fit_grid_point function Feb 14, 2020
@thomasjpfan
thomasjpfan merged commit c2e742c into scikit-learn:master Feb 14, 2020
@thomasjpfan

Copy link
Copy Markdown
Member

Thank you @ariepratama !

@ariepratama

Copy link
Copy Markdown
Contributor Author

sorry to give you headache when reviewing my codes @thomasjpfan

thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Feb 22, 2020
panpiort8 pushed a commit to panpiort8/scikit-learn that referenced this pull request Mar 3, 2020
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.

Is model_selection.fit_grid_point useful?

3 participants