Ensemble Learning (Bagging, Voting, Stacking)
Machine Learning · Intermediate
Definition
Ensembles combine several models so their errors cancel out.
Usually more accurate and robust than any single model.
Diagram
Flowchart
Example: Majority vote
preds = ['spam', 'ham', 'spam']
print(max(set(preds), key=preds.count))Output: spam
Key points
- Random forest = bagging of trees
- Diverse models ensemble best
Interview questions
Why do ensembles help?
Independent errors average out, reducing variance.