Skip to main content
Albero Academy

Trees & Ensembles

Non-linear regression with decision trees, forests and boosting.

Regression9 min

When relationships are non-linear or involve interactions, tree-based models shine. A decision tree splits the data into regions; ensembles combine many trees for accuracy and stability — often the top performers on tabular data.

From tree to forest

the tree family
from sklearn.tree import DecisionTreeRegressor
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor
DecisionTreeRegressor(max_depth=5) # one tree — interpretable, overfits easily
RandomForestRegressor(n_estimators=200) # many trees averaged — robust
GradientBoostingRegressor() # trees built to fix each other's errors

Why ensembles win

Key takeaways

  1. 01Decision trees split data into regions — interpretable but prone to overfitting.
  2. 02Random forests average many trees to reduce variance and improve robustness.
  3. 03Gradient boosting builds trees sequentially to fix errors — often top tabular accuracy.
  4. 04Trees need no scaling and capture non-linearities; feature_importances_ ranks features.

Finished this chapter?

Mark it complete to track your progress through Scikit-learn.