Skip to content

Switch RandomForest max_depth default to None - #8200

Merged
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
csadorf:pr-7958
Jun 2, 2026
Merged

Switch RandomForest max_depth default to None#8200
rapids-bot[bot] merged 2 commits into
NVIDIA:mainfrom
csadorf:pr-7958

Conversation

@csadorf

@csadorf csadorf commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Changes RandomForestClassifier, RandomForestRegressor, and their Dask variants to use max_depth=None as the default now that unlimited-depth support is available. Also removes the 26.06 deprecation sentinel and updates tests/docs to expect the new default.

Validation:

  • python -m pytest python/cuml/tests/test_random_forest.py -k "default_parameters or unlimited_max_depth"
  • python -m pytest python/cuml/tests/dask/test_dask_random_forest.py -k "unlimited_max_depth"
  • python -m pytest python/cuml/tests/test_sklearn_compatibility.py -k "RandomForest"

Closes #7946

@csadorf csadorf added improvement Improvement / enhancement to an existing function breaking Breaking change labels Jun 1, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jun 1, 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 1, 2026
@csadorf

This comment has been minimized.

@csadorf
csadorf marked this pull request as ready for review June 1, 2026 22:09
@csadorf
csadorf requested a review from a team as a code owner June 1, 2026 22:09
@csadorf
csadorf requested a review from betatim June 1, 2026 22:09
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 393dfb5c-2928-4b38-a1be-3ee8379d3780

📥 Commits

Reviewing files that changed from the base of the PR and between cf6a546 and df38839.

📒 Files selected for processing (18)
  • python/cuml/cuml/dask/ensemble/base.py
  • python/cuml/cuml/dask/ensemble/randomforestclassifier.py
  • python/cuml/cuml/dask/ensemble/randomforestregressor.py
  • python/cuml/cuml/ensemble/randomforest_common.pyx
  • python/cuml/cuml/ensemble/randomforestclassifier.py
  • python/cuml/cuml/ensemble/randomforestregressor.py
  • python/cuml/tests/dask/test_dask_random_forest.py
  • python/cuml/tests/explainer/test_explainer_common.py
  • python/cuml/tests/explainer/test_explainer_kernel_shap.py
  • python/cuml/tests/explainer/test_gpu_treeshap.py
  • python/cuml/tests/test_api.py
  • python/cuml/tests/test_base.py
  • python/cuml/tests/test_common.py
  • python/cuml/tests/test_fil.py
  • python/cuml/tests/test_meta_estimators.py
  • python/cuml/tests/test_pickle.py
  • python/cuml/tests/test_random_forest.py
  • python/cuml/tests/test_sklearn_compatibility.py
💤 Files with no reviewable changes (9)
  • python/cuml/tests/explainer/test_gpu_treeshap.py
  • python/cuml/tests/test_common.py
  • python/cuml/tests/dask/test_dask_random_forest.py
  • python/cuml/tests/explainer/test_explainer_common.py
  • python/cuml/tests/test_fil.py
  • python/cuml/cuml/dask/ensemble/base.py
  • python/cuml/tests/explainer/test_explainer_kernel_shap.py
  • python/cuml/tests/test_meta_estimators.py
  • python/cuml/tests/test_pickle.py

📝 Walkthrough

Summary by CodeRabbit

  • Documentation

    • Updated Random Forest classifier and regressor documentation to reflect new default parameter values and version information.
  • Bug Fixes

    • Removed deprecation warnings previously displayed during model fitting.
    • Simplified parameter validation logic in Random Forest models.
    • Updated test suites and warning filters across the codebase to align with revised defaults.

Walkthrough

This PR removes the max_depth=16 deprecation cycle by eliminating the deprecated sentinel value, associated FutureWarning logic, and all test warning suppressions. The default max_depth parameter changes from 16 to None (unlimited depth) across CPU and Dask RandomForest estimators, with updated docstrings and test expectations.

Changes

Default max_depth switch and deprecation removal

Layer / File(s) Summary
Core CPU RandomForest API default switch
python/cuml/cuml/ensemble/randomforestclassifier.py, python/cuml/cuml/ensemble/randomforestregressor.py, python/cuml/cuml/ensemble/randomforest_common.pyx
RandomForestClassifier and RandomForestRegressor constructor parameters change from "deprecated" sentinel to None. BaseRandomForestModel in the cython layer updates its default to None and removes sentinel-to-16 mapping in _params_to_cpu. Docstrings updated to reflect new default and versionchanged:: 26.08 directive.
Dask RandomForest API and deprecation logic removal
python/cuml/cuml/dask/ensemble/base.py, python/cuml/cuml/dask/ensemble/randomforestclassifier.py, python/cuml/cuml/dask/ensemble/randomforestregressor.py
Dask BaseRandomForestModel removes max_depth user-tracking logic, FutureWarning emission in _fit, and set_params bookkeeping. Dask classifier and regressor docstrings updated to document None default.
Core test expectations and warning filters
python/cuml/tests/test_random_forest.py, python/cuml/tests/test_sklearn_compatibility.py
test_random_forest.py removes global warning filter, removes pytest.warns() expectations around fit calls, and adds assertions verifying max_depth=None in get_params(). test_sklearn_compatibility.py removes explicit max_depth=None from ESTIMATORS instantiation.
Test warning filter updates across suite
python/cuml/tests/{dask/test_dask_random_forest.py, test_api.py, test_base.py, test_common.py, test_meta_estimators.py, test_pickle.py, test_fil.py, explainer/test_*.py}
Remove module-level pytestmark filters for max_depth deprecation FutureWarning across all affected test modules; replace with alternative warning filters where needed (e.g., as_fil() deprecation in test_fil.py, forest-inference in test_explainer_common.py).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • rapidsai/cuml#7895: Implements max_depth=None support for unlimited depth in RandomForest estimators; this PR completes the deprecation cycle by removing the deprecated sentinel and switching the default.
  • rapidsai/cuml#7958: Related deprecation removal PR that handles the same max_depth deprecation plumbing across CPU and Dask variants.
  • rapidsai/cuml#8113: Adds rapids-pre-commit-hooks suppression comments around the max_depth deprecation warning block that this PR removes entirely.

Suggested labels

sklearn-api-compat

Suggested reviewers

  • jcrist
  • hcho3
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: switching RandomForest max_depth default from 16 to None.
Description check ✅ Passed The description clearly explains the changes made: default max_depth switch to None, removal of deprecation sentinel, and updates to tests/docs.
Linked Issues check ✅ Passed All requirements from issue #7946 are met: max_depth default changed to None in all variants [#7946], deprecation warning removed [#7946], and documentation/tests updated [#7946].
Out of Scope Changes check ✅ Passed All changes are directly related to switching max_depth default to None; no unrelated or out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@jcrist jcrist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jcrist

jcrist commented Jun 2, 2026

Copy link
Copy Markdown
Member

/merge

@rapids-bot
rapids-bot Bot merged commit 8446aa4 into NVIDIA:main Jun 2, 2026
100 checks passed
@csadorf
csadorf deleted the pr-7958 branch June 2, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change Cython / Python Cython or Python issue improvement Improvement / enhancement to an existing function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch default max_depth to None in RandomForest estimators

4 participants