Standard 6 stops to get here

Bagging

Bootstrap aggregating: train many copies of a model on random resamples of the data, then average or vote their predictions to cut variance.

Your route here

6 stops · basics first
  1. Machine Learning ✓ understood

    Building systems that learn patterns from data instead of following hand-written rules, getting better at a task as they see more examples.

  2. Supervised Learning ✓ understood

    Learning from examples paired with the correct answer, so a model can predict answers for new inputs it hasn't seen.

  3. Ensemble Learning ✓ understood

    Combining multiple models to produce better predictions than any individual model (bagging, boosting, stacking).

  4. Classification ✓ understood

    A supervised learning task where the model assigns each input to one of a fixed set of categories, such as spam or not spam.

  5. Regression ✓ understood

    A supervised learning task where the model predicts continuous numerical values rather than discrete categories.

  6. Decision Tree ✓ understood

    A tree-structured model that makes decisions by splitting data based on feature values, interpretable but prone to overfitting.

  7. Bagging · you are here ✓ understood

Picture it

  1. 01 Original training set N examples
  2. 02 Bootstrap samples Draw N with replacement, many times
  3. 03 Train one model per sample Same algorithm, different data
  4. 04 Aggregate Average numbers, majority vote for classes
Notice each model sees a slightly different resample of the same data; their errors partly cancel when you combine them.

Bagging, short for bootstrap aggregating, is a way to make an unstable model steadier by training many copies of it and combining their answers. Leo Breiman introduced it in 1994. It is one of the classic ensemble strategies, alongside boosting and stacking.

The recipe has two steps. First, make many bootstrap samples: new training sets the same size as the original, drawn at random with replacement, so each one repeats some examples and leaves others out (about a third, on average). Train one model on each. Second, aggregate: average the predictions when the target is a number, take a plurality vote when it’s a class.

Why it works

Some models change a lot when the training data changes a little. A deep decision tree is the textbook case: move a few examples and the splits near the top can flip. That sensitivity is variance, and it is a major source of overfitting. Averaging many such models, each fitted to a slightly different resample, smooths out the idiosyncrasies each one picked up while keeping what they agree on. Breiman’s paper puts the condition plainly: bagging helps when perturbing the training set changes the predictor significantly.

The corollary matters too. A stable model, such as a regularized linear model, barely changes between resamples, so bagging it adds cost and little else. In the terms of the bias-variance tradeoff, bagging mainly lowers variance and does little about bias.

Where you meet it

A random forest is bagged decision trees with one extra twist: each split considers only a random subset of features, which makes the trees less alike and the average stronger (the paper). Gradient boosting takes the other route, training models one after another, each correcting the last.

Where it sits

Bagging

Leads to

Nothing yet: a destination in its own right.

Explore nearby

Sources

  1. Leo Breiman, "Bagging Predictors" . UC Berkeley Technical Report 421, 1994; published in Machine Learning 24(2), 1996