pyts.multivariate.transformation.MultivariateTransformer

class pyts.multivariate.transformation.MultivariateTransformer(estimator, flatten=True)[source]

Transformer for multivariate time series.

It provides a convenient class to transform multivariate time series with transformers that can only deal with univariate time series.

Parameters:
estimator : estimator object or list thereof

Transformer. If one estimator is provided, it is cloned and each clone transforms one feature. If a list of estimators is provided, each estimator transforms one feature.

flatten : bool (default = True)

Affect shape of transform output. If True, transform returns an array with shape (n_samples, *). If False, the output of transform from each estimator must have the same shape and transform returns an array with shape (n_samples, n_features, *). Ignored if the transformers return sparse matrices.

Examples

>>> from pyts.datasets import load_basic_motions
>>> from pyts.multivariate.transformation import MultivariateTransformer
>>> from pyts.image import GramianAngularField
>>> X, _, _, _ = load_basic_motions(return_X_y=True)
>>> transformer = MultivariateTransformer(GramianAngularField(),
...                                       flatten=False)
>>> X_new = transformer.fit_transform(X)
>>> X_new.shape
(40, 6, 100, 100)
Attributes:
estimators_ : list of estimator objects

The collection of fitted transformers.

Methods

__init__(self, estimator[, flatten]) Initialize self.
fit(self, X[, y]) Pass.
fit_transform(self, X[, y]) Fit to data, then transform it.
get_params(self[, deep]) Get parameters for this estimator.
set_params(self, \*\*params) Set the parameters of this estimator.
transform(self, X) Apply transform to each feature.
__init__(self, estimator, flatten=True)[source]

Initialize self. See help(type(self)) for accurate signature.

fit(self, X, y=None)[source]

Pass.

Parameters:
X : array-like, shape = (n_samples, n_features, n_timestamps)

Multivariate time series.

y : None or array-like, shape = (n_samples,) (default = None)

Class labels.

Returns:
self : object
fit_transform(self, X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
X : numpy array of shape [n_samples, n_features]

Training set.

y : numpy array of shape [n_samples]

Target values.

**fit_params : dict

Additional fit parameters.

Returns:
X_new : numpy array of shape [n_samples, n_features_new]

Transformed array.

get_params(self, deep=True)

Get parameters for this estimator.

Parameters:
deep : bool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

set_params(self, **params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**params : dict

Estimator parameters.

Returns:
self : object

Estimator instance.

transform(self, X)[source]

Apply transform to each feature.

Parameters:
X : array-like, shape = (n_samples, n_features, n_timestamps)

Multivariate time series.

Returns:
X_new : array, shape = (n_samples, *) or (n_samples, n_features, *)

Transformed time series.