Skip to content

FEA Add estimators_ attribute to random forest estimators - #8238

Draft
betatim wants to merge 6 commits into
NVIDIA:mainfrom
betatim:add-rf-estimators_-attribute
Draft

FEA Add estimators_ attribute to random forest estimators#8238
betatim wants to merge 6 commits into
NVIDIA:mainfrom
betatim:add-rf-estimators_-attribute

Conversation

@betatim

@betatim betatim commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This is an attempt to make the estimators_ attribute available on fitted random forests. Closes #8018

The 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 call fit() on one of them). But they do give you access to the information tools like skforecast look for.

A lot of the testing in test_rf_estimators.py is 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).

@copy-pr-bot

copy-pr-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the Cython / Python Cython or Python issue label Jun 8, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Cython / Python Cython or Python issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recent versions of skforecast need RandomForestRegressor.estimators_

2 participants