Decision Trees and Regression Trees
Context: FIT1043_MOC Β· a predictive model you can read as rules Β· splits the feature space into regions Β· the building block of a Random Forest
Quick Revision
- π― Objective: classify or predict by walking a tree of feature tests β decision tree = categorical, regression tree = real value.
- π¦ Core Components: recursive partitioning | leaf prediction (mode vs mean) | split criterion (purity/info gain).
- β‘ Key Constraint: the algorithmβs choices β which feature to split on (purity/information gain) and when to stop β determine the tree.
π How It Works
1. Two Kinds of Tree
- Decision tree β predicts a binary/multi-class categorical outcome (play tennis: yes/no).
- Regression tree β predicts a continuous real value (leaves hold numbers like 45.6).
- Structure β start at the root, follow a branch per feature test, reach a leaf = the prediction.
2. Building & Predicting
- Recursive partitioning β repeatedly divide the feature space into regions that group similar instances together.
- Decision-tree leaf β predict the most common class in that region.
- Regression-tree leaf β predict the average value in that region.
3. Split Criteria & Stopping
- Which feature to split β chosen by a purity / information-gain measure (e.g. entropy); algorithms differ β ID3, C4.5, CART.
- When to stop β further splits stop helping: minimum samples per node, maximum depth, or negligible accuracy gain.
βοΈ Core Implementation
πΉ Decision tree β βplay tennis?β
Mermaid tree + rule
graph TD A[outlook?] -->|sunny| B[humidity?] A -->|overcast| C[yes] A -->|rain| D[wind?] B -->|high| E[no] B -->|normal| F[yes] D -->|strong| G[no] D -->|weak| H[yes]π‘ Common Mistake: Read the tree as OR-of-AND rules β good day = (Sunny and Normal) or Overcast or (Rain and Weak); everything else is a bad day.
βοΈ Core Decision Matrix
| Tree | Predicts | Leaf value |
|---|---|---|
| Decision tree | category (yes/no, classes) | most common class in region |
| Regression tree | real value | average value in region |
When It Flips: both trees are built the same way (recursively partition the feature space); they differ only in the leaf rule β mode for classification, mean for regression.
π§ Active Recall
How does a decision tree differ from a regression tree in what it predicts and how a leaf decides?
Answer
- Short answer: A decision tree predicts a category (leaf = most common class in the region); a regression tree predicts a real value (leaf = average of the region).
- Why: Same partitioning, different leaf β both recursively split the feature space; only the leaf aggregation changes.
What two decisions define a tree-building algorithm, and name a criterion for each.
Answer
- Short answer: (1) which feature to split on β by purity/information gain (e.g. entropy; ID3/C4.5/CART); (2) when to stop β min samples, max depth, or negligible gain.
- Why: Purity + stopping β splits that best separate classes, halted before they overfit.