Page20/20
Ensemble Methods β Combine Multiple Models Β· Page 1 of 1
Ensemble Learning Philosophy
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β¦