Skip to content

Make HighVarianceCVDataCheck a standalone object/method instead of a data check#1928

Merged
angela97lin merged 9 commits into
mainfrom
1861_hv
Mar 6, 2021
Merged

Make HighVarianceCVDataCheck a standalone object/method instead of a data check#1928
angela97lin merged 9 commits into
mainfrom
1861_hv

Conversation

@angela97lin

Copy link
Copy Markdown
Contributor

Closes #1861

@angela97lin angela97lin self-assigned this Mar 4, 2021
@codecov

codecov Bot commented Mar 4, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1928 (cb9c761) into main (cfc601d) will decrease coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             main    #1928     +/-   ##
=========================================
- Coverage   100.0%   100.0%   -0.0%     
=========================================
  Files         267      265      -2     
  Lines       21730    21712     -18     
=========================================
- Hits        21724    21706     -18     
  Misses          6        6             
Impacted Files Coverage Δ
evalml/data_checks/__init__.py 100.0% <ø> (ø)
evalml/automl/automl_search.py 100.0% <100.0%> (ø)
evalml/tests/automl_tests/test_automl.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 cfc601d...cb9c761. Read the comment docs.

@angela97lin angela97lin marked this pull request as ready for review March 5, 2021 15:39

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

@angela97lin Looks good to me!

Comment thread docs/source/release_notes.rst Outdated
* Updated ``add_results`` in ``AutoMLAlgorithm`` to take in entire pipeline results dictionary from ``AutoMLSearch`` :pr:`1891`
* Updated ``ClassImbalanceDataCheck`` to look for severe class imbalance scenarios :pr:`1905`
* Deleted the ``explain_prediction`` function :pr:`1915`
* Removed ``HighVarianceCVDataCheck`` and convered it to a standalone method instead :pr:`1928`

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 think this should also be marked as a breaking change

assert str(warn[0].message).startswith("Argument 'random_state' has been deprecated in favor of 'random_seed'")


def test_automl_check_for_high_variance(X_y_binary, dummy_binary_pipeline_class, caplog):

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.

Not entirely in the scope of this issue but I just noticed we don't test if the high variance warning runs during search. I think it would be worth doing that eventually but we can tackle that in a separate issue. What do you think?

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.

Yup, you're right--we test that the output is bool but not whether we actually log. I'll add a test 🥳

Comment thread evalml/automl/automl_search.py Outdated
high_variance_cv = False

if cv_scores.mean() != 0:
high_variance_cv = bool(abs(cv_scores.std() / cv_scores.mean()) > 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.

Isn't abs(cv_scores.std() / cv_scores.mean()) > threshold already a bool?

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.

@freddyaboulton Unfortunately it resolves to a numpy.bool_ which is different 😭

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.

Damn. But then how does the old code work? 🤔

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.

Old code (and this code) check if high_variance_cv which will evaluate to True regardless of python or numpy bool, but now we want to take high_variance_cv and set it in pipeline_results. (Previously, just checked if # of warnings greater than 0, then set high_variance_cv to True so not using it directly.)

I wasn't aware of the difference myself until test_search_results broke at assert isinstance(results['high_variance_cv'], bool) without this type conversion 😬

@jeremyliweishih jeremyliweishih left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

very nice

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

Dig it. Nice work.

Comment thread evalml/automl/automl_search.py Outdated
pipeline_name = pipeline.name
high_variance_cv = False

if cv_scores.mean() != 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.

What case is this capturing?

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.

Hm, this was more a rework of what was already there and the fear of cv_scores.mean() == 0 meaning you divide by 0 in the lines that follow... but it seems like numpy just handles division by 0 as nan, and nan won't ever be greater than the threshold so maybe we don't need this after all. I'll remove!

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

Looks good! I left a few comments on testing/thresholding, but nothing blocking.

* Updated ``add_results`` in ``AutoMLAlgorithm`` to take in entire pipeline results dictionary from ``AutoMLSearch`` :pr:`1891`
* Updated ``ClassImbalanceDataCheck`` to look for severe class imbalance scenarios :pr:`1905`
* Deleted the ``explain_prediction`` function :pr:`1915`
* Removed ``HighVarianceCVDataCheck`` and convered it to an ``AutoMLSearch`` method instead :pr:`1928`

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.

Typo: convered?

self.add_result_callback(self._results['pipeline_results'][pipeline_id], pipeline, self)
return pipeline_id

def _check_for_high_variance(self, pipeline, cv_scores, threshold=0.2):

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.

nitpick, but should we enforce that users can't pass in threshold < 0, even though this is a private method?

assert not automl._check_for_high_variance(pipeline, cv_scores)

cv_scores = pd.Series([0, 0, 0])
assert not automl._check_for_high_variance(pipeline, cv_scores)

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.

Might be nice to test different thresholds just to be super comprehensive

@angela97lin angela97lin merged commit 709ae0a into main Mar 6, 2021
@angela97lin angela97lin deleted the 1861_hv branch March 6, 2021 04:15
@dsherry dsherry mentioned this pull request Mar 11, 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.

Make HighVarianceCVDataCheck a standalone object/method instead of a data check

5 participants