Intuition The one core idea
A decision tree slices your data into rectangular boxes by asking one yes/no question at a time, and inside each box it gives a single answer. To read the parent note fluently you only need to picture points on a grid , the question that draws a line , and the box that line helps carve out — everything else (Gini, pruning, forests) is just how those lines get chosen.
This page assumes you know how to count and read a graph with an x and y axis. Nothing more. We build every symbol the parent note throws at you, in an order where each piece stands on the one before it.
Before any tree exists, we have a table of data . Picture a spreadsheet.
Definition Sample (also "example", "data point", "row")
A sample is one thing you measured — one customer, one email, one flower. In a picture it is one dot placed on a grid.
Definition Feature (also "attribute", "column", "input")
A feature is one measurable property of a sample — Age, Income, petal length. Each feature becomes one axis of the grid. Two features → a flat 2D grid you can draw.
Definition Target (also "label", "output",
y )
The target is the thing you want to predict. If it is a category (cat / dog, reject / accept) we colour the dot. If it is a number (price = 14.2) we could write the number next to the dot.
How to read this figure: each dot is one sample . Its horizontal position is Feature 1 (Income) and its vertical position is Feature 2 (Age) — the two axes . Its colour is the target: magenta dots are class A, violet dots are class B. Notice the two colours already sit in different corners of the grid — that separation is exactly what a tree will try to fence off with straight cuts. The orange arrow points at one single dot to remind you: one dot = one row of the spreadsheet = one sample .
Why the topic needs this: a decision tree's entire job is to look at where the dots sit (features) and predict their colour or number (target). No dots, no tree.
The parent note writes things like x j and y i . These little lowered letters are just labels that say "which one" .
Intuition Two different jobs for a subscript
i (and ℓ ) point at samples — which dot.
j points at features — which axis.
Same idea (a pointer), different things pointed at. Keep them straight and every formula in the parent unlocks.
We meet one more symbol, ∈ , in section 3 — but only after we have defined the box R ℓ that a dot can belong to. We build the box first.
Why the topic needs this: the leaf-prediction formulas point at individual dots (y i ) and individual features (x j ); without subscripts you can't say which one.
This is the heart of the whole topic.
≤
≤ means less than or equal to . x j ≤ t asks: "is feature j 's value no bigger than the number t ?" The answer is only ever yes or no .
Here is the visual that makes "axis-aligned" click:
Intuition Why a test is a straight line perpendicular to an axis
The question "x 1 ≤ 30 ?" cares about nothing except the horizontal position of a dot. Every dot with x 1 = 30 sits on one vertical line . Dots to the left answer yes ; dots to the right answer no . So one test = one line at right angles to one axis. That is exactly what axis-aligned means, and why diagonals like x 1 + x 2 ≤ 5 are not allowed — that line would tilt, using two features at once.
Why the topic needs this: every internal node in the parent note is one of these tests. Stack a few and you carve the grid into boxes (next section).
R ℓ
R ℓ is the set of samples (the box) owned by leaf ℓ . The subscript ℓ is just a name-tag for "this particular leaf". Picture a fenced rectangle on the grid; R ℓ = all dots inside that fence.
Definition Hyper-rectangle
A hyper-rectangle is the fancy word for "a box whose sides are parallel to the axes", in any number of features. In 2D it is a plain rectangle; in 3D a shoebox; in more dimensions we can't draw it but the idea is identical.
Now that a box R ℓ exists, the membership symbol has something to point into:
Intuition Why the boundary is a staircase
Because every cut is a straight axis-aligned line, the border between "predict red" and "predict blue" can only go horizontally or vertically, never at an angle . Assemble many such cuts and the boundary looks like stair-steps — never a smooth diagonal. This is the reason a single tree's prediction surface is a staircase.
Definition Empty region (the degenerate box)
A split can send all dots to one side, leaving the other child with ∣ R ℓ ∣ = 0 — a box with no dots inside . This is the degenerate case you must plan for. Standard implementations simply never create such a leaf (a split that empties a child is rejected), or, if one arises, the leaf inherits its parent's prediction so it still has an answer. Keep this in mind: the formulas below quietly assume ∣ R ℓ ∣ ≥ 1 .
The parent derives two leaf predictions. Let's arm every symbol first. Throughout, every sum runs over i ∈ R ℓ — only the dots inside this leaf's box , never all samples.
^
A hat over a letter means "our guess / estimate" , not the true value.
y i = the true answer of dot i .
y ^ ℓ = the one guess the whole leaf ℓ hands out.
∑
∑ i ∈ R ℓ ( something i ) means "add up 'something' for every dot in the box" . The big Greek S is just a compact "add these all". The subscript i ∈ R ℓ under the ∑ is doing real work: it restricts the walk to the dots of this leaf only . Picture walking through each dot in the fence and dropping its number into a running total.
Definition Indicator function
1 [ condition ]
The indicator outputs 1 when the condition is true, 0 when false . So 1 [ y i = y ^ ℓ ] is 1 exactly when the guess is wrong for dot i . Summing it over i ∈ R ℓ counts mistakes in this leaf .
arg max c
arg max c f ( c ) answers "which value of c makes f biggest?" — it returns the winner , not the size of the win. In a leaf, arg max c ∣ { i ∈ R ℓ : y i = c } ∣ = "which class label has the most dots?" → the majority vote .
Intuition Why majority vote minimises mistakes
Whatever label you announce, you are "wrong" for every dot that isn't that label. Pick the biggest colour-group and the fewest dots are left over as wrong. That is precisely why classification leaves predict the majority.
Definition Ties in the majority vote
If two classes have the same top count in R ℓ , arg max is ambiguous — several answers tie for "best". A strict rule must break the tie. The usual convention: pick the class with the smaller label / lower index (deterministic), or the class that is more frequent in the whole training set. Any fixed rule is fine as long as it is deterministic , so the same tree always gives the same answer. (scikit-learn, for instance, picks the lowest class index.)
For regression the parent takes a derivative. Here is why that tool and not another .
Intuition Why a derivative here?
We want the single number y ^ ℓ that makes the total squared error ∑ i ∈ R ℓ ( y i − y ^ ℓ ) 2 as small as possible . A derivative measures the slope of a curve — how fast the error changes as you nudge y ^ ℓ . At the very bottom of a valley the slope is flat (zero) . So "set derivative = 0 " is just the mathematical way of saying "find the flat bottom of the error bowl" . No other tool locates a minimum so directly.
Definition Cardinality bars
∣ ⋅ ∣
The straight bars mean count — "how many items are in this set". ∣ R ℓ ∣ = number of dots in the box. ∣ { i : y i = c } ∣ = how many dots have label c . Whenever ∣ R ℓ ∣ appears in a denominator, remember it must be at least 1 (the empty-region rule).
These are relationship words, not new maths.
Definition Family vocabulary
Root : the topmost node, holding all dots before any cut.
Parent / child : a node directly above / below another via one split — relative, like family.
Depth : the number of edges (arrows) on the longest path from root down to a leaf. Count the arrows, not the nodes.
Subtree : a node plus everything hanging below it .
Common mistake Counting depth by nodes, not edges
Why it feels right: you naturally count the boxes you pass through.
Fix: Depth counts the edges (arrows) between nodes. Root → node → node → leaf passes through 4 nodes but only 3 edges , so depth = 3 .
Subscripts xj and yi which one
Indicator counts mistakes
Derivative finds the mean
Decision Tree structure 2.3.1
The test x j ≤ t and regions feed CART algorithm (how splits are searched) and Gini impurity and entropy (how a split is scored).
Depth and subtree feed Overfitting and pruning .
The staircase boundary is smoothed by Random Forests and corrected by Gradient Boosted Trees ; the depth/complexity story connects to Bias-variance tradeoff .
Return to the parent: parent topic .
Self-test: can you answer each before revealing?
What does a subscript like y i tell you? Which sample — it points at "sample number i " and its true target.
What is the difference between the index i and the index j ? i points at a sample (a dot); j points at a feature (an axis).
Read i ∈ R ℓ in plain words. "Sample i is one of the dots inside region (box) R ℓ ."
Geometrically, what shape is the test x j ≤ t ? A straight line perpendicular to axis j (vertical or horizontal), splitting dots into yes/no.
Why can't a standard split use x 1 + x 2 ≤ 5 ? That line is diagonal (uses two features at once); standard splits are axis-aligned, one feature at a time.
What is a hyper-rectangle? A box whose sides are parallel to the axes — a leaf's region in any number of features.
What happens if a leaf's region is empty, ∣ R ℓ ∣ = 0 ? The mean formula would divide by zero, so such splits are rejected or the leaf inherits its parent's prediction.
What does y ^ (with a hat) mean versus y ? y ^ is our prediction/estimate; y is the true value.
What does 1 [ y i = y ^ ] compute, and why sum it over i ∈ R ℓ ? It is 1 when the guess is wrong, 0 when right; summing over the leaf's dots counts total mistakes in that leaf.
What does arg max c return, and how do you break a tie? The class with the most dots; ties are broken by a fixed deterministic rule (e.g. lowest class index).
Why use a derivative to find a regression leaf's prediction? The minimum of the error bowl has zero slope; setting the derivative to 0 locates that flat bottom → the mean.
What does ∣ R ℓ ∣ count, and what must it be for the mean formula? The number of dots in region R ℓ ; it must be at least 1 to avoid dividing by zero.
How is tree depth measured? By counting edges (arrows) on the longest root-to-leaf path, not nodes.