FIX Raise error for categorical features with criterion='absolute_error' - #34594
Conversation
The categorical split-finding algorithm is not valid for the absolute error criterion, which made test_split_impurity flaky on CI (scikit-learngh-34578). Rather than silently return a possibly suboptimal split, raise a clear error, matching the other categorical-features incompatibility checks. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: Claude Sonnet 5 <[email protected]>
StefanieSenger
left a comment
There was a problem hiding this comment.
Looks almost good to me. Thank you @cakedev0!
I have nit comment regarding documentation.
Another very tiny nit maybe: The error message reads a bit redundant.
|
This PR also lgtm. One question: Do we need the new changelog entry? I would prefer to add that bit of information to the entry of #33354. |
This is a good point. 33354 has not been released yet, so an extra changelog entry for this fix would only be confusing. |
Co-authored-by: Stefanie Senger <[email protected]>
Co-authored-by: Stefanie Senger <[email protected]>
StefanieSenger
left a comment
There was a problem hiding this comment.
Now looks good to me. Thanks again. :)
|
Thanks for the quick reviews! It's good to merge on my side |
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Head branch was pushed to by a user without write access
…or' (scikit-learn#34594) Co-authored-by: Stefanie Senger <[email protected]>
Reference Issues/PRs
Fixes #34578
What does this implement/fix? Explain your changes.
The categorical split-finding algorithm is not valid for
criterion="absolute_error": it can produce splits that aren't actually optimal for MAE, which is whytest_split_impuritywas flaky on CI for thedense-categorical/DecisionTreeRegressor/absolute_errorcombination on certainglobal_random_seedvalues (see #34578).This implements option 1 from #34578 (comment): raise a clear
ValueErrorfor this case.AI usage
100%, then reviewed
Any other comments?
Once this is merged, I think it would be good to open the debate around allowing near-optimal splits in trees:
tree.tree_.impurityreports incorrect impurity for monotonic trees #34078 (comment)cc @lorentzenchr