Alt+←/→to navigatePage20/20100
Ensemble Methods — Combine Multiple Models · Page 1 of 1
Ensemble Learning Philosophy
20 min Advanced
Ensemble Methods — Combine Multiple Models
Why Ensembles?
"Wisdom of crowds" — multiple imperfect models often beat a single perfect one. This is why:
- Kaggle competitions: ~100% of winners use ensembles
- Real production systems: Google, Netflix, Amazon all use ensembles
Three Main Approaches
-
Bagging (Bootstrap Aggregating)
- Train independent models on random subsets of data
- Average predictions
- Example: Random Forest
-
Boosting
- Train models sequentially, each correcting previous errors
- Weight incorrect predictions higher
- Example: XGBoost, Gradient Boosting
-
Stacking
- Train multiple different models
- Use their outputs as input to a meta-learner
The Bias-Variance Tradeoff
| Method | Reduces | Problem |
|---|---|---|
| Bagging | Variance | Single model is weak |
| Boosting | Bias | Prone to overfitting |
| Stacking | Both | Complex, slow |
Random Forest — The Gold Standard
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(n_estimators=100, max_depth=10)
rf.fit(X_train, y_train)
accuracy = rf.score(X_test, y_test)
Why Random Forest wins:
- Parallelizable (train trees independently)
- Handles missing data well
- Feature importance built-in
- Minimal hyperparameter tuning
main.py
Loading...
OUTPUT
▶Click "Run Code" to execute…