FEA Add estimators_ attribute to random forest estimators - #8238
Draft
betatim wants to merge 6 commits into
Draft
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
rapids-bot Bot
pushed a commit
that referenced
this pull request
Jun 25, 2026
Fix `RandomForestClassifier.as_sklearn()` so exported child estimators use sklearn-compatible encoded `classes_` and `n_classes_` metadata, while the exported forest keeps the original labels. Adds coverage with non-contiguous classifier labels and compares the exported child estimator metadata against a fitted sklearn random forest. Contributes to #8180. Related to #8238. Authors: - Simon Adorf (https://github.com/csadorf) Approvers: - Jim Crist-Harif (https://github.com/jcrist) URL: #8291
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt to make the
estimators_attribute available on fitted random forests. Closes #8018The basic idea is to create a structure in
rf.estimators_that mimics what is present in the scikit-learn attribute. For scikit-learn this is a "natural" thing to do, because the random forest is made of individual decision trees. For cuml this isn't the case. This means we have to extract the individual "trees" from the treelite model after fitting. It also means that these decision trees are not fully functional (e.g. you can't callfit()on one of them). But they do give you access to the information tools likeskforecastlook for.A lot of the testing in
test_rf_estimators.pyis about trying to figure out if the information in the individual trees is correct and consistent with what you get from the forest.Most of the implementation itself was written by AI. In particular the part on how to extract information about the individual trees from treelite. The idea and structure of the code is human made, as well as what to test (and how). I'm still working through this to convince myself that we either not expose information or if we do that it is correct. The naming of the classes and sub-module is not ideal, if you have ideas for better names let me know (in particular wrt how to signal to users that these are not fully functional trees).