2.3.9 · D1Tree-Based & Instance Methods

Foundations — Out-of-bag error estimation

2,018 words9 min readBack to topic

This page assumes you have seen nothing. Every letter, ratio, and squiggle in the parent note gets built here, one brick at a time, so that when you read the main OOB topic note every symbol is already an old friend.


0. What is a "dataset" and what does mean?

The picture: think of numbered cards laid in a row. Card carries a question () on the front and its correct answer () on the back.

Why the topic needs it: OOB error is measured per example, so we must be able to point at "example number " precisely. The subscript is that pointing finger.

Figure — Out-of-bag error estimation

1. Drawing "with replacement" — the heart of everything

The word bootstrap means: build a new sample of size by picking cards one at a time, and each time putting the card back before the next pick. Putting it back = "with replacement".

The picture: a jar of balls. You reach in, read a ball's number, drop it back, shake, and reach again — times total. Your new list may read for : ball 3 and ball 5 were never scooped.

Figure — Out-of-bag error estimation

Why the topic needs it: "with replacement" is the single mechanism that manufactures a free test set. No replacement → every card is picked exactly once → nothing is ever left out → no OOB. See Bootstrap Sampling.


2. Probability — reading

The picture: a pie sliced into equal wedges. One wedge = your card. Its slice of the whole pie is of the area.

Why the topic needs it: the famous "37% is out-of-bag" number is a probability. To earn it you must first be comfortable that "not this one card" .


3. Independent events → multiply

The picture: flip a coin twice. Chance of two heads . Each independent flip multiplies in a fresh factor.

Here the raised exponent is not magic notation — it literally means "multiply the same factor by itself times, once per draw".

Why the topic needs it: a whole bootstrap sample is draws. To leave card out we need it missed every single time — that "every time" is what turns the exponent into .


4. The number and the limit — why 37%?

The picture: plot against . As climbs, the dots flatten onto a horizontal line at about . They never wander off — they converge.

Figure — Out-of-bag error estimation

So ≈ 36.8% of cards fall out-of-bag per tree, and the rest, ≈ 63.2%, stay in-bag.

Why the topic needs it: this single ratio (37 out / 63 in) is the reason OOB is a usable test set. If only 1% were left out, each point would rarely be OOB and the estimate would be starved.


5. Sets and the symbols , , ,

The picture: a fenced pen () with a few numbered sheep inside. = "this sheep is inside the fence"; = "this sheep is outside"; = "count the sheep inside".

In the parent note, reads plainly as: " is the collection of tree-numbers such that example is not in tree 's bootstrap sample" — i.e. the trees for which is OOB.

Why the topic needs it: OOB prediction for a point only uses that point's own — the exact trees that never trained on it. Sets are how we name "just those trees".


6. Indexing the trees: , ,

The picture: a shelf of trained trees, each a little machine. Feed into machine and out drops a guess .

Why the topic needs it: the forest (Random Forests, built by Bootstrap Aggregating (Bagging)) is a collection of trees. Every OOB formula is a sum or vote over some subset of these machines.


7. Aggregation, loss, and the summation sign

The picture: is a conveyor belt: each example drops its loss onto the belt, and at the end you read the total — then divide by to get the average.

Why the topic needs it: the final OOB error is exactly this average loss: Every symbol in that line — , , , , — is now defined.

Figure — Out-of-bag error estimation

8. How it all snaps together

Dataset of n examples x_i y_i

Draw with replacement bootstrap

In-bag picked cards

Out-of-bag left-out cards

Probability 1 minus 1 over n

Multiply over n draws independent

Limit gives e to the minus 1 about 0.368

Set S_i trees that never saw i

Trees T_b trained here

Aggregate vote or average

Loss L then sum divide by n

OOB error estimate of test error

Read top-left to bottom-right: the with-replacement draw splits each tree's data into in-bag and out-of-bag; the probability chain explains why ~37% land out-of-bag; the set gathers each point's honest trees; aggregation + loss + turn those honest guesses into one number — the OOB error, a cheap stand-in for Cross-Validation that measures the test error of the forest.


Equipment checklist

Test yourself — cover the right side and answer aloud.

What does stand for?
The number of examples (rows) in your dataset.
What do the subscript and the notation mean?
points to a specific example; is its inputs, its true label.
What does "with replacement" mean and why does it matter?
Each pick is put back before the next, so a card can repeat or be missed — missing is what creates OOB points.
What is the difference between in-bag and out-of-bag?
In-bag = distinct cards the tree trained on; out-of-bag = cards never picked, unseen by that tree.
Why is ?
The one wanted card has chance ; "not it" is the remaining of wedges.
Why do we raise it to the power ?
The draws are independent, so multiply the per-draw miss chance times.
What does mean here?
The value that settles toward as grows very large.
What is numerically and what does it represent?
About ; the fraction of data out-of-bag per tree for large .
Read in words.
The set of tree indices for which example was NOT in the bootstrap — its OOB trees.
What does mean?
The number of trees for which point is out-of-bag.
What does compute?
The total .
What does the hat in signify?
A predicted/estimated value, not the true label.
What is 0/1 loss vs squared error?
0/1 loss is 0 if correct else 1 (classification); squared error is (regression).