Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MRG + 1] FIX Calling fit_transform instead of transform in Pipeline's fit_predict #7585

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

Merged
merged 3 commits into from
Oct 6, 2016

Conversation

gszpak
Copy link
Contributor

@gszpak gszpak commented Oct 5, 2016

Reference Issue

This PR fixes issue #7558.

What does this implement/fix? Explain your changes.

As discussed in #7558, each transformer in pipeline should call fit_transform instead of transform in fit_predict. test_fix_predict_on_pipeline is also fixed.

@amueller
Copy link
Member

amueller commented Oct 5, 2016

thanks, lgtm :)

Copy link
Member

@amueller amueller left a comment

Choose a reason for hiding this comment

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

pep8 ;)


# first compute the transform and clustering step separately
scaled = scaler.fit_transform(iris.data)
separate_pred = km.fit_predict(scaled)

# use a pipeline to do the transform and clustering in one step
pipe = Pipeline([('scaler', scaler), ('Kmeans', km)])
pipe = Pipeline([('scaler', scaler_for_pipeline), ('Kmeans', km_for_pipeline)])
Copy link
Member

Choose a reason for hiding this comment

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

this line's too long now :)

@amueller amueller changed the title [MRG] FIX Calling fit_transform instead of transform in Pipeline's fit_predict [MRG + 1] FIX Calling fit_transform instead of transform in Pipeline's fit_predict Oct 5, 2016
@amueller
Copy link
Member

amueller commented Oct 5, 2016

thanks!

@jnothman jnothman added this to the 0.18.1 milestone Oct 5, 2016
@jnothman
Copy link
Member

jnothman commented Oct 5, 2016

This is actually fixing a regression, and an error on my part :( Tagging with 0.18.1 for backport. Almost LGTM.

@jnothman jnothman added the Bug label Oct 5, 2016
@@ -277,14 +277,19 @@ def test_fit_predict_on_pipeline():
# transform and clustering steps separately
iris = load_iris()
scaler = StandardScaler()
scaler_for_pipeline = StandardScaler()
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment that this is necessary since Pipeline does not clone the estimators.

@jnothman
Copy link
Member

jnothman commented Oct 6, 2016

LGTM, thanks

@jnothman jnothman merged commit 0a1f6cd into scikit-learn:master Oct 6, 2016
@gszpak gszpak deleted the fix_pipeline_fit_predict branch October 7, 2016 09:45
amueller pushed a commit to amueller/scikit-learn that referenced this pull request Oct 14, 2016
…t_predict (scikit-learn#7585)

* BUGFIX Calling fit_transform instead of transform in Pipeline's fit_predict (scikit-learn#7558)

* PEP8 fixes in test_fit_predict_on_pipeline

* Added comment explaining separate estimators for pipeline in test_fit_predict_on_pipeline
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this pull request Jun 14, 2017
…t_predict (scikit-learn#7585)

* BUGFIX Calling fit_transform instead of transform in Pipeline's fit_predict (scikit-learn#7558)

* PEP8 fixes in test_fit_predict_on_pipeline

* Added comment explaining separate estimators for pipeline in test_fit_predict_on_pipeline
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
…t_predict (scikit-learn#7585)

* BUGFIX Calling fit_transform instead of transform in Pipeline's fit_predict (scikit-learn#7558)

* PEP8 fixes in test_fit_predict_on_pipeline

* Added comment explaining separate estimators for pipeline in test_fit_predict_on_pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants