Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Release Notes
* Added the ability to see the linear coefficients of features in linear models terms :pr:`1738`
* Added support for ``scikit-learn`` ``v0.24.0`` :pr:`1733`
* Fixes
* Removed ``random_state`` arg from ``get_pipelines`` in ``AutoMLSearch`` :pr:`1719`
* Changes
* Updated components and pipelines to return ``Woodwork`` data structures :pr:`1668`
* Documentation Changes
Expand Down
5 changes: 2 additions & 3 deletions evalml/automl/automl_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,13 +840,12 @@ def _evaluate_pipelines(self, current_pipeline_batch, baseline=False, search_ite

return current_batch_pipeline_scores

def get_pipeline(self, pipeline_id, random_state=0):
def get_pipeline(self, pipeline_id):
"""Given the ID of a pipeline training result, returns an untrained instance of the specified pipeline
initialized with the parameters used to train that pipeline during automl search.

Arguments:
pipeline_id (int): pipeline to retrieve
random_state (int): Seed for the random number generator. Defaults to 0.

Returns:
PipelineBase: untrained pipeline instance associated with the provided ID
Expand All @@ -862,7 +861,7 @@ def get_pipeline(self, pipeline_id, random_state=0):
pipeline.custom_hyperparameters = pipeline_class.custom_hyperparameters
pipeline.custom_name = pipeline_class.name
pipeline.component_graph = pipeline_class.component_graph
return pipeline(parameters, random_state=random_state)
return pipeline(parameters, random_state=self.random_state)

def describe_pipeline(self, pipeline_id, return_dict=False):
"""Describe a pipeline
Expand Down
13 changes: 13 additions & 0 deletions evalml/tests/automl_tests/test_automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,3 +2165,16 @@ def test_automl_pipeline_params_kwargs(mock_fit, mock_score, X_y_multi):
if 'Decision Tree Classifier' in row['parameters']:
assert 0.1 < row['parameters']['Decision Tree Classifier']['ccp_alpha'] < 0.5
assert row['parameters']['Decision Tree Classifier']['max_depth'] == 1


@pytest.mark.parametrize("random_state", [0, 1, 9])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So fresh and so clean. Awesome.

@patch('evalml.pipelines.MulticlassClassificationPipeline.score')
@patch('evalml.pipelines.MulticlassClassificationPipeline.fit')
def test_automl_pipeline_random_state(mock_fit, mock_score, random_state, X_y_multi):
X, y = X_y_multi
automl = AutoMLSearch(X_train=X, y_train=y, problem_type='multiclass', random_state=random_state, n_jobs=1)
automl.search()

for i, row in automl.rankings.iterrows():
if 'Base' not in list(row['parameters'].keys())[0]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O same question as other PR LOL, why the check for Base here :o

Copy link
Contributor Author

@bchen1116 bchen1116 Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The baseline pipeline isn't initialized with a random_state arg, so we can't check for random state here

assert automl.get_pipeline(row['id']).random_state == random_state