Ensemble Learning MCQs for NSCT
Ensemble learning combines several base models, such as many decision trees, so that their joint prediction is more accurate and more stable than any one of them. It is topic 7 of the AI, Machine Learning & Data Analytics area, which carries 10% of the NSCT according to HEC's Areas of Competencies. In 2026 candidates averaged 50.8% accuracy in this area, per the HEC NSCT report and APP.
Revise Supervised Learning first, because ensembles are built from supervised base learners such as decision trees.
Bagging
Bagging (bootstrap aggregating, Breiman 1996) trains each model on a bootstrap sample: n rows drawn with replacement from the n training rows. Classification combines the models by majority vote and regression by averaging.
Because each row is missed by one draw with probability (1 - 1/n), it is left out of a whole sample with probability (1 - 1/n)^n, which tends to 1/e = 0.368. So each sample holds about 63.2% of the distinct rows, and the other 36.8% are out-of-bag (OOB) rows that can score the model for free.
Exam angle: bagging mainly reduces variance, so it helps unstable, low-bias learners such as deep trees, and does little for an underfitting model.
Boosting
Boosting trains learners sequentially, each one correcting the ensemble so far. In AdaBoost each weak learner (often a one-split decision stump) gets a vote weight alpha = (1/2) ln((1 - e)/e), where e is its weighted error. Misclassified rows are multiplied by e^alpha and correct rows by e^-alpha, then the weights are normalised.
With e = 0.2, alpha = 0.5 ln 4 = 0.693 and e^alpha = 2, so the misclassified rows end up holding exactly half the total weight. Gradient boosting instead fits each new tree to the negative gradient of the loss; for squared error that is simply the residual y - F(x), and each tree is added with a learning rate (shrinkage) eta.
Exam angle: boosting mainly reduces bias, and because it chases hard rows it is more sensitive to label noise than bagging.
| Bagging / random forest | Boosting | |
|---|---|---|
| Training | Parallel, independent | Sequential, dependent |
| Data per learner | Bootstrap sample | Re-weighted rows or residuals |
| Mainly reduces | Variance | Bias |
| Typical base learner | Deep, unpruned tree | Stump or shallow tree |
| More estimators | Error flattens | Can overfit without early stopping |
Random forest
A random forest is bagged trees plus feature randomness: every split looks at only a random subset of features. The usual default is sqrt(p) features for classification (8 of 64, for example). Breiman suggested about p/3 for regression, although scikit-learn's regressor now defaults to all features, so sources disagree here.
The reason is correlation. For n models with variance sigma^2 and pairwise correlation rho, the average has variance rhosigma^2 + (1 - rho)sigma^2/n. Adding trees shrinks only the second term, so decorrelating the trees lowers the floor.
Exam angle: expect a question on why max_features helps, or on why OOB accuracy is below training accuracy. Training accuracy near 100% is normal for a forest.
XGBoost
XGBoost (eXtreme Gradient Boosting, Chen and Guestrin 2016) is regularised gradient boosting. Its objective adds Omega = gammaT + (1/2)lambdasum(w^2), where T is the number of leaves and w the leaf weights. Using gradients g and Hessians h, the best leaf weight is w = -G/(H + lambda). A split is kept only if its gain, 1/2[GL^2/(HL+lambda) + GR^2/(HR+lambda) - (GL+GR)^2/(HL+HR+lambda)] - gamma, is positive.
Exam angle: gamma acts as a minimum loss reduction for a split, and lambda shrinks leaf weights towards zero.
Stacking and voting
Hard voting counts labels; soft voting averages probabilities. Stacking trains a meta-learner on out-of-fold base-model predictions.
Common traps
- Saying bagging reduces bias. It mainly reduces variance; boosting mainly reduces bias.
- Using 36.8% as the share of rows in a bootstrap sample. 36.8% is the out-of-bag share; about 63.2% are in-bag.
- Assuming more trees always risks overfitting. A forest's error flattens as trees are added; boosting is the one that can overfit.
- Forgetting the 1/2 in AdaBoost's alpha, or the gamma penalty in XGBoost's split gain.
- Believing any ensemble beats its members. Majority voting helps only when members beat chance (p > 0.5) and make different errors.
- Training a stacking meta-learner on in-sample predictions, which rewards the most overfitted base model.
Worked examples
1. Understanding. Which ensemble method trains its learners independently on bootstrap samples and averages them? Answer: bagging. Boosting trains sequentially, and stacking learns a combiner on top of the base models.
2. Application. Three independent classifiers are each 80% accurate. What is the accuracy of their majority vote? Answer: 0.896. The vote is right when at least two are right: 3(0.8^2)(0.2) + 0.8^3 = 0.384 + 0.512 = 0.896.
3. Analysis. A gradient-boosting model with learning rate 0.3 has validation error that falls until about 400 rounds and then rises. Which change is most sensible? Answer: lower the learning rate and use early stopping on validation error. Rising error means extra rounds are fitting noise. Adding trees makes it worse, and switching to deeper trees raises variance further.
Practise
The quiz below has 100 Ensemble Learning questions, filterable by tier and difficulty.
Practise: 100 questions
FAQs
Is random forest bagging or boosting?
Random forest is a bagging method. Each tree is trained independently on a bootstrap sample, and the forest votes or averages. What makes it more than plain bagging is the random subset of features considered at every split, which makes the trees less correlated.
Which is better, XGBoost or random forest?
Neither always wins. Tuned gradient boosting such as XGBoost often leads on tabular benchmarks, but it has more hyperparameters and can overfit if the learning rate and number of rounds are not controlled. A random forest is easier to tune and more robust to noisy labels, so it is a strong baseline.
Does boosting reduce bias or variance?
Mainly bias. Each new learner corrects the remaining errors, so a set of weak, high-bias stumps becomes a strong model. Shrinkage and subsampling also reduce variance a little, but if a question asks for the main effect, the answer is bias, while bagging mainly reduces variance.
Next step
Continue with Unsupervised Learning MCQs, go back to the AI & ML MCQ hub, or test yourself across every area in an NSCT mock test.