Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[MRG+1] Change named_steps to Bunch object #8586
What does this implement/fix? Explain your changes.
This PR changes
Any other comments?
> clf = svm.SVC(kernel='linear') > anova_svm = Pipeline([('anova', anova_filter), ('svc', clf)]) > anova_svm.named_steps.anova SelectKBest(k=5, score_func=<function f_regression at 0x7f1d984d8620>)
@@ Coverage Diff @@ ## master #8586 +/- ## ========================================== + Coverage 95.49% 95.49% +<.01% ========================================== Files 342 342 Lines 61072 61088 +16 ========================================== + Hits 58318 58334 +16 Misses 2754 2754
To be sure, correct behaviour would be to provide dict's keys method, even if a step is named 'keys'. We can't just break the existing dict behaviour. Nor can we accept an error if a user chooses keys for a step name; they just don't get the new functionality.…
On 23 Mar 2017 7:20 am, "RAKOTOARISON Herilalaina" ***@***.***> wrote: Hi @jnothman <https://github.com/jnothman> @lesteve <https://github.com/lesteve> , thank you for your comment. Actually, the Bunch object didn't work when step names conflict with attribute of dict like values, items .. So I decide to override __getattribute__ on Bunch class. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#8586 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAEz6xqn2JCmA-Mv9RYXAp9dKM8wxrCRks5roYKCgaJpZM4MdNFz> .
To confirm what you said. I will remove the
pipeline = Pipeline([('values', transf), ("items", mult2)]) assert_true(pipeline.named_steps.values is not transf) assert_true(pipeline.named_steps.items is not mult2)
I still think this deserves a brief mention in
doc/modules/pipeline.rst, where it says "and as a dict in named_steps", with something like:
Attributes of named_steps map to keys, enabling tab completion in interactive environments: >>> pipe.named_steps.reduce_dim is pipe.named_steps['reduce_dim'] True
Otherwise LGTM. Please add an entry to what's new.