-
-
Notifications
You must be signed in to change notification settings - Fork 26k
Reduce iteration over steps in _sk_visual_block_
#29022
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
Conversation
_sk_visual_block_
_sk_visual_block_
sklearn/pipeline.py
Outdated
name_details = [str(est) for est in estimators] | ||
return _VisualBlock( | ||
"serial", | ||
estimators, | ||
names=names, | ||
names=list(names), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to add this partially undid the idea of removing one loop. 🤷 While I still think the refactor is an ever-so-slight improvement, I'm OK if want to close it, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. WDYT @Charlie-XIAO
I'm wondering why |
@adrinjalali thanks for the review, and @Charlie-XIAO sorry I missed your question!
To be honest, it's been so long that I forgot (and obviously I didn't explain it properly in my comment...), but looking at the CI failure, I think it's because of this: def test_get_visual_block_pipeline():
pipe = Pipeline(
[
("imputer", SimpleImputer()),
("do_nothing", "passthrough"),
("do_nothing_more", None),
("classifier", LogisticRegression()),
]
)
est_html_info = _get_visual_block(pipe)
assert est_html_info.kind == "serial"
assert est_html_info.estimators == tuple(step[1] for step in pipe.steps)
> assert est_html_info.names == [
"imputer: SimpleImputer",
"do_nothing: passthrough",
"do_nothing_more: passthrough",
"classifier: LogisticRegression",
]
E AssertionError It seems |
Upon second thought, I guess could change the test instead? |
Fixing the test sounds good. |
@deepyaman would you be able to finish this PR? |
Sorry, lot of things happened. :) Let me try and wrap it up later today, or on the weekend. |
@adrinjalali @Charlie-XIAO Sorry for the delay on this; I've made the minor requested change in 99a2177! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @deepyaman
Reference Issues/PRs
N/A
What does this implement/fix? Explain your changes.
I was reading the code for
_sk_visual_block
, and I felt like it was unnecessary to getnames
andestimators
fromself.steps
separately (the first pass simply throws away names), so I figured I'd try some drive-by refactoring.Any other comments?
I know the "optimization" is very minimal, but I think it could also be viewed as cleaner (than discarding
names
in_
the first time around).