09 · Learning path
Decision Tree
Makes decisions by following branches of simple, highly interpretable rules.
A decision tree splits the data space into branches by asking “if-then” questions. Each node tests a condition and each leaf gives a final decision.
Follow a decision path
Decision tree lab
Splits, impurity and leaves (CART)
Hyperparameters
More depth fits the training data better, but can overfit.
Customer path
Approved
Leaf with 6 of 9 approved (P = 0.67), at depth 3.
Train accuracy
94.4%
Test accuracy
80.3%
Leaves
7
Learned tree
- Income ≤ 59.5
- Income ≤ 45.9
- Debt ≤ 25.1
- Rejected
- Rejected
- Income ≤ 50.6
- Approved
- Rejected
- Debt ≤ 25.1
- Debt ≤ 79.1
- Income ≤ 68.7
- Approved
- Approved
- Rejected
- Income ≤ 68.7
- Income ≤ 45.9
- Approved
- Rejected
- Active path
What to look for
- Each split minimizes the weighted Gini impurity of the two children.
- Increase depth: training accuracy goes up, test accuracy plateaus or drops.
- Move the customer near a threshold and watch how the leaf changes.
How a tree thinks
At each node, the tree tries thresholds on the variables (income, debt, score…) and keeps the split that leaves the leaves as “pure” as possible. Purity is measured with Gini impurity or with entropy:
where
What to look for
- A single variable can send a case down a different branch.
- The main advantage of a tree is that it is easy to explain.
- If it grows too deep, it can memorize the training data and overfit.
Applications
Used in credit scoring, medical rules, customer segmentation, and any setting where explaining the decision matters almost as much as accuracy.