Back to models
Transformer

CombineTransformers

Combination operation applied to the outputs of multiple transformers.

Quickstart

python
from sktime.transformations.compose import CombineTransformers

estimator = CombineTransformers(transformers, op)

Parameters(2)

transformerslist of (str, transformer) tuples
List of transformers to apply to the input data. Each tuple contains a name and a transformer instance. All transformers must inherit from BaseTransformer.
opnumpy ufuncs or callable of same signature
Function to apply to the outputs of the transformers. Should accept N arrays/Series/DataFrames and return a DataFrame or Series. Examples include numpy ufuncs (e.g., np.add, np.divide) or custom functions.

Examples

>>> import numpy as np
>>> from sktime.utils._testing.series import _make_series
>>> from sktime.transformations.exponent import ExponentTransformer
>>> from sktime.transformations.compose import CombineTransformers
>>> transformers = [
... ("t1", ExponentTransformer (power = 2)),
... ("t2", ExponentTransformer (power = 1)),
... ]
>>> op = CombineTransformers (transformers, op = np. divide)
>>> X = _make_series (n_timepoints = 10, n_columns = 2, random_state = 42)
>>> Xt = op. fit_transform (X)
>>> # Xt contains the elementwise ratio of squared to original values

References

  1. Inspired by scikit-learn’s FunctionTransformer and FeatureUnion.