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
Remove ComponentGraph.from_list
and update PipelineBase impl creating from lists
#2549
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2549 +/- ##
=======================================
+ Coverage 99.9% 99.9% +0.1%
=======================================
Files 285 285
Lines 26167 26168 +1
=======================================
+ Hits 26131 26132 +1
Misses 36 36
Continue to review full report at Codecov.
|
@@ -31,6 +31,10 @@ class ComponentGraph: | |||
def __init__(self, component_dict=None, random_seed=0): | |||
self.random_seed = random_seed | |||
self.component_dict = component_dict or {} | |||
if not isinstance(self.component_dict, dict): |
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.
No more lists allowed!
@@ -150,6 +151,34 @@ def linearized_component_graph(self): | |||
"""A component graph in list form. Note that this is not guaranteed to be in proper component computation order""" | |||
return ComponentGraph.linearized_component_graph(self.component_graph) | |||
|
|||
@staticmethod | |||
def _make_component_dict_from_component_list(component_list): |
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.
Moved this into pipeline_base... mostly because trying to import this from pipeline.utils.py, which imports PipelineBase, would otherwise create a circular dependency :/
evalml/pipelines/pipeline_base.py
Outdated
component = handle_component_class(component) | ||
if not component._supported_by_list_API: | ||
raise ValueError( | ||
"This component cannot be defined in a list because edges may be ambiguous. Please use a dictionary to specify the appropriate component graph for this pipeline instead." |
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.
nit-pick: Should we list the component name in the message?
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.
Sure thing, done 😁
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.
@angela97lin This looks good to me!
"SMOTENC Oversampler", | ||
estimator, | ||
] | ||
component_graph={ |
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.
👍
More breaking up #2490 into smaller and cleaner PRs :)
This PR removes
from_list
from ComponentGraph and updatesPipelineBase
's implementation to handle creating a component dictionary to pass along to the ComponentGraph.This is slightly different from our behavior today because it puts the burden of converting from a list of components --> component dict on the pipeline. This means that ComponentGraphs do not need to understand how to handle lists.
Note that
_make_component_dict_from_component_list
updates the generated component graph to include X and y edges for each component, but it is not enforced yet! That will come in a later PR :)