-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
FEA Trees: Add support for missing values with criterion="absolute_error" by greatly simplifying the logic #32119
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
base: main
Are you sure you want to change the base?
Conversation
Note: at this day, tests passes on my laptop and most CI unit tests pipelines are successful. But some are failing, I managed to reproduce one of the failing pipelines locally using a Docker image. I still need to find the bug though. |
Tests pass! 🎊 Well, I learned the difference between |
Let's keep this in draft mode until we merge #32100. Ping here for a review after the initial PRs are sorted out |
This PR refactors how missing values are handled in trees by:
Criterion
subclassesThis greatly simplifies the logic and unlocks for free the support of missing values for MAE trees.
Reference Issues/PRs
This PR accidentally fixes #32178
Otherwise, I looked but I didn't find any issue requesting this feature. I think it's because MAE trees are just too slow in sklearn for now so it's not much used... People wanting to use the MAE will just search for other options in sklearn or other libs.
What does this implement/fix? Explain your changes.
Currently, a part of the missing values support is done by each subclass of
Criterion
. I believe it's not a great design because:Criterion
is "X-blind", it's not aware of X values. It just looks aty
andsample_weights
in the order defined by the sorted indices (sample_indices
). It never looks at X values. But somehow, by making it handle missing values, it does have some dealing with X values. Why not just use the ordering ofsample_indices
to take into account missing values? Like what we do for any other value (even inf/-inf for instance).So, to the question "Why not just use the ordering of
sample_indices
to take into account missing values? " my answer is :"yes, let's just do that". The result is removing 200 lines from_criterion.pxy
while not increasing the complexity of the splitter and the partitionner (actually, it also simplifies a bit the splitter).Any other comments?
I think it might unlock making the support for missing values + monotonic constraints easy, but I haven't look into it yet.
It might also simplify a bit the support for missing values + sparse, but this is still not easy to do.