Lesson 3.8core2 h 30 min

Decision trees

Learning by asking the most informative question first

Trees are the most human-readable model family and the building block of the ensembles that still win most tabular competitions (3.9 Ensembles: bagging, random forests and gradient boosting). Learning them teaches you impurity measures that reuse entropy (1.9 Information theory: entropy, cross-entropy and KL divergence), shows the bias–variance trade-off (3.5 Evaluating models: metrics, validation and the bias–variance trade-off) in its rawest form, and gives you a mental model for "routing" that returns in mixture-of-experts layers (7.11 Mixture of Experts) and agent workflows (10.5 Agentic workflow patterns).

You'll be able to

  • Compute Gini impurity, entropy and information gain for a candidate split by hand
  • Explain how CART grows a classification or regression tree greedily and why the result is piecewise constant
  • Control overfitting with pre-pruning hyperparameters and cost-complexity pruning
  • Diagnose the strengths (interpretability, no scaling) and weaknesses (instability, axis-aligned boundaries) of a single tree

Key ideas

  1. A tree partitions feature space into axis-aligned rectangles and predicts a constant per leaf: flexible, interpretable, scale-invariant.
  2. Splits are chosen greedily to maximize impurity decrease; Gini = 1 − Σp², entropy = −Σp log₂p, information gain = parent impurity − weighted child impurity.
  3. Regression trees minimize within-leaf squared error and predict the leaf mean.
Show 4 more key ideas
  1. A fully grown tree memorizes noise; control variance with max_depth/min_samples_leaf or cost-complexity pruning chosen by cross-validation.
  2. Trees handle missing values natively (surrogates or learned default direction) and need no feature scaling.
  3. Single trees are unstable (high variance) and draw staircase boundaries — the motivation for ensembles.
  4. Impurity-based feature importance is biased toward high-cardinality features; prefer permutation importance or SHAP.

Suggested path through this lesson