Classical Machine Learning

Decision Trees, Random Forests & Gradient Boosting

Tree models learn decision rules by splitting feature space. A single tree is readable but unstable; random forests reduce variance by averaging many trees; gradient boosting builds trees sequentially to fix the current ensemble's errors.
  • A decision tree is nested if/else logic learned from data
  • Single trees overfit easily
  • Random forests average many noisy trees
  • Gradient boosting learns corrections
  • Tree ensembles handle nonlinearity and interactions well
  • Interpretability decreases as performance rises
Tree-family trade-offs
ModelMain strengthMain weaknessGood default?
Decision treeReadable rulesHigh variance / overfitsFor explanation, not usually accuracy
Random forestRobust with little tuningLarger and less interpretableYes
Gradient boostingExcellent tabular accuracyTuning-sensitiveYes, with validation
From one tree to ensembles
Forests fight variance by averaging; boosting fights bias/residual error by sequencing.
Tree ensemble baseline
from sklearn.ensemble import RandomForestClassifier, HistGradientBoostingClassifier
from sklearn.model_selection import cross_validate

models = {
    "forest": RandomForestClassifier(n_estimators=300, min_samples_leaf=5),
    "boosting": HistGradientBoostingClassifier(max_leaf_nodes=31, learning_rate=0.05),
}

for name, model in models.items():
    result = cross_validate(model, X, y, cv=5, scoring=["f1", "roc_auc"])
    print(name, result["test_f1"].mean(), result["test_roc_auc"].mean())
Compare ensembles against a simple baseline and each other; don't pick by vibes.
Sources
  • An Introduction to Statistical Learning with PythonTree-Based Methods
  • scikit-learn User GuideDecision Trees; Ensemble Methods
  • Machine Learning Crash CourseDecision Forests