You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Common test to check that estimator state does not change at transform/predict/predict_proba time #7297
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.
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.
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.
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
Activity
amueller commentedon Aug 30, 2016
Sorry, I didn't follow #6607 closely. Only in
fitas opposed to what?transformin this case, I guess. We already check that nothing happens in__init__in several ways.If you call
transformbefore calling fit, you usually get anNotFittedErrorbut there are some "stateless transformers" like theHashingVectorizerand theChi2Samplerthat don't requirefit.These could be checked by comparing the dict before and after
transform. Nothing should change.transformneeds to not change the estimator.Or is the question more "after fitting, make sure that
transformdoesn't modify the estimator"?Again, we could copy the dict and check that it's the same? All things should be
isidentical. If a reference changed, we messed up.MechCoder commentedon Aug 30, 2016
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.[-]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[/+]MechCoder commentedon Aug 30, 2016
I've updated the issue description.
kiote commentedon Sep 18, 2016
I'd like to handle this, but bear in mind I'm a total noob in the internals of sc-learn 😷
MechCoder commentedon Sep 22, 2016
Sure, thanks! I'm removing the Need Contributor label.
kiote commentedon Sep 27, 2016
sorry, have a tough days at work, but hope to continue here soon
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (#…
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (s…
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (s…
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (s…
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (s…
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (s…
[MRG] TST Ensure __dict__ is unmodified by predict, transform, etc (s…
rth commentedon Jun 21, 2019
Fixed in #7553