pyts.approximation.DiscreteFourierTransform¶
-
class
pyts.approximation.DiscreteFourierTransform(n_coefs=None, drop_sum=False, anova=False, norm_mean=False, norm_std=False)[来源]¶ 离散傅里叶变换。
Parameters: - n_coefs : None, int or float (default = None)
保留的傅里叶系数数量。如果为None,则保留所有傅里叶系数。如果是整数,当
anova=True时返回n_coefs个最显著的傅里叶系数,否则返回前n_coefs个傅里叶系数。如果是浮点数,它表示每个时间序列大小的百分比,必须在0到1之间。系数数量将计算为:当drop_sum=True时为ceil(n_coefs * (n_timestamps - 1)),当drop_sum=False时为ceil(n_coefs * n_timestamps)。- drop_sum : bool (default = False)
如果为True,则丢弃第一个傅里叶系数(即子序列之和)。否则,保留该系数。
- anova : bool (default = False)
如果为True,则通过单向ANOVA检验选择傅里叶系数。如果为False,则选择前几个傅里叶系数。
- norm_mean : bool (default = False)
如果为True,在缩放前对每个时间序列进行居中处理。
- norm_std : bool (default = False)
如果为True,则将每个时间序列缩放到单位方差。
参考文献
[1] P. Schäfer 和 M. Högqvist, "SFA: 一种用于高维数据集相似性搜索的符号傅里叶近似与索引方法", 国际数据库技术扩展会议, 15, 516-527 (2012). 示例
>>> 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)
属性: - support_ : array, shape = (n_coefs,)
保留的傅里叶系数索引。
方法
__init__([n_coefs, drop_sum, anova, …])Initialize self. fit(X[, y])Learn indices of the Fourier coefficients to keep. fit_transform(X[, y])Learn and return the Fourier coeeficients to keep. 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=None, drop_sum=False, anova=False, norm_mean=False, norm_std=False)[来源]¶ 初始化自身。查看 help(type(self)) 获取准确的签名信息。
-
fit(X, y=None)[来源]¶ 学习需要保留的傅里叶系数索引。
Parameters: - X : array-like, shape = (n_samples, n_timestamps)
训练向量。
- y : None or array-like, shape = (n_samples,) (default = None)
每个数据样本的类别标签。仅在
anova=True时使用。
返回值: - self : object
-
fit_transform(X, y=None)[来源]¶ 学习并返回需要保留的傅里叶系数。
参数: - X : array-like, shape = (n_samples, n_timestamps)
训练向量,其中n_samples是样本数量, n_features是特征数量。
- y : None or array-like, shape = (n_samples,) (default = None)
每个数据样本的类别标签。
返回值: - X_new : array, shape (n_samples, n_coefs)
每个样本选定的傅里叶系数。
-
get_params(deep=True)¶ 获取此估计器的参数。
参数: - deep : bool, default=True
如果为True,将返回此估计器及其包含的子估计器的参数。
返回值: - params : dict
参数名称映射到对应的值。