MultivariateTransformer#
- class pyts.multivariate.transformation.MultivariateTransformer(estimator: _SupportsFitTransform | list[_SupportsFitTransform], flatten: bool = 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:
- estimatorestimator 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.
- flattenbool (default = True)
Affect shape of transform output. If True,
transformreturns an array with shape (n_samples, *). If False, the output oftransformfrom each estimator must have the same shape andtransformreturns an array with shape (n_samples, n_features, *). Ignored if the transformers return sparse matrices.
- Attributes:
- estimators_list of estimator objects
The collection of fitted transformers.
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)
Methods
__init__(estimator[, flatten])fit(X[, y])Pass.
fit_transform(X[, y])Fit to data, then transform it.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_params(**params)Set the parameters of this estimator.
transform(X)Apply transform to each feature.
- __init__(estimator: _SupportsFitTransform | list[_SupportsFitTransform], flatten: bool = True) None[source]#
- fit(X: ArrayLike, y: ArrayLike | None = None) Self[source]#
Pass.
- Parameters:
- Xarray-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- yNone or array-like, shape = (n_samples,) (default = None)
Class labels.
- Returns:
- selfobject
- fit_transform(X: ArrayLike, y: ArrayLike | None = None) NDArray[Any] | csr_matrix[source]#
Fit to data, then transform it.
Unlike most transformers,
transformmay return a sparse matrix (when the wrapped per-feature transformers do), so this method is overridden instead of relying onMultivariateTransformerMixin.fit_transform, whose declared return type is a plain array.- Parameters:
- Xarray-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- yNone or array-like, shape = (n_samples,) (default = None)
Class labels.
- Returns:
- X_newarray, shape = (n_samples, *) or (n_samples, n_features, *)
Transformed time series. May be a sparse matrix instead when the wrapped per-feature transformers return one.
- transform(X: ArrayLike) NDArray[Any] | csr_matrix[source]#
Apply transform to each feature.
- Parameters:
- Xarray-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- Returns:
- X_newarray, shape = (n_samples, *) or (n_samples, n_features, *)
Transformed time series.