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 oftransform
from each estimator must have the same shape andtransform
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__
(estimator[, flatten])Initialize self. fit
(X[, y])Pass. fit_transform
(X[, y])Fit to data, then transform it. 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, flatten=True)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(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
(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 : array-like, shape = (n_samples, n_features, n_timestamps)
Multivariate time series.
- y : None or array-like, shape = (n_samples,) (default = None)
Target values (None for unsupervised transformations).
- **fit_params : dict
Additional fit parameters.
Returns: - X_new : array
Transformed array.
-
get_params
(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 : dict
Parameter names mapped to their values.
-
set_params
(**params)¶ Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). 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 : estimator instance
Estimator instance.