Skip to content

Common test to check that estimator state does not change at transform/predict/predict_proba time #7297

Closed

Description

@MechCoder

Description

I feel the design of #6607 could have been better thought of, if we had a common test that tests that learning happens only during fit time. We should check __dict__ after fit and after transform and their state should not change.

Activity

  1. amueller commented on Aug 30, 2016

    @amueller
    Member

    Sorry, I didn't follow #6607 closely. Only in fit as opposed to what? transform in this case, I guess. We already check that nothing happens in __init__ in several ways.

    If you call transform before calling fit, you usually get an NotFittedError but there are some "stateless transformers" like the HashingVectorizer and the Chi2Sampler that don't require fit.
    These could be checked by comparing the dict before and after transform. Nothing should change. transform needs to not change the estimator.

    Or is the question more "after fitting, make sure that transform doesn't modify the estimator"?
    Again, we could copy the dict and check that it's the same? All things should be is identical. If a reference changed, we messed up.

  2. MechCoder commented on Aug 30, 2016

    @MechCoder
    MemberAuthor

    These could be checked by comparing the dict before and after transform.

    Sure, that is what I meant (and maybe predict and predict_proba to do a sanity check). The problem in #6607 was we set the attribute indicator_features_ during transform time.

  3. changed the title [-]Common test to check that learning happens only during fit time.[/-] [+]Common test to check that estimator state does not change at transform/predict/predict_proba time[/+] on Aug 30, 2016
  4. MechCoder commented on Aug 30, 2016

    @MechCoder
    MemberAuthor

    I've updated the issue description.

  5. kiote commented on Sep 18, 2016

    @kiote
    Contributor

    I'd like to handle this, but bear in mind I'm a total noob in the internals of sc-learn 😷

  6. MechCoder commented on Sep 22, 2016

    @MechCoder
    MemberAuthor

    Sure, thanks! I'm removing the Need Contributor label.

  7. kiote commented on Sep 27, 2016

    @kiote
    Contributor

    sorry, have a tough days at work, but hope to continue here soon

  8. rth commented on Jun 21, 2019

    @rth
    Member

    Fixed in #7553

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions