Skip to content

Pipeline should use fit_transform in fit_predict #7558

Closed

Description

@gszpak

Description

Pipeline's fit_predict implementation is inconsistent with docstring. According to docstring, each
step should call fit_transform, but it calls only transform instead.

Activity

  1. amueller commented on Oct 3, 2016

    @amueller
    Member

    wow this is a pretty bad bug. Is fit_predict not tested?

  2. gszpak commented on Oct 3, 2016

    @gszpak
    ContributorAuthor

    It is here, but not properly in my opinion.
    Pipeline object in this test uses the same scaler object that was used earlier to calculate expected result. Therefore this call of check_is_fitted doesn't fail and the test passes.

  3. amueller commented on Oct 3, 2016

    @amueller
    Member

    Do you want to fix this, and the test?

    Hm @jnothman I am somewhat confused. I thought we'd be cloning estimators on pipeline construction. Was it a deliberate choice not to clone when we set the steps?

  4. gszpak commented on Oct 3, 2016

    @gszpak
    ContributorAuthor

    Sure, I'll fix both.

  5. jnothman commented on Oct 4, 2016

    @jnothman
    Member

    I don't think you should fix the lack of cloning. @amueller, I consider this to be among Pipeline's "legacy" behaviour. It's been around for a long time and we'll break lots of code by changing its behaviour. Pipeline also modifies a constructor param in fit rather than setting a new _-trailed attr.

    Yes, fix fit_predict.

  6. amueller commented on Oct 5, 2016

    @amueller
    Member

    Ugh I should remember that. Should we add that to the docs somewhere?

  7. jnothman commented on Oct 5, 2016

    @jnothman
    Member

    Should we add that to the docs somewhere?

    Perhaps we should document it; perhaps we should ensure it's tested; and it should at least be commented.

  8. gszpak commented on Oct 6, 2016

    @gszpak
    ContributorAuthor

    I can add it to test_pipeline_init (or add a separate test) if you don't mind.

  9. jnothman commented on Oct 6, 2016

    @jnothman
    Member

    Perhaps as a separate PR. I'd rather merge the fix first.

  10. jnothman commented on Oct 6, 2016

    @jnothman
    Member

    Thanks for catching and fixing this, @gszpak

  11. amueller commented on Oct 7, 2016

    @amueller
    Member

    @gszpak if you like you can open an issue and/or PR for the tests and doc. That would be much appreciated.

  12. gszpak commented on Oct 9, 2016

    @gszpak
    ContributorAuthor

    Sure, will do:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions