I asked this question on Stackoverflow, but it's likely that I will received no answer on that site. So I cross-post my question here.
I'm using the function randomForest
from package randomForest
. One of the objects of class randomForest is err.rate
which is
(classification only) vector error rates of the prediction on the input data, the i-th element being the (OOB) error rate for all trees up to the i-th.
Could you please explain what is the meaning of this component? Thank you so much for your help!
I take the dataset Sonar, Mines vs. Rocks
as an code example.
library(mlbench)
data(Sonar)
library(boot)
library(randomForest)
n <- 208
ntrain <- 100
ntest <- 108
train.idx <- sample(1:n, ntrain, replace = FALSE)
train.set <- Sonar[train.idx, ]
test.set <- Sonar[-train.idx, ]
rf <- randomForest(Class ~ ., data = train.set, keep.inbag = TRUE, importance = TRUE)
head(rf$err.rate)
Here is the result of the code
OOB M R
[1,] 0.1891892 0.1500000 0.2352941
[2,] 0.2931034 0.2307692 0.3437500
[3,] 0.2739726 0.2647059 0.2820513
[4,] 0.2911392 0.2894737 0.2926829
[5,] 0.2413793 0.2682927 0.2173913
[6,] 0.2555556 0.2142857 0.2916667
[7,] 0.2553191 0.2444444 0.2653061
[8,] 0.2268041 0.1956522 0.2549020
[9,] 0.2783505 0.2608696 0.2941176