Skip to content

DOC: clarify splitter='random' behavior in DecisionTree/ExtraTree docstrings - #33576

Closed
AutoHmn13 wants to merge 2 commits into
scikit-learn:mainfrom
AutoHmn13:doc-gh33568-random-splitter-clarify
Closed

AutoHmn13 wants to merge 2 commits into
scikit-learn:mainfrom
AutoHmn13:doc-gh33568-random-splitter-clarify

Conversation

@AutoHmn13

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #33568

What does this implement/fix? Explain your changes.

The splitter parameter description for 'random' previously read:

"random" to choose the best random split

This is ambiguous — it does not explain how the random strategy actually
works. Based on the implementation in sklearn/tree/_splitter.pyx
(lines 594–706), the updated docstring explains the full process:

  • Up to max_features candidate features are drawn at random.
  • For each candidate feature, a single split threshold is sampled
    uniformly between that feature's observed minimum and maximum values.
  • The (feature, threshold) pair with the best impurity improvement
    is selected.

The clarification is applied consistently to all four affected classes:
DecisionTreeClassifier, DecisionTreeRegressor,
ExtraTreeClassifier, and ExtraTreeRegressor.

Any other comments?

The existing opening sentence is preserved verbatim; the new detail is
appended as a follow-on sentence so the short summary continues to read
cleanly.

AI Generation Disclosure

Cursor (Claude) was used as a coding assistant. The assistant helped
locate the relevant source code and draft the docstring wording. All
changes were reviewed and accepted by the contributor before submission.

Made with Cursor

…arngh-33568)

The previous description ("random to choose the best random split") was
ambiguous about how the random strategy actually works. Based on the
implementation in _splitter.pyx, the updated docstring explains that
up to max_features candidate features are drawn at random, a single
threshold is sampled uniformly between each feature's observed min/max,
and the (feature, threshold) pair with the best impurity improvement
is selected.

Applied to DecisionTreeClassifier, DecisionTreeRegressor,
ExtraTreeClassifier, and ExtraTreeRegressor.

Made-with: Cursor
@betatim

betatim commented Mar 20, 2026

Copy link
Copy Markdown
Member

Thanks for making this PR. The docstring is not meant to be exhaustive, otherwise we'd have to explain a lot of things and they'd become unreadable. They are more like short reminders for those in the know or a jumping off point for those who need more details. The details needed to understand them should be in the user guide and/or example gallery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify how splits are selected in DecisionTree when using a random splitter

2 participants