CAB212 · Unit 4: Ensemble learning
Voting and stacking
6 practice questions
Key points
- Hard vote = majority; soft vote = mean probability
- Stacking trains a meta-learner
- Use out-of-fold predictions
- Diversity matters
Other ways to combine models:
- Hard voting: majority class among models. Soft voting: average predicted probabilities, then choose the largest (usually better when probabilities are reliable).
- Stacking: a meta-learner is trained on the predictions of base models (often a different algorithm family, such as k-NN, SVM and trees). To avoid leakage, the meta-features are made with out-of-fold predictions.
- Blending: like stacking but uses a single hold-out set.
Diverse, individually decent models with uncorrelated errors give the biggest ensemble gain.
Worked example: three classifiers output P(positive) = 0.9, 0.4, 0.4. Soft voting average = 0.567, so predict positive; hard voting gives 1 positive vs 2 negative, so predict negative.
Exam pitfall: if all base models make the same mistakes, combining them adds nothing.
Try two questions
In stacking, the meta-learner is trained on:
- Raw pixel values of the original images only
- Predictions of the base models
- The true labels of the test set
- Random noise features added for diversity
Show the answer
B. Base predictions become its input features.
For the same three models, hard voting (each thresholded at 0.5) predicts:
- Positive
- Negative
- Tie
- Positive with probability 0.9
Show the answer
B. Only one of three votes positive.