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

Default optimize_thresholds to True in AutoMLSearch #1943

Merged
merged 38 commits into from Mar 15, 2021
Merged

Conversation

bchen1116
Copy link
Contributor

@bchen1116 bchen1116 commented Mar 8, 2021

fix #648

Perf test here

In-depth dive added here

@bchen1116 bchen1116 self-assigned this Mar 8, 2021
@codecov
Copy link

codecov bot commented Mar 8, 2021

Codecov Report

Merging #1943 (ae727a5) into main (7e8f082) will increase coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             main    #1943     +/-   ##
=========================================
+ Coverage   100.0%   100.0%   +0.1%     
=========================================
  Files         273      273             
  Lines       22279    22356     +77     
=========================================
+ Hits        22273    22350     +77     
  Misses          6        6             
Impacted Files Coverage Δ
evalml/automl/automl_search.py 100.0% <ø> (ø)
evalml/automl/engine/engine_base.py 100.0% <100.0%> (ø)
evalml/automl/utils.py 100.0% <100.0%> (ø)
evalml/pipelines/classification_pipeline.py 100.0% <100.0%> (ø)
evalml/pipelines/pipeline_base.py 100.0% <100.0%> (ø)
evalml/tests/automl_tests/test_automl.py 100.0% <100.0%> (ø)
.../automl_tests/test_automl_search_classification.py 100.0% <100.0%> (ø)
evalml/tests/automl_tests/test_automl_utils.py 100.0% <100.0%> (ø)
evalml/tests/automl_tests/test_engine_base.py 100.0% <100.0%> (ø)
evalml/tests/pipeline_tests/test_pipelines.py 100.0% <100.0%> (ø)
... and 1 more

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 7e8f082...ae727a5. Read the comment docs.

@@ -83,7 +83,7 @@ def test_search_results(X_y_regression, X_y_binary, X_y_multi, automl_type, obje
expected_pipeline_class = MulticlassClassificationPipeline
X, y = X_y_multi

automl = AutoMLSearch(X_train=X, y_train=y, problem_type=automl_type, objective=objective, max_iterations=2, n_jobs=1)
automl = AutoMLSearch(X_train=X, y_train=y, problem_type=automl_type, objective=objective, optimize_thresholds=False, max_iterations=2, n_jobs=1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed to set optimize_thresholds as False in order to avoid issues during training best_pipeline with predict_proba. Otherwise, I could have mocked predict_proba for all the tests but this was a faster approach with similar results.

@bchen1116 bchen1116 marked this pull request as ready for review March 8, 2021 21:15
Copy link
Contributor

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

@bchen1116 I have a couple design questions before taking a closer look!

docs/source/demos/cost_benefit_matrix.ipynb Outdated Show resolved Hide resolved
evalml/automl/utils.py Outdated Show resolved Hide resolved
@bchen1116 bchen1116 marked this pull request as ready for review March 10, 2021 18:54
@@ -227,20 +227,21 @@ def test_additional_objectives(X_y_binary):


@patch('evalml.objectives.BinaryClassificationObjective.optimize_threshold')
@patch('evalml.pipelines.BinaryClassificationPipeline._encode_targets', side_effect=lambda y: y)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to patch encode_targets in order to optimize the threshold

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, otherwise sklearn will throw an exception. The encoder is fit during pipeline.fit but since we're mocking fit, that doesn't happen.

Copy link
Contributor

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

@bchen1116 This looks great!

docs/source/user_guide/automl.ipynb Outdated Show resolved Hide resolved
evalml/automl/engine/engine_base.py Show resolved Hide resolved
evalml/pipelines/classification_pipeline.py Outdated Show resolved Hide resolved
@@ -227,20 +227,21 @@ def test_additional_objectives(X_y_binary):


@patch('evalml.objectives.BinaryClassificationObjective.optimize_threshold')
@patch('evalml.pipelines.BinaryClassificationPipeline._encode_targets', side_effect=lambda y: y)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, otherwise sklearn will throw an exception. The encoder is fit during pipeline.fit but since we're mocking fit, that doesn't happen.

evalml/tests/pipeline_tests/test_pipelines.py Outdated Show resolved Hide resolved
evalml/tests/pipeline_tests/test_pipelines.py Outdated Show resolved Hide resolved
evalml/tests/automl_tests/test_automl.py Show resolved Hide resolved
Copy link
Contributor

@angela97lin angela97lin left a comment

Choose a reason for hiding this comment

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

Looks good! Mostly left some nit picky comments heh

evalml/pipelines/classification_pipeline.py Outdated Show resolved Hide resolved
evalml/pipelines/classification_pipeline.py Outdated Show resolved Hide resolved
evalml/pipelines/classification_pipeline.py Outdated Show resolved Hide resolved
evalml/tests/pipeline_tests/test_pipelines.py Outdated Show resolved Hide resolved
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.

Re-enable binary classification threshold tuning by default
4 participants