Out-of-Bag Error
Study guide: Exam MAS-II
The Out-of-Bag Error is an estimate of the test error of a bagged model, made from the observations each bootstrap sample leaves out. A bootstrap sample of size n, drawn with replacement, leaves out a given observation with probability
\left(1 - \frac{1}{n}\right)^{n} \approx e^{-1} = 0.368
An observation is out of bag for a tree if it is not in that tree's bootstrap sample. Each observation is out of bag for about 0.368B of the B trees, roughly a third.
A random forest of 600 trees is fitted to 4,000 claims. About how many trees are out of bag for one claim?
- The probability a claim is left out of one sample is
(1 - 1/4{,}000)^{4{,}000} = 0.368.- About
0.368 \times 600 = 221trees never saw the claim.
Computing the out-of-bag error
The out-of-bag prediction for observation i averages the predictions of only the trees for which i is out of bag, or takes their majority vote for classification. The out-of-bag error is the MSE or classification error rate of these predictions over all the training observations. It needs no extra fitting, because it comes from the trees already grown. With B large, it is virtually equivalent to the leave-one-out cross-validation error.
The out-of-bag error is defined only for methods that resample. A single decision tree or a boosted model has none.
An observation with
y = 15is out of bag for three trees, which predict10,12and14. What is its out-of-bag prediction and squared error?
- The out-of-bag prediction is
(10 + 12 + 14)/3 = 12.- Its squared error is
(15 - 12)^2 = 9, one term of the out-of-bag MSE.
Using every tree An observation's out-of-bag prediction uses only the trees that did not see it. Averaging all
Btrees includes trees fitted to it and gives an optimistic training error, not a test-error estimate.