Regression Trees
Learn how decision trees predict continuous values instead of class labels.
Decision trees are not limited to yes/no class labels. Regression trees predict continuous numbers—prices, temperatures, scores.
Big idea
In classification, each leaf predicts a class. In regression, each leaf predicts a number—usually the mean of the target values that landed in that leaf.
Split quality is measured by how much variance remains in the target. Trees prefer splits that make each child group's targets more similar—lower spread, lower error.
Formula
Leaf prediction (mean of targets in the leaf):
y^leaf=n1i=1∑nyiMean squared error (MSE) as impurity:
MSE=n1i=1∑n(yi−y^)2A split is good when the weighted MSE of its children is lower than the parent's MSE—similar in spirit to weighted Gini, but for continuous targets.
Some implementations also support MAE (mean absolute error), which is more robust to outliers.
Worked example
A leaf contains targets y={10,12,14}:
y^=310+12+14=12 MSE=3(10−12)2+(12−12)2+(14−12)2=34+0+4≈2.67After a split, the tree compares weighted MSE on the left and right—just as it compares weighted Gini for classification.
Common mistake
Using classification impurity (Gini or entropy) on a regression problem. Continuous targets need variance-based measures like MSE, and leaves predict means—not class labels.
Key takeaway
Regression trees split to reduce target variance. Each leaf predicts the mean target value in that region.
Explore a simple regression tree workflow in the practice notebook below.
Practice
Try It Yourself
Open the practice lab to complete the starter code in the notebook.
Knowledge Check
Quick Quiz
A regression tree leaf typically predicts:
Summary
Key Takeaways
- Regression trees predict numeric targets instead of classes.
- Leaf values are often the mean target in that region.
- Impurity for regression uses measures like MSE.