-
Notifications
You must be signed in to change notification settings - Fork 86
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
Updated _evaluate_pipelines to consolidate side effects #1337
Conversation
7f53df8
to
48b340f
Compare
Codecov Report
@@ Coverage Diff @@
## main #1337 +/- ##
==========================================
- Coverage 99.95% 99.95% -0.00%
==========================================
Files 213 213
Lines 13938 13934 -4
==========================================
- Hits 13931 13927 -4
Misses 7 7
Continue to review full report at Codecov.
|
ba2c499
to
edf598b
Compare
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.
@christopherbunn Looks great!
mock_next_batch.side_effect = [[dummy_binary_pipeline_class(parameters={}), dummy_binary_pipeline_class(parameters={})]] | ||
automl = AutoMLSearch(problem_type='binary', allowed_pipelines=[dummy_binary_pipeline_class]) | ||
automl.search(X, y) | ||
# Mock rankings so `best_pipeline` setting does not error out | ||
with patch('evalml.automl.AutoMLSearch.rankings', new_callable=PropertyMock) as mock_rankings: |
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.
Why did you change mock_evaluate_pipelines
from .side_effect
to .return_value
?
So we need this this new PropertyMock because you're mocking _evaluate_pipelines
which is what calls _add_result
(which is what populates the data for the ranking table)?
I wonder if we even need this code block in the test. I think the point of the test is to verify that the search ends when it encounters a batch of all nan (which is what happens in the code block that doesn't have the property mock).
This would be fine to merge as is but I'm guessing we can simplify this test a bit without losing any coverage.
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.
Why did you change mock_evaluate_pipelines from .side_effect to .return_value?
Good question. I changed it to .return_value
as I needed the mock _evaluate_pipelines
to return the entire list of pipeline scores. Passing in a list to .side_effect
cause it to iterate through the list and only return each element.
RE: the code block, you're right about the reason why we have to populate the ranking table manually. My impression of the intent of this section was to show that having a np.nan
score as one of the pipeline results won't result in raising the AutoMLSearchException. If this isn't a necessary check, then I'm good with cutting out this section.
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.
Maybe we can delete that code block then? The second code block returns a Nan in the second batch and the search doesn't terminate then but we can check that explicitly with assert mock_evaluate_pipelines.call_count == 3
.
This isn't blocking merge but my vote is to remove code that provides redundant coverage while we're at it.
if add_single_pipeline: | ||
add_single_pipeline = False | ||
|
||
except KeyboardInterrupt: |
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.
From what I can tell there isn't any change to the keyboard interrupt feature! What do you think @christopherbunn ?
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.
I think technically if the user terminates the search while the next batch is being generated, it wouldn't get caught by this KeyboardInterrupt. In practice, getting the next batch takes so little time it's very unlikely that this will occur.
b2d304b
to
3bf80f0
Compare
evalml/automl/automl_search.py
Outdated
return True | ||
|
||
scores = self._evaluate_pipelines(pipelines, X, y, baseline=True) | ||
if scores == []: |
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.
return len(scores) == 0
?
3bf80f0
to
028fa66
Compare
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.
@christopherbunn LGTM!
I left one question about show_batch_output
. I also left a comment about deleting an old docstring. Otherwise, nothing blocking
evalml/automl/automl_search.py
Outdated
Returns: | ||
self | ||
feature_types (list, optional): list of feature types, either numerical or categorical. | ||
Categorical features will automatically be encoded |
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.
@christopherbunn I think we deleted this deprecated feature_types
field last week
evalml/automl/automl_search.py
Outdated
|
||
except KeyboardInterrupt: | ||
current_pipeline_batch = self._handle_keyboard_interrupt(pipeline, current_pipeline_batch) | ||
if current_pipeline_batch == []: |
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.
Style nit-pick: if len(current_pipeline_batch) == 0
I don't think there's much significant functional difference here lol, I just think checking length is more clear.
@@ -425,6 +427,7 @@ def search(self, X, y, data_checks="auto", show_iteration_plot=True): | |||
if self.allowed_pipelines == []: | |||
raise ValueError("No allowed pipelines to search") | |||
if self.max_batches and self.max_iterations is None: | |||
self.show_batch_output = True |
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.
@christopherbunn what's this? Why do we need it?
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.
Currently, we show the batch number only if the user specifies a number of max_batches
. Since we use batching internally even if only max_iterations
is specified, there isn't really a clean way to infer whether or not we want to show the number of batches other than setting a variable at the beginning.
028fa66
to
f67ea11
Compare
8abf084
to
41d8163
Compare
41d8163
to
88e0ee5
Compare
@christopherbunn and I saw intermittent failures in the linux CI tests on his branch. Since they were coming from pipeline tests and this PR only changes automl code, we conclude those failures aren't introduced by this PR. Will keep debugging. |
This reverts commit 9451546.
Taking on a different approach with
_evaluate
side effects by restructuring and renaming to_evaluate_pipelines
. See this comment for more info.Resolves #1295