-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
ENH Add option to pass custom scorer for RandomForest OOB calculation #25177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Add option to pass custom scorer for RandomForest OOB calculation #25177
Conversation
Check if the oob_score is a function, if yes pass it in, otherwise don't.
9a18f0e to
4ff5975
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
Thanks for the feedback! Switched to the approach you suggested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @betatim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| def _set_oob_score_and_attributes(self, X, y): | |
| raise NotImplementedError("OOB score not supported by tree embedding") |
|
Implemented both ideas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…scikit-learn#25177) Co-authored-by: simonandras <simonandras97@gmail.com>
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.