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

Fix Automl custom objective stack trace #1575

Merged
merged 6 commits into from Jan 4, 2021

Conversation

freddyaboulton
Copy link
Contributor

@freddyaboulton freddyaboulton commented Dec 17, 2020

Pull Request Description

Fixes #1572

The issue is that _compute_cv_scores stores the objective scores in a dict keyed by the objective name (str). When we go to compute "percent better than baseline", we have to map the string name to an objective class. We were doing this mapping with get_objective which doesn't doesn't know about the class definition of a custom objective.

The fix is to create a name to class mapping when AutoMLSearch is created.


After creating the pull request: in order to pass the release_notes_updated check you will need to update the "Future Release" section of docs/source/release_notes.rst to include this pull request by adding :pr:123.

@freddyaboulton freddyaboulton added the bug Issues tracking problems with existing features. label Dec 17, 2020
@freddyaboulton freddyaboulton added this to the December 2020 milestone Dec 17, 2020
@freddyaboulton freddyaboulton self-assigned this Dec 17, 2020
@codecov
Copy link

codecov bot commented Dec 17, 2020

Codecov Report

Merging #1575 (2242ffd) into main (b257752) will increase coverage by 0.1%.
The diff coverage is 100.0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             main    #1575     +/-   ##
=========================================
+ Coverage   100.0%   100.0%   +0.1%     
=========================================
  Files         240      240             
  Lines       18210    18235     +25     
=========================================
+ Hits        18202    18227     +25     
  Misses          8        8             
Impacted Files Coverage Δ
evalml/automl/automl_search.py 99.7% <100.0%> (ø)
evalml/tests/automl_tests/test_automl.py 100.0% <100.0%> (ø)
evalml/tests/objective_tests/test_objectives.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 b257752...2242ffd. Read the comment docs.

@freddyaboulton freddyaboulton marked this pull request as ready for review December 17, 2020 20:35
@freddyaboulton freddyaboulton force-pushed the 1572-automl-custom-objective-support branch from ff1fbba to e4ea401 Compare December 18, 2020 15:22
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.

Looks good! Left one question, but nothing blocking

@@ -619,15 +619,17 @@ def _add_baseline_pipelines(self, X, y):
return False

@staticmethod
def _get_mean_cv_scores_for_all_objectives(cv_data):
def _get_mean_cv_scores_for_all_objectives(cv_data, objective_name_to_class):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just call self.objective_name_to_class inside this function rather than pass it in as an arg? Is there a reason to choose one versus the other, since the objectives don't change post-initialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wanted to keep it static 🤷‍♂️ Yes you're right though. Functionally, there's no difference between this implementation and just adding self as an argument to the method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, sounds good!

@@ -34,7 +34,7 @@ class MockNoObjectiveFunctionObjective(ObjectiveBase):
MockNoObjectiveFunctionObjective()


@pytest.mark.parametrize("obj", _get_subclasses(ObjectiveBase))
@pytest.mark.parametrize("obj", _all_objectives_dict().values())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@freddyaboulton freddyaboulton force-pushed the 1572-automl-custom-objective-support branch 2 times, most recently from 99743dc to fa38e71 Compare December 21, 2020 15:20
@dsherry dsherry removed this from the December 2020 milestone Jan 4, 2021
@freddyaboulton freddyaboulton force-pushed the 1572-automl-custom-objective-support branch 2 times, most recently from 771272b to 0c3ce80 Compare January 4, 2021 20:06
@freddyaboulton freddyaboulton force-pushed the 1572-automl-custom-objective-support branch from 0491c59 to 2242ffd Compare January 4, 2021 20:33
@freddyaboulton freddyaboulton merged commit ae248fe into main Jan 4, 2021
@freddyaboulton freddyaboulton deleted the 1572-automl-custom-objective-support branch January 4, 2021 21:06
@bchen1116 bchen1116 mentioned this pull request Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues tracking problems with existing features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AutoML: using a custom objective causes stack trace
3 participants