Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 949
William Cha Avatar asked Sep 12 '25 09:09

William Cha


1 Answers

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.

like image 124
PhilippPro Avatar answered Sep 15 '25 00:09

PhilippPro