'Can I see the out of bag error for regression tasks in the R randomForest package?
I'm using the randomForest package in R for prediction, and want to plot the out of bag (OOB) errors to see if I have enough trees, and to tune the mtry (number of variables at each split) variable. The package seems to automatically compute the OOB errors for classification tasks, but doesn't do so for regression tasks. Does anyone know if there is a way to look at the OOB errors for regressions tasks?
Solution 1:[1]
You can also look directly at the out of bag predictions:
data(airquality)
set.seed(131)
ozone.rf <- randomForest(Ozone ~ ., data=airquality, mtry=3,
importance=TRUE, na.action=na.omit)
ozone.rf$predicted
And then you can calculate also other measures like eg median absolute error.
Solution 2:[2]
As said in the comments the mse object is computed OOB. See page 20 in https://datajobs.com/data-science-repo/Random-Forest-%5bLiaw-and-Weiner%5d.pdf Hence, the mse object is already an estimate of the OOB mean squared error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | PhilippPro |
| Solution 2 | JRT |
