-
Notifications
You must be signed in to change notification settings - Fork 91
Update ComponentGraph to enforce needing .x and .y for each component specified in the graph #2563
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
Merged
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
943a155
init: moving code around
angela97lin f87ec33
merge
angela97lin 85f32a9
init
angela97lin b558919
cap sktime
angela97lin 64d94af
release notes
angela97lin 0929b3b
add test
angela97lin 71c6fb1
Merge branch '2494_component_supports_lists' into 2482_deprecate_list…
angela97lin 948abe9
cleanup: lint and rls notes
angela97lin f2997f7
moving away from linear_component_graph
angela97lin 55e0e7f
more slow updates
angela97lin 90470ad
init
angela97lin 3f57291
Merge branch '2494_component_supports_lists' into 2493_component_grap…
angela97lin c390b18
hmmm
angela97lin 01f85e4
init
angela97lin 33bc7eb
Merge branch 'main' into 2493_component_graphs_make_pipelines
angela97lin a7408e0
push a different version
angela97lin 892426b
init
angela97lin 3e36890
release notes
angela97lin 6865c47
oops fix
angela97lin e1d8fa5
move out
angela97lin 8144b1a
Merge branch 'main' into 2493_component_graphs_make_pipelines
angela97lin ee8c9d4
init and merge
angela97lin ee0f3cb
Merge branch '2493_component_graphs_make_pipelines' of github.com:alt…
angela97lin d3c0158
clean up and add tests
angela97lin f36cf6b
update private vars as abstract attrs
angela97lin ff74f9a
Merge branch 'main' into 2493_component_graphs_make_pipelines
angela97lin fa5e3ba
add attributes to tests
angela97lin e002e20
Merge branch '2493_component_graphs_make_pipelines' of github.com:alt…
angela97lin 224209c
more cleanup
angela97lin a4fc850
add more test cases
angela97lin 6e95729
Merge branch 'main' into 2493_component_graphs_make_pipelines
angela97lin 692a86d
Merge branch 'main' into 2482_deprecate_list_API
angela97lin feca82e
progress on tests
angela97lin d438e27
more cleanup tests
angela97lin 4ae856f
Merge branch 'main' into 2482_deprecate_list_API
angela97lin c062eac
more test cleanup, more to go L:
angela97lin 3bf54bf
merging
angela97lin e2e6544
fix some tests with fixture, let tests run
angela97lin 69a5c46
:)
angela97lin 9dd26b7
clean up tests
angela97lin aad921c
Merge branch 'main' into 2482_deprecate_list_API
angela97lin 2ae3d4c
fix other test
angela97lin 1147126
Merge branch '2482_deprecate_list_API' of github.com:alteryx/evalml i…
angela97lin 5fb648f
Merge branch 'main' into 2482_deprecate_list_API
angela97lin b9facdf
merge
angela97lin 900e374
pipelinebase cleanup and testing docs
angela97lin d6eeef2
more cleanup and moving methods to avoid circular dep
angela97lin 28d81b6
add tests for component graph to enforce x, y
angela97lin 1d5f3b5
merging
angela97lin 39ee3ac
merge main
angela97lin 699d00e
fix tests from merge
angela97lin b81aa45
merge and fix tests
angela97lin d95c5dd
revert moving methods around and do some cleanup
angela97lin 7edac1d
merging main
angela97lin 52024dc
clean up test and release notes
angela97lin d595244
revert unnecessary changes
angela97lin a36f835
some general cleanup with tests and fixtures
angela97lin 5b1f51d
init
angela97lin 1e22794
cleanup impl
angela97lin 158bc40
remove unnecessary test
angela97lin 07ad029
merging
angela97lin f3a3352
oops remove pdb
angela97lin ab76746
fix not connected case and add test
angela97lin b193d71
oops forgot to uncomment component_graphs
angela97lin 94f15e8
move test to other test with bad init graph
angela97lin 423b3e0
Merge branch 'main' into 2482_x_y
angela97lin 637c177
Merge branch 'main' into 2482_x_y
angela97lin f797653
fix test
angela97lin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,20 +39,37 @@ def __init__(self, component_dict=None, random_seed=0): | |
| raise ValueError( | ||
| "component_dict must be a dictionary which specifies the components and edges between components" | ||
| ) | ||
| self._validate_component_dict() | ||
| self.component_instances = {} | ||
| self._is_instantiated = False | ||
| for component_name, component_info in self.component_dict.items(): | ||
| if not isinstance(component_info, list): | ||
| raise ValueError( | ||
| "All component information should be passed in as a list" | ||
| ) | ||
| component_class = handle_component_class(component_info[0]) | ||
| self.component_instances[component_name] = component_class | ||
| self.input_feature_names = {} | ||
| self._feature_provenance = {} | ||
| self._i = 0 | ||
| self._compute_order = self.generate_order(self.component_dict) | ||
|
|
||
| def _validate_component_dict(self): | ||
| for _, component_inputs in self.component_dict.items(): | ||
| if not isinstance(component_inputs, list): | ||
| raise ValueError( | ||
| "All component information should be passed in as a list" | ||
| ) | ||
| component_inputs = component_inputs[1:] | ||
| has_feature_input = any( | ||
| component_input.endswith(".x") or component_input == "X" | ||
| for component_input in component_inputs | ||
| ) | ||
| has_target_input = any( | ||
| component_input.endswith(".y") or component_input == "y" | ||
| for component_input in component_inputs | ||
| ) | ||
| if not (has_feature_input and has_target_input): | ||
| raise ValueError( | ||
| "All edges must be specified as either an input feature (.x) or input target (.y)." | ||
| ) | ||
|
|
||
| @property | ||
| def compute_order(self): | ||
| """The order that components will be computed or called in.""" | ||
|
|
@@ -280,7 +297,7 @@ def _compute_features(self, component_list, X, y=None, fit=False): | |
| output = component_instance.predict(input_x) | ||
| else: | ||
| output = None | ||
| output_cache[component_name] = output | ||
| output_cache[f"{component_name}.x"] = output | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means that components will use estimator outputs as |
||
| return output_cache | ||
|
|
||
| def _get_feature_provenance(self, input_feature_names): | ||
|
|
@@ -522,6 +539,7 @@ def generate_order(cls, component_dict): | |
| if len(edges) == 0: | ||
| return [] | ||
| digraph = nx.DiGraph() | ||
| digraph.add_nodes_from(list(component_dict.keys())) | ||
| digraph.add_edges_from(edges) | ||
| if not nx.is_weakly_connected(digraph): | ||
angela97lin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| raise ValueError("The given graph is not completely connected") | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Like this function - super readable.