Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is oob_score_ calculated in sklearn.RandomForestRegressor?

How exactly is the OOB score calculated for random forest regression in scikit-Learn?

I am aware that it arises from the out-of-bag samples that are not included in the bootstrap sample, but I cannot find any specific description besides Scikit Learn: OOB Errors for Random Forests, which is specific to RandomForestClassifier.

I have also tried doing a wider search for methodology, but the only note I could find on it was on Page 17 of these lecture notes from Duke University, which states that

An OOB prediction can be obtained in this way for each of the n observations, from which the overall OOB MSE (for a regression problem) [...] can be calculated.

Is OOB mean squared error the method that is used for random forest regression in scikit-learn?

like image 894
cbass798 Avatar asked Nov 28 '25 13:11

cbass798


1 Answers

As you can see here in the source code, the score is set in the following line:

self.oob_score_ = r2_score(y, self.oob_prediction_)

So no, it's OOB R^2.

like image 138
jprebys Avatar answered Nov 30 '25 04:11

jprebys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!