Bootstrap aggregating


Bootstrap aggregating, also called bagging, is a machine learning ensemble meta-algorithm designed to improve the stability and accuracy of machine learning algorithms used in statistical classification and regression. It also reduces variance and helps to avoid overfitting. Although it is usually applied to decision tree methods, it can be used with any type of method. Bagging is a special case of the model averaging approach.

Description of the technique

Given a standard training set of size n, bagging generates m new training sets, each of size n′, by sampling from D uniformly and with replacement. By sampling with replacement, some observations may be repeated in each. If n′=n, then for large n the set is expected to have the fraction of the unique examples of D, the rest being duplicates. This kind of sample is known as a bootstrap sample. Then, m models are fitted using the above m bootstrap samples and combined by averaging the output or voting.
Bagging leads to "improvements for unstable procedures", which include, for example, artificial neural networks, classification and regression trees, and subset selection in linear regression. An interesting application of bagging showing improvement in preimage learning is provided here. On the other hand, it can mildly degrade the performance of stable methods such as K-nearest neighbors.

Example: Ozone data

To illustrate the basic principles of bagging, below is an analysis on the relationship between ozone and temperature.
The relationship between temperature and ozone in this data set is apparently non-linear, based on the scatter plot. To mathematically describe this relationship, LOESS smoothers are used.
Instead of building a single smoother from the complete data set, 100 bootstrap samples of the data were drawn. Each sample is different from the original data set, yet resembles it in distribution and variability. For each bootstrap sample, a LOESS smoother was fit. Predictions from these 100 smoothers were then made across the range of the data. The first 10 predicted smooth fits appear as grey lines in the figure below. The lines are clearly very wiggly and they overfit the data - a result of the bandwidth being too small.
By taking the average of 100 smoothers, each fitted to a subset of the original data set, we arrive at one bagged predictor. Clearly, the mean is more stable and there is less overfit.

History

Bagging was proposed by Leo Breiman in 1994 to improve classification by combining classifications of randomly generated training sets.