BaggingRegressor is a scikit-learn ensemble estimator for regression. It trains selected base estimators on sampled training data and combines their predictions, reducing the impact of individual overfit models. section 5.1.1
The estimator supports different sampling strategies through bootstrap, max_samples, and max_features. Its estimator parameter selects the model used in the ensemble; decision trees are the default. section 5.1.1
Use the parameters to choose how diversity enters the ensemble:
- Bagging samples training examples with replacement. section 5.1.1
- Pasting samples training examples without replacement. section 5.1.1
- Random subspaces sample features without replacement. section 5.1.1
- Random patches sample both training examples and features. section 5.1.1
Regression and stability selection
For a regression problem, replace the classification ensemble with BaggingRegressor and use Lasso as the base estimator. Repeated bootstrap fits can then reveal how consistently features receive relevant coefficients. section 6.2.1
Table 5.1 Bagging and sampling strategies (view table figure)
| Averaging strategy |
What happens to data |
Parameters for BaggingClassifier/BaggingRegressor |
|---|---|---|
| Pasting |
Training examples are sampled without replacement |
bootstrap = False max_samples < 1.0 max_features = 1.0 |
| Bagging |
Training examples are sampled with replacement (bootstrapping) |
bootstrap = True max_samples = 1.0 max_features = 1.0 |
| Random subspaces |
Features are sampled (without replacement) |
bootstrap = False max_samples = 1.0 max_features < 1.0 |
| Random patches |
Training examples and features are sampled without replacement |
bootstrap = False max_samples < 1.0 max_features < 1.0 |
Compare bootstrap, sample, and feature settings before configuring a BaggingRegressor. section 5.1.1
