Back to models
Classifier

WeightedEnsembleClassifier

Weighted ensemble of classifiers with fittable ensemble weight.

Quickstart

python
from sktime.classification.ensemble import WeightedEnsembleClassifier

estimator = WeightedEnsembleClassifier(classifiers, weights=None, cv=None, metric=None, metric_type='point', random_state=None)

Parameters(6)

classifiersdict or None, default=None
Parameters for the ShapeletTransformClassifier module. If None, uses the default parameters with a 2 hour transform contract.
weightsfloat, or iterable of float, optional, default=None

if float, ensemble weight for classifier i will be train score to this power if iterable of float, must be equal length as classifiers

ensemble weight for classifier i will be weights[i]

if None, ensemble weights are equal (uniform average)

cvNone, int, or sklearn cross-validation object, optional, default=None

determines whether in-sample or which cross-validated predictions used in fit None: predictions are in-sample, equivalent to fit(X, y).predict(X) cv: predictions are equivalent to fit(X_train, y_train).predict(X_test)

where multiple X_train, y_train, X_test are obtained from cv folds returned y is union over all test fold predictions cv test folds must be non-intersecting

intequivalent to cv=KFold(cv, shuffle=True, random_state=x),

i.e., k-fold cross-validation predictions out-of-sample random_state x is taken from self if exists, otherwise x=None

metricsklearn metric for computing training score, default=accuracy_score
only used if weights is a float
metric_typestr, one of “point” or “proba”, default=”point”
type of sklearn metric, point prediction (“point”) or probabilistic (“proba”) if “point”, most probable class is passed as y_pred if “proba”, probability of most probable class is passed as y_pred
random_stateint or None, default=None
Seed for random number generation.

Examples

>>> from sktime.classification.dummy import DummyClassifier
>>> 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 = WeightedEnsembleClassifier (
... [DummyClassifier (), RocketClassifier (num_kernels = 100)],
... weights = 2,
... )
>>> clf. fit (X_train, y_train) WeightedEnsembleClassifier(
... )
>>> y_pred = clf. predict (X_test)