Repository navigation
Conversation
…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
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. |
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.
Reference Issues/PRs
Fixes #33568
What does this implement/fix? Explain your changes.
The
splitterparameter description for'random'previously read: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:
max_featurescandidate features are drawn at random.uniformly between that feature's observed minimum and maximum values.
(feature, threshold)pair with the best impurity improvementis selected.
The clarification is applied consistently to all four affected classes:
DecisionTreeClassifier,DecisionTreeRegressor,ExtraTreeClassifier, andExtraTreeRegressor.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