Skip to content

Update clone() for pipelines and components to copy over random state by default - #1753

Merged
angela97lin merged 14 commits into
mainfrom
1340_clone_random_state
Feb 1, 2021
Merged

angela97lin merged 14 commits into
mainfrom
1340_clone_random_state

Conversation

@angela97lin

Copy link
Copy Markdown
Contributor

Closes #1340

@angela97lin angela97lin self-assigned this Jan 27, 2021
@codecov

codecov Bot commented Jan 28, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #1753 (318a9a6) into main (2e7a92b) will decrease coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             main    #1753     +/-   ##
=========================================
- Coverage   100.0%   100.0%   -0.0%     
=========================================
  Files         247      247             
  Lines       19598    19574     -24     
=========================================
- Hits        19589    19565     -24     
  Misses          9        9             
Impacted Files Coverage Δ
evalml/automl/automl_search.py 99.7% <100.0%> (ø)
evalml/pipelines/components/component_base.py 100.0% <100.0%> (ø)
evalml/pipelines/pipeline_base.py 100.0% <100.0%> (ø)
evalml/tests/component_tests/test_components.py 100.0% <100.0%> (ø)
evalml/tests/pipeline_tests/test_pipelines.py 100.0% <100.0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e7a92b...318a9a6. Read the comment docs.

assert clf.parameters == clf_clone.parameters


def test_clone_random_state():

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't need this test specifically anymore.

pipeline_clone = pipeline.clone(random_state=42)
assert pipeline_clone.random_state == pipeline.random_state

pipeline = linear_regression_pipeline_class(parameters=parameters, random_state=2)

@angela97lin angela97lin Jan 28, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was duplicated checks? 🤔 Either way, not necessary anymore.


def test_nonlinear_clone_init(nonlinear_regression_pipeline_class):
@pytest.mark.parametrize("is_linear", [True, False])
def test_clone_init(is_linear, linear_regression_pipeline_class, nonlinear_regression_pipeline_class):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Combined test_clone_init and test_nonlinear_clone_init via parametrize


def test_clone_fitted(X_y_binary, logistic_regression_binary_pipeline_class):
@pytest.mark.parametrize("is_linear", [True, False])
def test_clone_fitted(is_linear, X_y_binary, logistic_regression_binary_pipeline_class, nonlinear_binary_pipeline_class):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Combined test_nonlinear_clone_fitted and test_clone_fitted via parametrize

@angela97lin
angela97lin marked this pull request as ready for review January 28, 2021 18:23
@angela97lin angela97lin added this to the Sprint 2021 Jan B milestone Jan 28, 2021

@bchen1116 bchen1116 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@chukarsten chukarsten left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really like the subtractions in this PR. Very well done.

@angela97lin
angela97lin merged commit d39352b into main Feb 1, 2021
@angela97lin
angela97lin deleted the 1340_clone_random_state branch February 1, 2021 00:18
@chukarsten chukarsten mentioned this pull request Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should clone copy the random state by default?

3 participants