What is bagging (bootstrap aggregating)?

Last updated 5 November 2026

Bagging trains many copies of the same model, each on a different bootstrap sample of the data. It then aggregates their predictions (averaging for regression, voting for classification) to get a lower-variance ensemble.

  • Procedure:

    1. Draw B bootstrap samples, each of size n with replacement.

    2. Fit one base model on each sample, independently and in parallel.

    3. Aggregate the outputs: mean for regression, majority vote or averaged probabilities for classification.

  • What it fixes:

    • It mainly reduces variance and leaves bias roughly unchanged.

    • It works best with unstable, low-bias learners such as deep decision trees.

    • It helps little for stable models like linear regression or k-NN with large k.

  • Limitation:

    • Bootstrap samples overlap heavily, so the models stay correlated and that correlation caps the variance reduction.

    • Random Forest adds per-split feature subsampling to break this correlation.

  • Contrast with boosting:

    • Bagging builds models in parallel and independently, targeting variance.

    • Boosting builds models sequentially, each correcting the previous ones' errors, targeting mainly bias.

  • Bonus: the left-out rows give out-of-bag error estimates without a separate validation set.

  • https://www.analyticsvidhya.com/blog/2022/12/interview-questions-on-bagging-algorithms-in-machine-learning/
  • https://medium.com/@vikashsinghy2k/top-interview-questions-and-answers-on-bagging-algorithms-every-data-scientist-should-know-5bc65f637d91
  • https://github.com/Devinterview-io/random-forest-interview-questions
All Random Forests interview questions