pyts.image
.GramianAngularField¶
-
class
pyts.image.
GramianAngularField
(image_size=1.0, sample_range=(-1, 1), method='summation', overlapping=False, flatten=False)[source]¶ Gramian Angular Field.
Parameters: - image_size : int or float (default = 1.)
Shape of the output images. If float, it represents a percentage of the size of each time series and must be between 0 and 1. Output images are square, thus providing the size of one dimension is enough.
- sample_range : None or tuple (min, max) (default = (-1, 1))
Desired range of transformed data. If None, no scaling is performed and all the values of the input data must be between -1 and 1. If tuple, each sample is scaled between min and max; min must be greater than or equal to -1 and max must be lower than or equal to 1.
- method : ‘summation’ or ‘difference’ (default = ‘summation’)
Type of Gramian Angular Field. ‘s’ can be used for ‘summation’ and ‘d’ for ‘difference’.
- overlapping : bool (default = False)
If True, reduce the size of each time series using PAA with possible overlapping windows.
- flatten : bool (default = False)
If True, images are flattened to be one-dimensional.
References
[R972e7a1f5b03-1] Z. Wang and T. Oates, “Encoding Time Series as Images for Visual Inspection and Classification Using Tiled Convolutional Neural Networks.” AAAI Workshop (2015). Examples
>>> from pyts.datasets import load_gunpoint >>> from pyts.image import GramianAngularField >>> X, _, _, _ = load_gunpoint(return_X_y=True) >>> transformer = GramianAngularField() >>> X_new = transformer.transform(X) >>> X_new.shape (50, 150, 150)
Methods
__init__
(self[, image_size, sample_range, …])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)Transform each time series into a GAF image. -
__init__
(self, image_size=1.0, sample_range=(-1, 1), method='summation', overlapping=False, flatten=False)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
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.