Bagging for classification
Scikit-learn's implementation of bagging lies in the sklearn.ensemble package. BaggingClassifier is the corresponding class for classification problems. It has a number of interesting parameters, allowing for greater flexibility. It can use any scikit-learn estimator by specifying it with base_estimator. Furthermore, n_estimators dictates the ensemble's size (and, consequently, the number of bootstrap samples that will be generated), while n_jobs dictates how many jobs (processes) will be used to train and predict with each base learner. Finally, if set to True, oob_score calculates the out-of-bag score for the base learners.
Using the actual classifier is straightforward and similar to all other scikit-learn estimators. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access