Raise a custom exception for partial dependence errors#2604
Raise a custom exception for partial dependence errors#2604freddyaboulton merged 3 commits intomainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2604 +/- ##
=======================================
+ Coverage 99.9% 99.9% +0.1%
=======================================
Files 295 295
Lines 26848 26894 +46
=======================================
+ Hits 26802 26848 +46
Misses 46 46
Continue to review full report at Codecov.
|
| raise ValueError( | ||
| "Too many features given to graph_partial_dependence. Only one or two-way partial " | ||
| "dependence is supported." | ||
| try: |
There was a problem hiding this comment.
Adding this try unfortunately makes the diff seem bigger than it is. I think it's important to catch all possible errors that this can raise so that users don't have to resort to except Exception or except PartialDependenceError, ValueError and hope that'll catch everything.
There was a problem hiding this comment.
We have an outstanding issue to clean up partial dependence (#2502) so maybe this will be cleaner once we redesign this with this requirement in mind.
chukarsten
left a comment
There was a problem hiding this comment.
Very awesome, great work. Thanks for consolidating all these exceptions and making it super tidy. I think this will also help downstream consumers of EvalML a LOT.
| code=PartialDependenceErrorCode.COMPUTED_PERCENTILES_TOO_CLOSE, | ||
| ) | ||
| else: | ||
| raise e |
There was a problem hiding this comment.
Ah, so this error isn't necessarily due to Partial Dependence, so it doesn't necessarily fall into the PartialDependenceError category? Got it
There was a problem hiding this comment.
Yea it's caused by something else in sklearn. Raising here makes sure the final except catches it and then we can wrap as PartialDependenceError with the "all other errors code"
There was a problem hiding this comment.
Also, about the docs page. Yea you have to click on the drop down on the left hand side and then click on exceptions.
The "API Reference" is a manually curated list of functions/classes but it's not exhaustive.
ParthivNaresh
left a comment
There was a problem hiding this comment.
Solid work, love the Enum implementation
angela97lin
left a comment
There was a problem hiding this comment.
I love this change. LGTM!
| if any(is_datetime): | ||
| raise ValueError( | ||
| "Two-way partial dependence is not supported for datetime columns." | ||
| X_unknown = X_features.ww.select("unknown") |
There was a problem hiding this comment.
Can we combine this with the following check for "URL", "EmailAddress", "NaturalLanguage"? They all have the INVALID_FEATURE_TYPE code :)
8650c12 to
2148a52
Compare
2148a52 to
53b932b
Compare
Pull Request Description
Fixes #2539
Design document here .
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.rstto include this pull request by adding :pr:123.