Random Forests: Bagging and Out-of-Bag Validation
Learning objectives
- Draw a bootstrap of the rows and say why it leaves about a third of them out of each tree
- Explain bagging: trees grown on bootstraps overfit in different ways, and their vote cancels part of it
- Read a forest's out-of-bag accuracy as trees are added, against each tree's own
- Say why the out-of-bag score of a forest grown on wells flatters it on a new well, and what to score instead
Many Trees, Each on Its Own Rows
A random forest grows many decision trees, each on a bootstrap of the rows: as many rows as there are, drawn with replacement, so each tree sees about two thirds of them, some twice, and never sees the rest; at each split it also chooses among a few logs drawn at random. The trees overfit their bootstraps in different ways, and their vote cancels much of it: that is bagging. The rows a tree never saw give it an out-of-bag vote, a validation that costs no extra data. On the Ogbon field's nine wells, from the porosity logs alone, one tree calls 0.809 of its out-of-bag rows right on average and the vote of 100 trees 0.872; with log10 RT, 0.982 and 0.990. But an out-of-bag row lies half a foot from rows of the same well that the voting trees learned from: held out one well at a time, the same forest calls 0.976.
The Data
The data are the book's own learning set: Ogbon-1, the Petrophysics book's well, and eight hypothetical appraisal wells of the book's field, each 1201 samples every 0.5 ft, 10809 in all, logged by Ogbon-1's own build and the book's own tool model, all synthetic. The class is pay, the Petrophysics book's net-pay rule on the generator's truth. The forest reads the logs as they are, unscaled, since a tree reads only the order of a log (Section 7.2). It is precomputed in the book's forest table: 100 trees on 10809 rows take seconds in node and far longer on a phone. Plate (a) is drawn on the page, from the kernel's own generator.
The Bootstrap
Drawing n rows from n with replacement leaves a given row out with probability , which for n = 10809 is 0.368, close to . Tree 1's bootstrap draws 6810 distinct rows, 1957 of them twice and 719 three times, and leaves 3999 out, a share of 0.370. Over the forest's 100 trees a bootstrap keeps 0.632 of the rows on average.
Bagging
Each tree is grown unpruned, a leaf for as few as 1 sample, and each split chooses among 2 logs drawn at random: alone, a tree fits its bootstrap to the last sample. On the porosity logs, which see clean rock and not the oil in it, every one of the 100 trees calls between 0.798 and 0.822 of its own out-of-bag rows right. The forest's vote climbs from 0.803 at one tree to 0.819 at ten and 0.872 at 100, and not one of the trees does as well alone. With log10 RT the trees are good already, 0.972 to 0.986 each, and the vote reaches 0.990: a vote gains less when its trees make fewer mistakes, and it cannot cancel the mistakes they all make.
Out of Bag
For each row the trees whose bootstraps missed it vote, a tie going to not pay, and the out-of-bag accuracy is the share of the rows with a vote whose vote is the truth. After one tree only its 3999 out-of-bag rows have a vote; after ten trees, 10716 rows; by 100, all 10809. The curve in plate (b) levels off: with log10 RT it is 0.989 at 30 trees and 0.990 at 100. More trees steady the vote; they do not make the trees better.
What Out of Bag Measures
An out-of-bag row was in none of the bootstraps of the trees that vote on it, but the rows half a foot above and below it usually were, and so were the rest of its well. On Ogbon-8, the well wholly in the water leg, the out-of-bag vote with log10 RT calls 1.000 of the rows right; held out as a whole well, the forest grown on the other eight calls 0.872. Over the nine wells the out-of-bag score is 0.990 and the held-out score 0.976. Out of bag is an honest estimate for rows drawn independently; for logs, which come in wells, it scores the wells the forest has seen. On the porosity logs, where the trees cannot learn much that a well's neighbouring samples share, the two are closer: 0.872 out of bag, 0.864 held out.
What Comes Next
Section 8.2, the chapter's workshop, grows the same forest on eight wells at a time, scores it on the ninth, and asks which logs it leans on.