tensorturnBETA
Home › Machine Learning Tasks

Ensemble Learning: Bagging, Boosting, Stacking and Voting Explained

Ensemble learning combines the predictions of several models so that their individual errors partly cancel out, which usually gives better accuracy and more stable results than any single model. The four main methods are bagging (many models on resampled data, such as random forests), boosting (models trained in sequence to fix earlier mistakes, such as XGBoost), stacking (a meta-model learns how to combine base models) and voting (a simple vote or average). On TensorTurn you can ask for any of these in a notebook, or run ensemble mode to train several diverse models in parallel across your own connected machines.

Why ensembles work

Every model makes errors. If two models make the same errors, combining them adds nothing. If their errors are different and only partly correlated, averaging their predictions lowers the variance of the combined prediction, and a sequential method like boosting can also lower bias. The key ingredient is diversity: different training samples, different random seeds, different features or different algorithms. A combination of five near-identical models is barely better than one.

Bagging vs boosting vs stacking vs voting

MethodHow it worksMainly reducesExamplesWhen to use
BaggingTrain many models in parallel on bootstrap samples of the data, then average or voteVarianceRandom forest, bagged decision trees, Extra TreesHigh-variance models that overfit, such as deep decision trees
BoostingTrain models in sequence, each focusing on the errors of the ones beforeBias, and variance with regularisationXGBoost, LightGBM, CatBoost, AdaBoostTabular data where you want top accuracy; the default for most structured problems
StackingTrain diverse base models, then fit a meta-model on their out-of-fold predictionsBoth, by learning which model to trust whenLogistic regression over XGBoost, random forest and a neural netSqueezing out the last gains once single models are tuned
Voting / averagingCombine predictions directly by majority vote, averaged probabilities or averaged valuesVarianceSoft-voting classifier, averaged regressors, multi-seed neural netsQuick wins from models you already have; parallel training across machines

Hard vs soft voting

Hard voting takes the class predicted by the most models. Soft voting averages each model's predicted probabilities and picks the class with the highest average. Soft voting is usually better because it uses each model's confidence, but it needs models whose probabilities are reasonably calibrated. For regression the equivalent is simply averaging the predicted values, optionally weighted by each model's validation score.

Stacking without leaking

Stacking has one serious trap. If the meta-model is trained on predictions the base models made on data they were trained on, those predictions are overconfident and the meta-model learns to trust them too much. The fix is to generate out-of-fold predictions: split the training data into k folds, train each base model on k-1 folds, predict the held-out fold, and use those predictions as the meta-model's features. Keep the test set completely untouched until the very end.

When ensembles are not worth it

Ensemble mode across your own machines

Ensembles are naturally parallel: each member can train independently. TensorTurn uses this in its distributed training feature. When you connect two or more of your own machines, you can pool them into one run in ensemble mode. Each member trains with its own random seed, so the models come out diverse, a live leaderboard shows each member's score, and the members' predictions are combined by soft voting or averaging. Because members never need to talk to each other, slower or faster machines simply take more or less of the work.

The alternative, fused mode, shards the rows across machines and periodically averages model weights to produce one merged model instead of a committee. Choose ensemble mode when accuracy matters most and you can afford to serve several models; choose fused mode when you need a single model or the dataset is too large for one machine.

How to build an ensemble on TensorTurn

Start building free

Frequently asked questions

What is ensemble learning in simple terms?

Ensemble learning trains several models and combines their predictions, by voting, averaging or a learned combiner, so the group is more accurate and stable than any single member. It works best when the models make different kinds of mistakes.

What is the difference between bagging and boosting?

Bagging trains models independently on random resamples of the data and averages them, which mainly reduces variance; random forest is the classic example. Boosting trains models one after another, each correcting the previous errors, which reduces bias; XGBoost and LightGBM are popular examples.

Is stacking better than voting?

Stacking can beat simple voting because the meta-model learns which base model to trust in which situation, but it is more complex and easy to overfit. Always build it from out-of-fold predictions, and compare it against plain soft voting before keeping it.

Is XGBoost an ensemble method?

Yes. XGBoost is a gradient boosting library, and boosting is an ensemble method: the final model is a sum of many decision trees, each trained to correct the errors of the trees before it.

Can I train an ensemble across multiple computers?

Yes. With TensorTurn you can connect two or more of your own machines and run a distributed job in ensemble mode, where each machine trains diverse members in parallel and their predictions are combined by voting or averaging.