DiscreteFourierTransform#
- class pyts.approximation.DiscreteFourierTransform(n_coefs: int | float | None = None, drop_sum: bool = False, anova: bool = False, norm_mean: bool = False, norm_std: bool = False)[source]#
Discrete Fourier Transform.
- Parameters:
- n_coefsNone, int or float (default = None)
The number of Fourier coefficients to keep. If None, all the Fourier coeeficients are kept. If an integer, the
n_coefsmost significant Fourier coefficients are returned ifanova=True, otherwise the firstn_coefsFourier coefficients are returned. If a float, it represents a percentage of the size of each time series and must be between 0 and 1. The number of coefficients will be computed asceil(n_coefs * (n_timestamps - 1))ifdrop_sum=Trueandceil(n_coefs * n_timestamps)ifdrop_sum=False.- drop_sumbool (default = False)
If True, the first Fourier coefficient (i.e. the sum of the subseries) is dropped. Otherwise, it is kept.
- anovabool (default = False)
If True, the Fourier coefficient selection is done via a one-way ANOVA test. If False, the first Fourier coefficients are selected.
- norm_meanbool (default = False)
If True, center each time series before scaling.
- norm_stdbool (default = False)
If True, scale each time series to unit variance.
- Attributes:
- support_array, shape = (n_coefs,)
Indices of the kept Fourier coefficients.
References
[1]P. Schäfer, and M. Högqvist, “SFA: A Symbolic Fourier Approximation and Index for Similarity Search in High Dimensional Datasets”, International Conference on Extending Database Technology, 15, 516-527 (2012).
Examples
>>> from pyts.approximation import DiscreteFourierTransform >>> from pyts.datasets import load_gunpoint >>> X, _, _, _ = load_gunpoint(return_X_y=True) >>> transformer = DiscreteFourierTransform(n_coefs=4) >>> X_new = transformer.fit_transform(X) >>> X_new.shape (50, 4)
Methods
__init__([n_coefs, drop_sum, anova, ...])fit(X[, y])Learn indices of the Fourier coefficients to keep.
fit_transform(X[, y])Learn and return the Fourier coeeficients to keep.
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)Return the selected Fourier coefficients for each sample.
- __init__(n_coefs: int | float | None = None, drop_sum: bool = False, anova: bool = False, norm_mean: bool = False, norm_std: bool = False) None[source]#
- fit(X: ArrayLike, y: ArrayLike | None = None) Self[source]#
Learn indices of the Fourier coefficients to keep.
- Parameters:
- Xarray-like, shape = (n_samples, n_timestamps)
Training vector.
- yNone or array-like, shape = (n_samples,) (default = None)
Class labels for each data sample. Only used if
anova=True.
- Returns:
- selfobject
- fit_transform(X: ArrayLike, y: ArrayLike | None = None) NDArray[float64][source]#
Learn and return the Fourier coeeficients to keep.
- Parameters:
- Xarray-like, shape = (n_samples, n_timestamps)
Training vector, where n_samples in the number of samples and n_features is the number of features.
- yNone or array-like, shape = (n_samples,) (default = None)
Class labels for each data sample.
- Returns:
- X_newarray, shape (n_samples, n_coefs)
The selected Fourier coefficients for each sample.