Decision Trees
The mathematical framework of recursive partitioning: impurity measures (Gini, entropy, MSE), optimal split criteria, the greedy induction algorithm, pruning theory, and computational complexity analysis.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Recursive Partitioning Framework
- Impurity Measures
- Information Gain and Split Criteria
- The Greedy Induction Algorithm
- Regression Trees
- Pruning and Complexity Control
- Theoretical Properties
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Formalize a decision tree as a recursive partition of input space.
- Derive Gini impurity and entropy as measures of node heterogeneity.
- Derive the information gain criterion for optimal split selection.
- Analyze the greedy algorithm's computational complexity.
- Explain cost-complexity pruning and its connection to regularized risk.
- Understand why trees are high-variance, low-bias estimators.
Notation
- — region corresponding to leaf node
- — number of training samples in region
- — proportion of class in node
- — impurity of node
- — information gain from a split
- — number of leaf nodes (tree complexity)
Core Intuition
A decision tree partitions the input space into axis-aligned rectangular regions, each assigned a constant prediction. The partition is built top-down: at each step, we find the split (feature , threshold ) that most reduces prediction error. The resulting model is interpretable, non-parametric, and handles mixed feature types naturally.
Decision Tree Splits
58% accRecursive Partitioning Framework
A tree defines a partition of with predictions:
For classification: (majority vote). For regression: (mean).
Each internal node implements a split , creating two child nodes.
Impurity Measures
Definition (Gini Impurity). For a node with classes:
Gini impurity equals the probability that a randomly chosen sample would be misclassified if labeled according to the distribution in the node.
Definition (Entropy).
Both are maximized when classes are uniformly distributed and minimized (zero) when the node is pure (single class).
Definition (MSE for regression).
Information Gain and Split Criteria
A split of node into children and produces information gain:
The optimal split maximizes :
For each feature with distinct values, there are at most candidate thresholds. Total candidates per node: in the worst case.
The Greedy Induction Algorithm
CART Algorithm (Breiman et al., 1984):
- Start with root containing all samples.
- For current node :
- If stopping criterion met (pure node, max depth, min samples): make leaf.
- Otherwise: find best split maximizing gain.
- Partition data: , .
- Recurse on and .
Complexity. At each node with samples: testing all splits costs (sort each feature). Over all nodes at a given depth: . For depth : total .
Regression Trees
For squared-error loss, the optimal constant prediction in region is the sample mean . The best split minimizes:
This is equivalent to maximizing the reduction in total variance — the regression analog of information gain.
Pruning and Complexity Control
An unpruned tree typically overfits ( if grown to full depth). Cost-complexity pruning regularizes:
where is the number of leaves and is a complexity parameter.
Theorem (Breiman). For any , there exists a unique smallest subtree that minimizes . The sequence of optimal subtrees is nested: for .
The optimal is selected via cross-validation.
Theoretical Properties
Consistency. Under mild conditions, decision trees are universally consistent: as with appropriate depth growth (, ), the risk converges to the Bayes risk.
Bias-Variance. Deep trees have low bias (can approximate any function on the training set) but high variance (small data perturbations change the tree structure drastically). This motivates ensemble methods (bagging, boosting) that reduce variance.
Approximation. A tree with leaves is a piecewise-constant function. Approximating a Lipschitz function to accuracy in dimensions requires leaves — the curse of dimensionality.
Common Pitfalls
Pitfall 1. Splits are axis-aligned. If the true boundary is diagonal (e.g., ), trees need many splits to approximate it (staircase pattern).
Pitfall 2. Greedy splitting is not globally optimal. The best split at the root may not lead to the best overall tree. Finding the optimal tree is NP-complete.
Pitfall 3. Information gain is biased toward features with many distinct values. Gain ratio (Quinlan, C4.5) corrects this by normalizing by split entropy.
Summary
- Decision trees recursively partition space via axis-aligned splits.
- Gini impurity and entropy measure node heterogeneity; splits maximize information gain.
- Trees are greedy, non-parametric, and interpretable.
- Unpruned trees overfit; cost-complexity pruning balances fit vs. complexity.
- High variance makes trees ideal base learners for ensembles.
Exercises
Exercise 1. Show that Gini impurity is a second-order Taylor approximation of entropy around uniform .
Exercise 2. For binary classification, show that both Gini and entropy are concave functions of and derive their maxima.
Exercise 3. Prove that the optimal constant prediction minimizing MSE within a region is the sample mean.
Exercise 4. Construct a 2D example where the optimal tree of depth 2 is not obtained by the greedy algorithm.
Exercise 5. Derive the number of possible binary trees with leaves and relate it to the Catalan numbers.