Why does a Random Forest not need feature scaling?
Last updated
Tree splits are thresholds on one feature at a time, so they depend only on the ordering of values, not their scale. Any monotonic rescaling produces the same partitions and the same predictions.
Splits are order-based:
A split like
x_j ≤ tdivides samples the same way whetherx_jis in metres or kilometres. The threshold just moves.Impurity reduction is computed from the target values on each side, which scaling doesn't change.
Features are never combined: There are no distances (unlike kNN or SVM), no dot products, and no gradient descent on weights (unlike linear models or neural nets), so one feature's range can't dominate another's.
Same reason outliers in features matter little: a split only cares which side of the threshold a value falls on.
When you'd still scale:
The pipeline includes scale-sensitive steps (PCA, kNN imputation) or other models you're comparing against.
Non-monotonic transforms (binning, interactions) are a different matter: they do change what the trees can learn.
- https://dev.to/moubarakmohame4/why-decision-trees-dont-need-feature-scaling-and-why-this-matters-91d
- https://medium.com/@kumarsuraj19111997/feature-scaling-in-machine-learning-why-when-and-how-to-use-it-83aa1a2304fc
- https://medium.com/@post.gourang/feature-scaling-in-machine-learning-which-popular-algorithms-require-it-and-which-dont-a71f5585d664