BaggingClassifier
Bagging ensemble of time series classifiers.
Quickstart
from sktime.classification.ensemble import BaggingClassifier
estimator = BaggingClassifier(estimator, n_estimators=10, n_samples=1.0, n_features=1.0, bootstrap=True, bootstrap_features=False, random_state=None)Parameters(7)
- estimatorsktime classifier, descendant of BaseClassifier
- classifier to use in the bagging estimator
- n_estimatorsint, default=10
- number of estimators in the sample for bagging
- n_samplesint or float, default=1.0
The number of instances drawn from
Xinfitto train each clone If int, then indicates number of instances precisely If float, interpreted as a fraction, and rounded byceil- n_featuresint or float, default=1.0
The number of features/variables drawn from
Xinfitto train each clone If int, then indicates number of instances precisely If float, interpreted as a fraction, and rounded byceilNote: if n_features=1, BaggingClassifier turns a univariate classifier into a multivariate classifier (as slices seen byestimatorare all univariate).- bootstrapboolean, default=True
- whether samples/instances are drawn with replacement (True) or not (False)
- bootstrap_featuresboolean, default=False
- whether features/variables are drawn with replacement (True) or not (False)
- random_stateint, RandomState instance or None, optional (default=None)
If int,
random_stateis the seed used by the random number generator; IfRandomStateinstance,random_stateis the random number generator; If None, the random number generator is theRandomStateinstance used bynp.random.
Examples
>>> from sktime.classification.ensemble import BaggingClassifier
>>> from sktime.classification.kernel_based import RocketClassifier
>>> from sktime.datasets import load_unit_test
>>> X_train, y_train = load_unit_test (split = "train")
>>> X_test, y_test = load_unit_test (split = "test")
>>> clf = BaggingClassifier (
... RocketClassifier (num_kernels = 100),
... n_estimators = 10,
... )
>>> clf. fit (X_train, y_train) BaggingClassifier(
... )
>>> y_pred = clf. predict (X_test)