Skip to content

Add Model Understanding Tests - #2286

Merged
bchen1116 merged 18 commits into
mainfrom
bc_oversampler_tests
May 19, 2021
Merged

Add Model Understanding Tests#2286
bchen1116 merged 18 commits into
mainfrom
bc_oversampler_tests

Conversation

@bchen1116

Copy link
Copy Markdown
Contributor

Address comments from this

We can't do prediction_explanations for Catboost or Elastic Net Classifier, and we already have issues related to the bugs here and here

@bchen1116 bchen1116 self-assigned this May 18, 2021
@codecov

codecov Bot commented May 18, 2021

Copy link
Copy Markdown

Codecov Report

Merging #2286 (4443846) into main (72b7fd1) will increase coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             main    #2286     +/-   ##
=========================================
+ Coverage   100.0%   100.0%   +0.1%     
=========================================
  Files         280      280             
  Lines       24392    24410     +18     
=========================================
+ Hits        24369    24387     +18     
  Misses         23       23             
Impacted Files Coverage Δ
...s/prediction_explanations_tests/test_explainers.py 100.0% <100.0%> (ø)
...understanding_tests/test_permutation_importance.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 72b7fd1...4443846. Read the comment docs.

@bchen1116
bchen1116 marked this pull request as ready for review May 18, 2021 21:36
@dsherry dsherry added task Scripting, configuration, or other work which doesn't categorize well as a feature/enhancement/bug. testing Issues related to testing. labels May 18, 2021

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

You rock, thanks for this! This will cover our butts while we work on adding coverage for automl --> model understanding to our release test suite.

I just had one blocking comment.

Comment thread docs/source/release_notes.rst Outdated

@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 besides what @dsherry pointed out, but I think it could be worthwhile to try to all estimators and single out catboost / EN. Then, when those issues are resolved it'll be easier to catch here and update the tests accordingly.

Comment thread evalml/tests/model_understanding_tests/test_permutation_importance.py Outdated

@ParthivNaresh ParthivNaresh 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 great, no other comments besides the changes already requested!

@bchen1116
bchen1116 requested a review from dsherry May 19, 2021 19:09

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

Looking good!

very_cool

pipeline.fit(X, y)
report = explain_predictions(pipeline, X, y, indices_to_explain=[0], output_format="dataframe", top_k_features=4)
assert report['feature_names'].isnull().sum() == 0
assert report['feature_values'].isnull().sum() == 0

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 this seems reasonable to me. We have other tests I believe which check that the output of prediction explanations is what we expect it to be. This test is just checking that something came out which matches the form we expect. 👍

pipeline = BinaryClassificationPipeline(component_graph=["Imputer", "One Hot Encoder", "DateTime Featurization Component", "SMOTENC Oversampler", estimator])
pipeline.fit(X=X, y=y)
pipeline.predict(X)
importance = calculate_permutation_importance(pipeline, X, y, objective="Log Loss Binary")

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 can be a long-running computation. How long does this unit test take locally?

If its longer than a couple seconds total I suggest just doing it for one estimator. IMO I think that's acceptable because the goal for these tests is to prove that using a component which modifies the target during training (oversampler) doesn't break the model understanding tools, so iterating over the estimators is nice but not a requirement.

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.

Yep! Running all locally took ~36 seconds, while running with one estimator took ~4.5 seconds. Will change to using just 1 estimator!

@bchen1116
bchen1116 merged commit 254a446 into main May 19, 2021
@chukarsten chukarsten mentioned this pull request May 24, 2021
@chukarsten chukarsten mentioned this pull request Jun 2, 2021
@freddyaboulton
freddyaboulton deleted the bc_oversampler_tests branch May 13, 2022 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

task Scripting, configuration, or other work which doesn't categorize well as a feature/enhancement/bug. testing Issues related to testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants