Skip to content

Commit 75c3f86

Browse files
committed
new article
1 parent a543616 commit 75c3f86

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
title: "Smarter Tree Splits: Understanding Friedman MSE in Regression Trees"
3+
categories:
4+
- machine-learning
5+
- tree-algorithms
6+
7+
tags:
8+
- decision-trees
9+
- regression
10+
- MSE
11+
- gradient-boosting
12+
- scikit-learn
13+
- xgboost
14+
- lightgbm
15+
16+
author_profile: false
17+
seo_title: "Friedman MSE vs Classic MSE in Regression Trees"
18+
seo_description: "Explore the differences between Classic MSE and Friedman MSE in regression trees. Learn why Friedman MSE offers smarter, faster, and more stable tree splits in gradient boosting algorithms."
19+
excerpt: "Explore the smarter way of splitting nodes in regression trees using Friedman MSE, a computationally efficient and numerically stable alternative to classic variance-based MSE."
20+
summary: "Understand how Friedman MSE improves split decisions in regression trees. Learn about its mathematical foundation, practical advantages, and role in modern libraries like LightGBM and XGBoost."
21+
keywords:
22+
- "Friedman MSE"
23+
- "Classic MSE"
24+
- "Decision Trees"
25+
- "Gradient Boosting"
26+
- "LightGBM"
27+
- "XGBoost"
28+
- "scikit-learn"
29+
classes: wide
30+
---
31+
32+
When building regression trees, whether in standalone models or ensembles like Random Forests and Gradient Boosted Trees, the key objective is to decide the best way to split nodes for optimal predictive performance. Traditionally, this has been done using **Mean Squared Error (MSE)** as a split criterion. However, many modern implementations — such as those in **LightGBM**, **XGBoost**, and **scikit-learn’s HistGradientBoostingRegressor** — use a mathematically equivalent but computationally superior alternative: **Friedman MSE**.
33+
34+
This article demystifies the idea behind Friedman MSE, compares it to classic MSE, and explains why it’s increasingly the preferred method in scalable tree-based machine learning.
35+
36+
37+
## Classic MSE in Regression Trees
38+
39+
In a traditional regression tree, splits are chosen to minimize the variance of the target variable $y$ in the resulting child nodes. The goal is to maximize the *gain*, or reduction in impurity, achieved by splitting a node.
40+
41+
The gain from a potential split is calculated using:
42+
43+
$$
44+
\text{Gain} = \text{Var}(y_{\text{parent}}) - \left( \frac{n_{\text{left}}}{n_{\text{parent}}} \cdot \text{Var}(y_{\text{left}}) + \frac{n_{\text{right}}}{n_{\text{parent}}} \cdot \text{Var}(y_{\text{right}}) \right)
45+
$$
46+
47+
Where:
48+
49+
- $\text{Var}(y)$ is the variance of the target variable in a node.
50+
- $n$ denotes the number of samples in each respective node.
51+
52+
This formulation effectively measures how much more "pure" (less variance) the child nodes become after a split. It works well in many cases but has some computational and numerical limitations, especially at scale.
53+
54+
---
55+
56+
## The Friedman MSE Formulation
57+
58+
Jerome Friedman, while developing **Gradient Boosting Machines (GBMs)**, introduced a smarter way to compute split gain without explicitly calculating variances or means. His formulation is based on sums of target values, which are cheaper and more stable to compute:
59+
60+
$$
61+
\text{FriedmanMSE} = \frac{\left( \sum y_{\text{left}} \right)^2}{n_{\text{left}}} + \frac{\left( \sum y_{\text{right}} \right)^2}{n_{\text{right}}} - \frac{\left( \sum y_{\text{parent}} \right)^2}{n_{\text{parent}}}
62+
$$
63+
64+
This method retains the goal of minimizing squared error but eliminates the need for floating-point division and subtraction of means, which can be error-prone.
65+
66+
---
67+
68+
## Mathematical Equivalence and Efficiency
69+
70+
Despite looking different, Friedman’s method is algebraically equivalent to minimizing MSE under squared loss. To see this, note that variance can be expressed in terms of the mean squared values, which in turn relate to sums of values.
71+
72+
By using only the sum and count of target values, this method:
73+
74+
- Avoids recomputation of sample means for every candidate split.
75+
- Allows incremental updates of statistics during tree traversal.
76+
- Greatly speeds up histogram-based methods where feature values are bucketed and pre-aggregated.
77+
78+
This efficiency is a major reason why libraries like **LightGBM** can scan millions of potential splits across thousands of features without breaking a sweat.
79+
80+
---
81+
82+
## Numerical Stability and Practical Robustness
83+
84+
Computing variance requires subtracting the mean from each data point — a step that introduces floating-point rounding errors, especially when target values are large or nearly identical.
85+
86+
Friedman MSE avoids this by working only with sums and counts, both of which are more robust under finite precision arithmetic. As a result, it tends to:
87+
88+
- Be less sensitive to large-magnitude values,
89+
- Handle outliers more gracefully,
90+
- Reduce the risk of numerical instability in deep trees.
91+
92+
This becomes particularly important when dealing with real-world datasets that often contain outliers, duplicates, or unscaled values.
93+
94+
---
95+
96+
## Comparative Table: Classic MSE vs Friedman MSE
97+
98+
| Feature | Classic MSE | Friedman MSE |
99+
|------------------------|-----------------------------|----------------------------------------|
100+
| Formula | Variance reduction | Sum of squares (per count) |
101+
| Computational Cost | Moderate | Low (sums and counts only) |
102+
| Outlier Sensitivity | Higher | Lower |
103+
| Numerical Stability | Moderate | High |
104+
| Used In | Small regression trees | Gradient boosting, histogram trees |
105+
106+
---
107+
108+
## Use Cases and When to Use Each
109+
110+
While both methods aim to minimize prediction error via informative splits, they differ in suitability based on context:
111+
112+
- **Small Datasets with Clean Targets**: Classic MSE works well and is interpretable.
113+
- **Large Tabular Datasets**: Friedman MSE is more scalable and efficient.
114+
- **Gradient Boosted Trees**: Friedman’s approach aligns with the boosting objective and is the default in most frameworks.
115+
- **High Cardinality Features**: Efficient computation via histograms makes Friedman MSE ideal.
116+
- **Presence of Noise or Outliers**: The robustness of Friedman MSE makes it a better default.
117+
118+
In practice, if you're using libraries like **LightGBM**, **XGBoost**, or **scikit-learn’s HistGradientBoostingRegressor**, you’re already benefiting from Friedman MSE — often without realizing it.
119+
120+
---
121+
122+
## Historical Origins and Impact
123+
124+
The method is named after **Jerome Friedman**, the statistician who introduced it while developing the **MART (Multiple Additive Regression Trees)** algorithm, which later evolved into what we know as Gradient Boosting Machines.
125+
126+
By reformulating the split criterion to depend only on aggregate statistics, Friedman laid the foundation for fast, scalable, and robust boosting algorithms. This innovation, though mathematically simple, had a profound impact on how tree-based models are implemented today.
127+
128+
---
129+
130+
## Summary Insights
131+
132+
Friedman MSE exemplifies how a clever mathematical simplification can drive both *speed* and *accuracy* in machine learning systems. While classic MSE is still valid and sometimes preferable in small-scale or academic scenarios, Friedman’s formulation dominates in real-world applications.
133+
134+
By leveraging only sums and counts, it reduces computational overhead, increases numerical stability, and integrates seamlessly with histogram-based algorithms. It’s a powerful example of how understanding the internals of a model — even a minor detail like the split criterion — can help practitioners make more informed choices and build better-performing systems.
135+
136+
---
137+
138+
## References
139+
140+
- Friedman, J. H. (2001). [Greedy Function Approximation: A Gradient Boosting Machine](https://projecteuclid.org/journals/annals-of-statistics/volume-29/issue-5/Greedy-function-approximation--A-gradient-boosting-machine/10.1214/aos/1013203451.full). *Annals of Statistics*.
141+
- [scikit-learn documentation: Decision Trees](https://scikit-learn.org/stable/modules/tree.html)
142+
- [LightGBM documentation: Histogram-based algorithms](https://lightgbm.readthedocs.io/)
143+
- [XGBoost documentation: Tree Booster Parameters](https://xgboost.readthedocs.io/en/stable/)

0 commit comments

Comments
 (0)