GramianAngularField#
- class pyts.image.GramianAngularField(image_size: int | float = 1.0, sample_range: tuple[float, float] | None = (-1, 1), method: str = 'summation', overlapping: bool = False, flatten: bool = False)[source]#
Gramian Angular Field.
- Parameters:
- image_sizeint 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_rangeNone 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’.
- overlappingbool (default = False)
If True, reduce the size of each time series using PAA with possible overlapping windows.
- flattenbool (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, ...])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)Transform each time series into a GAF image.
- __init__(image_size: int | float = 1.0, sample_range: tuple[float, float] | None = (-1, 1), method: str = 'summation', overlapping: bool = False, flatten: bool = False) None[source]#
- fit(X: ArrayLike | None = None, y: ArrayLike | None = None) Self[source]#
Pass.
- Parameters:
- X
Ignored
- y
Ignored
- Returns:
- selfobject
- transform(X: ArrayLike) NDArray[float64][source]#
Transform each time series into a GAF image.
- Parameters:
- Xarray-like, shape = (n_samples, n_timestamps)
- Returns:
- X_newarray-like, shape = (n_samples, image_size, image_size)
Transformed data. If
flatten=True, the shape is (n_samples, image_size * image_size).