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

[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__([image_size, sample_range, method, …]) 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) Transform each time series into a GAF image.
__init__(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(X=None, y=None)[source]

Pass.

Parameters:
X

Ignored

y

Ignored

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_timestamps)

Univariate 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.

transform(X)[source]

Transform each time series into a GAF image.

Parameters:
X : array-like, shape = (n_samples, n_timestamps)
Returns:
X_new : array-like, shape = (n_samples, image_size, image_size)

Transformed data. If flatten=True, the shape is (n_samples, image_size * image_size).

Examples using pyts.image.GramianAngularField

Data set of Gramian angular fields

Data set of Gramian angular fields

Data set of Gramian angular fields
Single Gramian angular field

Single Gramian angular field

Single Gramian angular field