Decision trees
A tree recursively partitions the input space. At each node, a greedy algorithm compares candidate splits using weighted child impurity. A locally best split need not produce the globally best tree.
7.1 Classification impurity and split gain
Past papers · DA 2024–2026 (3 papers): 1 question, 2 marks
At a node containing observations, let be the fraction belonging to class , with classes. Define by continuity.
A pure node has zero impurity. For uniform class proportions, entropy is , Gini is , and majority error is . Binary maxima are . The Gini value is also the probability of unequal labels in two independent draws from the node distribution.
For a numerical feature, sort its distinct training values and test thresholds between adjacent values. A split must use a consistent equality convention. Repeated feature values cannot be separated by a threshold. Leaves predict a most frequent class; their empirical class probabilities are class counts divided by leaf count.
7.2 Regression leaves and pruning
For a regression node , targets are numerical. Under squared error, the prediction is their mean . For absolute error, use a median. These predictions make a tree piecewise constant.
Choose the split with greatest SSE decrease. Dividing every candidate's total SSE by the same parent count preserves the ranking. Limit depth, enforce a minimum leaf size, or prune to control overfitting; tune those choices on validation data. Axis-aligned trees need repeated rectangular splits to approximate a diagonal boundary. Increasing tree depth normally reduces training error but can increase variance.
Last-minute recall
- Node proportions refer to that node, not the whole dataset.
- Entropy is zero at purity and largest at uniform class proportions.
- Child impurity is sample-weighted.
- Numerical thresholds are tested between distinct feature values.
- Squared-error regression leaves predict means.
- Pruning trades fit against the number of leaves.