Skip to content

Default optimize_thresholds to True in AutoMLSearch - #1943

Merged
bchen1116 merged 38 commits into
mainfrom
bc_1940_threshold
Mar 15, 2021
Merged

bchen1116 merged 38 commits into
mainfrom
bc_1940_threshold

Conversation

@bchen1116

@bchen1116 bchen1116 commented Mar 8, 2021 •

Copy link
Copy Markdown
Contributor

fix #648

Perf test here

In-depth dive added here

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

codecov Bot commented Mar 8, 2021 •

Copy link
Copy Markdown

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.

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
Copy Markdown
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

@freddyaboulton freddyaboulton 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.

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

Comment thread evalml/automl/utils.py Resolved
@bchen1116
bchen1116 marked this pull request as ready for review March 10, 2021 18:54


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

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.

need to patch encode_targets in order to optimize the threshold

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.

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

@freddyaboulton freddyaboulton 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.

@bchen1116 This looks great!

Comment thread docs/source/user_guide/automl.ipynb Resolved
Comment thread evalml/automl/engine/engine_base.py Resolved


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

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.

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

@angela97lin angela97lin 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.

Looks good! Mostly left some nit picky comments heh

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