0
$\begingroup$

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
$\endgroup$
3
  • 1
    $\begingroup$ The OOB error rate is the "out-of-bag" error rate, i.e., the error rate when predicting the observations not selected for training. The $i$th element is the OOB error rate for predictions based on the first $i$ trees; this is useful because as you train more trees, you expect the OOB error rate to decrease, but more-or-less stabilize (decrease very slowly) after a while, and it's useful to know when. $\endgroup$
    – jbowman
    Commented Mar 6, 2020 at 18:52
  • $\begingroup$ Thank you so much for your dedicated support @jbowman ;) $\endgroup$
    – Akira
    Commented Mar 6, 2020 at 22:53
  • 1
    $\begingroup$ That's what we're here for! $\endgroup$
    – jbowman
    Commented Mar 7, 2020 at 0:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.