Skip to content
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

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

Merged
merged 14 commits into from Feb 1, 2021

Conversation

angela97lin
Copy link
Contributor

Closes #1340

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

codecov bot commented Jan 28, 2021

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.

@@ -440,27 +440,19 @@ def test_clone_init():
clf = MockFitComponent(**params)
clf_clone = clf.clone()
assert clf.parameters == clf_clone.parameters


def test_clone_random_state():
Copy link
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)
Copy link
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
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
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

Copy link
Contributor

@bchen1116 bchen1116 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@chukarsten chukarsten left a comment

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