Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Decision Trees

1. Core Concepts and Terminology

A Decision Tree is a hierarchical non-parametric model that partitions the feature space into local regions via recursive splits.


2. Classification Trees: Impurity Measures

To determine the optimal split, we measure the “impurity” of labels at a node SS. Let pip_i be the proportion of instances belonging to class ii.

Entropy & Information Gain (ID3)

Entropy measures the uncertainty/disorder in a node:

H(S)=−∑i=1Cpilog⁡2piH(S) = -\sum_{i=1}^{C} p_i \log_2 p_i

Information Gain is the reduction in entropy achieved by partitioning SS using attribute AA:

Gain(S,A)=H(S)−H(S∣A)\text{Gain}(S, A) = H(S) - H(S|A)

H(S∣A)=∑v∈Values(A)∣Sv∣∣S∣H(Sv)H(S|A) = \sum_{v \in \text{Values}(A)} \frac{|S_v|}{|S|} H(S_v)

Gain Ratio (C4.5)

To correct the bias of Information Gain toward attributes with many levels, the Gain Ratio normalizes the gain:

GainRatio(A)=Gain(S,A)SplitInfo(A)\text{GainRatio}(A) = \frac{\text{Gain}(S, A)}{\text{SplitInfo}(A)}

SplitInfo(A)=−∑v=1V∣Sv∣∣S∣log⁡2∣Sv∣∣S∣\text{SplitInfo}(A) = -\sum_{v=1}^{V} \frac{|S_v|}{|S|} \log_2 \frac{|S_v|}{|S|}

Gini Index (CART)

Measures the probability of misclassification:

Gini(S)=1−∑i=1Cpi2\text{Gini}(S) = 1 - \sum_{i=1}^{C} p_i^2

3. Regression Trees

In regression, the model partitions the space to minimize prediction error, typically the Residual Sum of Squares (RSS).

Tree-Growing Algorithm

  1. Initialize: Start with a root node containing all NN observations. Compute the mean yˉ\bar{y} and total error SS:

    y‾=1N∑i=1Nyi,S=∑i=1N(yi−y‾)2\overline{y} = \frac{1}{N}\sum_{i=1}^{N} y_i, \quad S = \sum_{i=1}^{N}(y_i - \overline{y})^2
  2. Best Split Search: For a threshold w1w_1 splitting SS into cLc_{\text{L}} and cRc_{\text{R}}, compute the new error Sw1S_{w_1}:

    Sw1=∑i∈cL(yi−y‾cL)2+∑i∈cR(yi−y‾cR)2S_{w_1} = \sum_{i \in c_{\text{L}}}(y_i - \overline{y}_{c_{\text{L}}})^2 + \sum_{i \in c_{\text{R}}}(y_i - \overline{y}_{c_{\text{R}}})^2

    Select the split that maximizes the reduction: w1∗=argmaxw1(S−Sw1)w_1^* = \text{argmax}_{w_1} (S - S_{w_1}).

  3. Recurse: Apply the process to child nodes until stopping criteria are met.


4. Overfitting and Pruning

Trees are prone to overfitting, capturing noise and creating non-smooth boundaries.

Stopping Criteria (Pre-pruning)

Growth stops if:

Post-pruning

  1. Grow a deep tree T0T_0 using the training set.

  2. Iteratively remove (prune) nodes that yield the largest improvement in validation performance.

  3. Replacement Logic: Replace a subtree with a leaf if the expected error of the subtree exceeds that of the single leaf.


5. Ensemble Methods

To overcome the high variance and instability of single trees, ensemble methods combine multiple diverse trees.

Bootstrap Aggregating (Bagging)

Random Forest

Improves Bagging by further reducing correlation between trees.


6. Model Summary

FeatureDetails
AdvantagesInterpretability (rules), handles mixed data types, no feature scaling required, non-parametric.
DisadvantagesHigh variance (instability), prone to overfitting, piecewise-constant predictions (non-smooth).
ComparisonUnlike Neural Networks, which learn features and classifiers jointly (end-to-end), trees rely on direct data partitioning.

[Image comparing a smooth regression curve to a piecewise-constant tree approximation]