ENH Add option to pass custom scorer for RandomForest OOB calculation - #25177
Merged
Conversation
Check if the oob_score is a function, if yes pass it in, otherwise don't.
glemaitre
reviewed
Dec 12, 2022
betatim
force-pushed
the
rf-custom-oob-scoring
branch
from
December 12, 2022 16:37
9a18f0e to
4ff5975
Compare
glemaitre
self-requested a review
December 14, 2022 10:50
glemaitre
reviewed
Dec 14, 2022
glemaitre
left a comment
Member
There was a problem hiding this comment.
LGTM. I would just prefer to have the same signature between the abstract method and specialized one and inside the body of the code to specialize to accuracy or r2 score.
Member
Author
|
Thanks for the feedback! Switched to the approach you suggested. |
glemaitre
approved these changes
Dec 16, 2022
thomasjpfan
reviewed
Dec 19, 2022
thomasjpfan
left a comment
Member
There was a problem hiding this comment.
Thank you for the PR!
Nit: For consistency, can we update the signature of RandomTreesEmbedding._set_oob_score_and_attributes to match the new one?
scikit-learn/sklearn/ensemble/_forest.py
Lines 2701 to 2702 in ce89a4f
Member
Author
|
Implemented both ideas. |
thomasjpfan
reviewed
Dec 20, 2022
jjerphan
pushed a commit
to jjerphan/scikit-learn
that referenced
this pull request
Jan 3, 2023
…scikit-learn#25177) Co-authored-by: simonandras <[email protected]>
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.
Check if the oob_score is a function, if yes pass it in, otherwise
don't.
Reference Issues/PRs
Continuation of #23043. Closes #21521
What does this implement/fix? Explain your changes.
If the user wants to use a different score function to compute the OOB score they can now pass a callable to the
oob_scoreparameter. This will be used instead of the accuracy/R2 score that is the default for classification/regression problems.