pyts.approximation.SymbolicFourierApproximation¶
-
class
pyts.approximation.SymbolicFourierApproximation(n_coefs=None, n_bins=4, strategy='quantile', drop_sum=False, anova=False, norm_mean=False, norm_std=False, alphabet=None)[来源]¶ 符号傅里叶近似。
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)。- n_bins : int (default = 4)
要生成的区间数量。区间的范围由输入数据的最小值和最大值决定。该值必须在2到26之间。
- strategy : str (default = ‘quantile’)
用于定义分箱宽度的策略:
- ‘uniform’: 每个样本中的所有箱宽度相同
- 'quantile': 每个样本中的所有分箱具有相同数量的数据点
- ‘normal’: 箱边缘为标准正态分布的分位数
- ‘entropy’: 使用信息增益计算分箱边界
- drop_sum : bool (default = False)
如果为True,则丢弃第一个傅里叶系数(即时间序列的和)。如果为False,则保留第一个傅里叶系数的实部。
- anova : bool (default = False)
如果为True,则通过单向ANOVA检验选择傅里叶系数。如果为False,则选择前几个傅里叶系数。
- norm_mean : bool (default = False)
如果为True,在缩放前对数据进行中心化处理。如果
norm_mean=True且anova=False,将丢弃第一个傅里叶系数。- norm_std : bool (default = False)
如果为True,将数据缩放到单位方差。
- alphabet : None, ‘ordinal’ or array-like, shape = (n_bins,)
使用的字母表。如果为None,当n_bins小于27时使用拉丁字母表的前n_bins个字母,否则字母表将定义为[chr(i) for i in range(n_bins)]。如果为'ordinal',则使用整数。
参考文献
[1] P. Schäfer 和 M. Högqvist, "SFA: 一种用于高维数据集相似性搜索的符号傅里叶近似与索引方法", 国际数据库技术扩展会议, 15, 516-527 (2012). 示例
>>> from pyts.approximation import SymbolicFourierApproximation >>> from pyts.datasets import load_gunpoint >>> X, _, _, _ = load_gunpoint(return_X_y=True) >>> transformer = SymbolicFourierApproximation(n_coefs=4) >>> X_new = transformer.fit_transform(X) >>> X_new.shape (50, 4)
Attributes: - bin_edges_ : array, shape = (n_bins - 1,) or (n_timestamps, n_bins - 1)
分箱边界形状为 (n_bins - 1,) 当
strategy='normal'时,否则为 (n_timestamps, n_bins - 1)。- support_ : array, shape = (n_coefs,)
保留的傅里叶系数索引。
方法
__init__([n_coefs, n_bins, strategy, …])Initialize self. fit(X[, y])Select Fourier coefficients and compute bin edges for each feature. fit_transform(X[, y])Fit then transform the provided data. get_params([deep])Get parameters for this estimator. set_params(**params)Set the parameters of this estimator. transform(X)Transform the provided data. -
__init__(n_coefs=None, n_bins=4, strategy='quantile', drop_sum=False, anova=False, norm_mean=False, norm_std=False, alphabet=None)[来源]¶ 初始化自身。查看 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或strategy='entropy'时使用。
-
fit_transform(X, y=None)[来源]¶ 先拟合然后转换提供的数据。
Parameters: - X : array-like, shape = (n_samples, n_timestamps)
待转换的数据。
- y : None or array-like, shape = (n_samples,)
每个样本的类别标签。仅在
anova=True或strategy='entropy'时使用。
返回值: - X_new : array-like, shape = (n_samples, n_coefs)
转换后的数据。
-
get_params(deep=True)¶ 获取此估计器的参数。
参数: - deep : bool, default=True
如果为True,将返回此估计器及其包含的子估计器的参数。
返回值: - params : dict
参数名称映射到对应的值。