Lensa ML
Lensa ML

Decision Trees & Splitting

Step 1 of 6

What is a Decision Tree?

Nodes, branches & leaves

-3-2-10123-3-2-10123
DEPTH
1
REGIONS
2
ACCURACY
67%

A decision tree partitions data by asking yes/no questions. At depth 1 it makes a single axis-aligned cut — each colored region predicts one class. One cut isn't enough for interleaved clusters.

Step 1 of 6: What is a Decision Tree?

Nodes, branches & leaves

-3-2-10123-3-2-10123
DEPTH
1
REGIONS
2
ACCURACY
67%

A decision tree partitions data by asking yes/no questions. At depth 1 it makes a single axis-aligned cut — each colored region predicts one class. One cut isn't enough for interleaved clusters.

Step 2 of 6: Splitting Criteria

Gini impurity & information gain

x = 0.0L: 15r + 0gR: 0r + 15g
GINI LEFT
0.000
GINI RIGHT
0.000
WEIGHTED GINI
0.000
INFO GAIN
1.000

Strong split — the line lands between clusters. The left side is mostly red (100% pure) and the right mostly green (100% pure). Low weighted Gini (0.00) confirms the children are much purer than the parent.

Step 3 of 6: Growing the Tree

Recursive partitioning

TREE STRUCTUREy≤0.1DATA SPACE-3-2-10123-3-2-10123
DEPTH
1
LEAVES
2
ACCURACY
67%
GINI REDUCTION
0.056

With only 1 split, the tree picks the single best feature and threshold — but one cut can't separate interleaved clusters.

Step 4 of 6: Overfitting a Tree

When trees memorize noise

traintest
DEPTH
2
TRAIN ACC
79%
TEST ACC
92%
GAP
-13%

Underfitting — train 79% and test 92% are both low. The tree is too shallow to capture the cluster structure.

Step 5 of 6: Pruning

Simplifying for generalization

traintest
ALPHA
0.000
LEAVES
18/18
TRAIN ACC
92%
TEST ACC
77%

No pruning — this is the same depth-8 overfit tree from step 4 with 18 leaves. Train 92% but test only 77%. Increase alpha to start removing noise-fitting branches.

Step 6 of 6: Decision Boundaries

Axis-aligned regions

traintest
DEPTH
3
REGIONS
7
TRAIN ACC
97%
TEST ACC
90%

More depth creates finer axis-aligned rectangles. Unlike SVMs or neural networks, trees cannot create diagonal or curved boundaries.