I would like to use the OOB cases from a random forest fit to estimate the mean squared prediction error so I don't have to cross-validate. I am using the randomForest package in R. It is clear from the documentation that OOB error is reported for classification, but I can't figure out how to get OOB MSPE for regression. Am I missing it or is it truly not reported, which seems odd?
Contents
hide
Best Answer
It's not reported.
But you can use the predicted
part of the fit, which as per the help page yields
the predicted values of the input data based on out-of-bag samples.
An example:
set.seed(131) ozone.rf <- randomForest(Ozone ~ ., data=airquality,na.action=na.omit) mean((ozone.rf$predicted-airquality$Ozone[as.numeric(names(ozone.rf$predicted))])^2) [1] 316.7915
Similar Posts:
- Solved – Out of Bag Prediction Error Estimate from Random Forest Regression (i.e., not classification)
- Solved – Out of Bag Prediction Error Estimate from Random Forest Regression (i.e., not classification)
- Solved – How to report confusion matrix of Random Forest classifier on test set using R?
- Solved – RandomForest( ) more than 32factor levels
- Solved – How to plot an ROC curve?