TREE LAB
Seedling0 XP
All projects

A field guide to random forests & XGBoost

The TreeLab.

How do computers make guesses? A lot of the time, with trees. No math needed here. You learn by playing with them.

1 tree asks yes/no questions100 trees voteBoosting fixes mistakes
Start the lab
PlateI

One tree

A tree plays 20 questions.

Fig. 1

Start with a pile of blue and coral dots

Fig. 2

Ask one yes / no question, which draws a line

Fig. 3

Keep asking until each side is one color

Your jobMove the line until the colors are sorted as cleanly as possible.

Drag the line
BlueCoralQuiz dots (the tree never sees these)

The question

Is x < 0.50?

Move the line0.50

Yes side

-

No side

-

Mess scoreBest: ?
0.000

Lower = cleaner sides. Turns green when you nail it.

Mission 1Turn the mess meter green by moving the line yourself.

+100 XP
PlateII

Random forest · part 1

One tree memorizes. So grow a bunch.

Fig. 1

Each tree gets a random handful of the dots

Fig. 2

Some dots get picked twice, some get skipped

Fig. 3

So every tree turns out a little different

Your jobGrow 5 trees and see how different they look.

Press grow
PickedSkipped×2 = picked twice
-Dots this tree saw
-Dots it skipped
0Trees

Your forest

No trees yet. Grow one.

Every square is a whole tree's guess map. Same dots, different handfuls, different trees.

Mission 2Grow 5 trees.

+100 XP
PlateIII

Random forest · part 2

Then all the trees vote.

Fig. 1

A new dot shows up

Fig. 2

Every tree votes on its color

Fig. 3

The color with the most votes wins

Your jobTap the plot to drop a dot, then grow the forest to 50 trees.

Tap anywhere
Trees in the forest0

The vote

Tap the plot to drop a dot.

-Forest score on new dots
-One huge tree

Crowd bonus: -

ForestOne huge tree

Mission 3Grow the forest to 50 trees.

+100 XP
PlateIV

XGBoost · boosting

Each new tree fixes the last one’s mistakes.

Fig. 1

Start with a flat line as the first guess

Fig. 2

Look at the misses

Fig. 3

Add a small tree that fixes them

Fig. 4

Repeat and the misses keep shrinking

Your jobAdd trees until the misses shrink to under 20% of where they started.

Fixes added 0

The guess (blue) vs. the real dots

The misses (red) and the newest fix (blue)

Dots it learns fromQuiz dotsMissGuess / fix
Step size (learning rate)0.30
Tree size2
-Miss size
-Miss on quiz dots
100%Of where it started
MissesMisses on quiz dots
Small stepsSlow and steady.
Big stepsFast, but it starts chasing random noise. Watch the yellow line climb back up.

Mission 4Shrink the misses under 20% of where they started.

+100 XP
PlateV

XGBoost · pruning

Cut the branches that barely help.

Fig. 1

Grow a tree

Fig. 2

Score each branch on how much it helped

Fig. 3

Cut the ones that barely helped

Your jobTurn up the pickiness until 2 branches get cut.

Misses (dots) and what this tree predicts (blue)

Pickiness (gamma)0.00

A branch has to help at least this much to stay. Every box shows how much it helped.

-Branches kept
0Branches cut

Mission 5Cut at least 2 branches.

+100 XP
Show the math (optional)
Calm-down knob (lambda)1.0

Bigger lambda = smaller, more careful fixes. Tap any box in the tree to see its numbers.

PlateVI

Showdown

Forest vs. Boost. Who wins?

Fig. 1

Forest: 60 big trees that vote

Fig. 2

Boost: 60 small trees, each fixing the last

Fig. 3

Both get graded on new dots

Your jobPick a dataset and hit start.

Random Forest Trees 0

Winner
Score-

XGBoost Trees 0

Winner
Score-
Random ForestXGBoost

Mission 6Finish a race.

+100 XP
PlateVII

Recap + quiz

Lock it in.

Random Forest

  • ❧Lots of big trees
  • ❧Each gets a random handful of dots
  • ❧Built all at once
  • ❧They vote
  • ❧Hard to mess up

XGBoost

  • ❧Lots of small trees
  • ❧Each one learns the last one's misses
  • ❧Built one after another
  • ❧The fixes add up
  • ❧Usually wins, but needs tuning

Streak

0

Progress

Mission 7Finish the quiz.

+100 XP

See it in real life

My FRC Match Predictor uses XGBoost.

Same idea as chapter 4. It learned from 18,000+ robotics matches and calls the winner before the match starts.

Try it
+100Mission completeNice.