8000 ENH Add option to pass custom scorer for RandomForest OOB calculation by betatim · Pull Request #25177 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@betatim
Copy link
Member
@betatim betatim commented Dec 12, 2022

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_score parameter. This will be used instead of the accuracy/R2 score that is the default for classification/regression problems.

@betatim betatim force-pushed the rf-custom-oob-scoring branch from 9a18f0e to 4ff5975 Compare December 12, 2022 16:37
@glemaitre glemaitre self-requested a review December 14, 2022 10:50
Copy link
Member
@glemaitre glemaitre left a 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.

8000
@betatim
Copy link
Member Author
betatim commented Dec 16, 2022

Thanks for the feedback! Switched to the approach you suggested.

Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @betatim

8000 @betatim betatim added the Waiting for Second Reviewer First reviewer is done, need a second one! label Dec 19, 2022
Copy link
Member
@thomasjpfan thomasjpfan left a 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?

def _set_oob_score_and_attributes(self, X, y):
raise NotImplementedError("OOB score not supported by tree embedding")

@betatim
Copy link
Member Author
betatim commented Dec 20, 2022

Implemented both ideas.

Copy link
Member
@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan changed the title Add option to pass custom scorer for RandomForest OOB calculation ENH Add option to pass custom scorer for RandomForest OOB calculation Dec 22, 2022
@thomasjpfan thomasjpfan merged commit 0b202ca into scikit-learn:main Dec 22, 2022
@betatim betatim deleted the rf-custom-oob-scoring branch January 3, 2023 08:26
jjerphan pushed a commit to jjerphan/scikit-learn that referenced this pull request Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ensemble Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to choose OOB scorer in RandomForest

4 participants

0