Bagging vs Boosting
How bagging trains many models side by side to steady them, and how boosting trains them one after another to fix each other's mistakes, for your AI interview.
In short
Bagging trains many models separately, each on a random sample of the data, then averages them to steady the result. Boosting trains models one after another, each one fixing the mistakes of the last, to build one strong model.
11 min readIntermediateOccasional · estimateFacts checked 27 November 2026
Say it out loud
Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.
Bagging and boosting both combine many simple models into one, but they build them differently. Bagging trains each model on its own random sample and averages the results, which steadies a model that swings too much. Boosting trains models in order, and each new one focuses on what the last one got wrong. Boosting can reach high accuracy, but it can overfit if I add too many rounds.
Bagging and boosting both combine many simple models into one, but they build the models in different ways. Bagging trains each model on its own random sample of the past cases, then averages their answers. Boosting trains the models one after another, and each new model works on the mistakes of the ones before it.
The reason bagging helps is variance. A single fully grown tree, one that splits the rows until it fits its training data closely, can memorise the noise in that data, so its answers swing when the data changes. Averaging many trees trained on different samples cancels out those swings. scikit-learn says bagging works best with strong, complex models such as fully grown trees, because it reduces overfitting.
Boosting starts from weak models, such as shallow trees, and chains them. AdaBoost, the classic boosting method, gives the cases the last model got wrong more weight, so the next model focuses on them. Gradient boosting fits each new tree to the current errors. The risk is overfitting if I keep adding rounds, so I would set a learning rate, which is how big a step each new tree may take, and use early stopping, which ends training once the score on rows kept back from training stops improving.
In practice I would start with a random forest, which is bagging with a random set of features at each split, and test boosting against it on new data. If the labels are noisy, I would check the boosted model on rows kept back from training before trusting it.
What are bagging and boosting, in plain words?
Both are ensembles. An ensemble combines several simple models into one predictor, and scikit-learn's guide says the goal is a better result than any single model gives.
The difference is how the models are made. Bagging makes each model on its own, from a random sample, and averages them. Boosting makes them in order, and each one is aimed at the mistakes of the one before.
Think of a bank's credit committee. In bagging, five analysts each read a different random pile of past loan files, and their scores are averaged. In boosting, one reviewer marks the files the previous reviewer got wrong, and the next reviewer gives those files extra weight. A card company's fraud team faces the same choice with its payment data.
Key words
- Ensemble
- Many models whose answers are combined into one.
- Weak learner
- A simple model only a bit better than guessing, such as a shallow tree.
- Bootstrap sample
- A random copy of the training rows, drawn with repeats allowed.
- Variance
- How much a model's answers swing when the training data changes.
How does bagging work?
Bagging is short for bootstrap aggregating. Each model is a tree trained on a random sample of the rows, drawn with repeats, so some rows appear twice and some not at all. Google's course gives a typical figure of 67% of the examples for each tree.
“In ensemble algorithms, bagging methods form a class of algorithms which build several instances of a black-box estimator on random subsets of the original training set and then aggregate their individual predictions to form a final prediction.”
scikit-learn
Bagging: trees trained side by side
Past payments
made-up: 500,000 rows
Trained alone
Tree 1
its own random sample
Tree 2
trained alone, unaware of tree 1
Tree 3
trained alone, unaware of trees 1 or 2
Average the scores
one steadier answer
- 1Tree 1 learns from its own random sample of the past payments.
- 2Tree 2 learns from a different random sample.
- 3Tree 3 learns from a third sample. None of the trees waits for another.
- 4Tree 1 gives its fraud score, 0.82 in this made-up case.
- 5Tree 2 gives its fraud score, 0.40.
- 6Tree 3 gives its fraud score, 0.91. The average of the three is 0.71.
The trees do not depend on each other, so their building can run in parallel. scikit-learn's ensemble module supports the parallel construction of the trees.
Why does averaging help? Each tree makes its own errors, and those errors do not all point the same way, so many of them cancel out. scikit-learn calls this a way to reduce the variance of a single tree.
Tip
Worked example, made-up numbers: a card company's fraud model has three trees. They score one payment 0.82, 0.40 and 0.91. The average is 0.71, so with a made-up review line of 0.6 the payment goes to review, and no single tree decided it alone.
How does boosting work?
Boosting starts with a weak model and adds more models in order. Each new one is trained to fix what the models so far still get wrong. Google's course describes gradient boosting as combining many weak models, usually decision trees, one step at a time.
“The core principle of AdaBoost is to fit a sequence of weak learners (i.e., models that are only slightly better than random guessing, such as small decision trees) on repeatedly modified versions of the data.”
scikit-learn
“Gradient boosting creates a strong predictive model by iteratively combining multiple weak models, typically decision trees.”
Google for Developers
Boosting: each round fixes the last one's misses
Past payments
same rows, new weights each round
Round 1 tree
learns from every row
Round 2 tree
extra weight on round 1's misses
Round 3 tree
focuses on what is still missed
Weighted sum
one strong model
- 1Round 1 starts from all the past payments.
- 2Round 1 misses some frauds, so those rows get more weight next round.
- 3Round 2 still misses some frauds, so those rows get more weight for round 3.
- 4All the rounds are added into one model that is stronger than any single round.
The classic version, AdaBoost, does this by changing the weights of the training rows. scikit-learn's guide says the rows predicted wrongly get their weights increased, and the rows predicted correctly get them decreased, so the hard cases gain influence as the rounds go on.
Gradient boosting uses a different detail. Each new tree is trained to predict the errors of the current model, and then it is added with a small step. Both methods chain their trees, but the details differ.
- 1
Round 1
A tree learns from every past payment. In a made-up set of 1,000 frauds, it misses 300.
- 2
Round 2
The 300 misses get extra weight. The next tree catches 200 of them, so 100 remain missed.
- 3
Round 3
The tree focuses on those 100. It catches 70, so 30 remain missed in this made-up example.
Which one should you pick, and why?
- Bagging
Strong trees, averaged
Deep trees, each trained alone, then averaged. Steadier on new data, and the trees can be built in parallel.
- Boosting
Weak trees, chained
Shallow trees, trained in order. Can reach high accuracy, but it can overfit if rounds are not controlled.
- Trade-off
Steadiness or reach
Bagging is the safer first try. Boosting needs a learning rate and early stopping, and a test on new data.
A random forest is bagging of trees with one extra trick. At each split, only a random subset of the features is considered, which makes the trees differ more from each other. scikit-learn notes that random forests use bootstrap samples by default.
Boosting can overfit if rounds are not controlled. The learning rate is how big a step each new tree may take (shrinkage is the same idea), and early stopping means ending training once the score on rows kept back from training stops improving. scikit-learn says the learning rate controls overfitting through shrinkage.
Tip
Avoid saying boosting is always better. Name the fit instead: bagging when a single model swings too much, boosting when the simple model is too weak and a test on new data confirms the gain.
How would you choose for a messy claims dataset?
An insurer's claims team has labels typed by busy adjusters, and in a made-up audit about 5% of the fraud flags are wrong. The model must also work next quarter, on new claims.
I would start with bagged deep trees. Averaging dilutes the effect of an odd wrong label, though it does not remove it. Then I would try boosting with a small learning rate and early stopping, measured on rows kept back from training. I would keep boosting only if it wins on the new claims, not on the training data.
What does the interviewer want to hear?
A strong answer covers
- Bagging: separate models on random samples, averaged to cut variance.
- Boosting: models in order, each one fixing the last one's errors.
- Why bagging suits strong trees and boosting suits weak ones.
- Random forests are bagging of trees, plus random features at each split.
- Boosting's risk: overfitting when the rounds are not controlled.
- A choice backed by a test on new data, for the data at hand.
Common traps
Trap"Boosting is always more accurate."
BetterIt often scores higher, but it can overfit if rounds are not controlled. Test it against bagging on new data.
Trap"Bagging and boosting both train in order."
BetterBagging trains each model alone, so the models don't depend on each other. Boosting is the ordered one.
Trap"A random forest is just boosting with more trees."
BetterA random forest is bagging of trees, with random features at each split. Boosting chains its models.
Can you spot the right setup?
Spot the bagging
A colleague on the fraud team wrote one of these four setups. Which one is bagging, not boosting?
Quick check
A claims model's trees swing a lot each time the data is refreshed. Which change targets that problem?
Can you answer these from memory?
Flash cards · tap a card to flip it
What will they ask next?
Learn it in depth
Last updated on 27 November 2026
Building a model that must work on next quarter's data?
Venkat designs and builds AI products and agents (the UI and the system behind it), so book a short call and say what you need. No promises, no numbers.