binder

Theta Lines 转换器#

计算用于 ThetaForecaster 的 Theta lines。

Theta lines 是通过修改原始时间序列各点之间的距离得到的。我们将系数 θ (theta) 应用于原始观测值的二阶差分,从而改变局部曲率。Theta 系数是一个变换参数,它创建与原始数据具有相同均值和斜率但方差不同的序列。

[15]:
import matplotlib.pyplot as plt

from sktime.datasets import load_airline
from sktime.transformations.series.theta import ThetaLinesTransformer

y = load_airline()
transformer = ThetaLinesTransformer()
transformer.fit(y)
y_thetas = transformer.transform(y)

fig, ax = plt.subplots()
y_thetas.plot(ax=ax, figsize=(12, 7))
plt.legend(["theta=0", "theta=2"])
[15]:
<matplotlib.legend.Legend at 0x1b808c49370>
../../_images/examples_transformation_theta_transform_1_1.svg

特殊情况:theta = 0 和 theta = 1#

Theta 值 1 > theta > 0减小原始时间序列的曲率。Theta 系数值越小,时间序列的收缩程度越大。

theta=0 时,Theta-line 给出一条线性回归线。

[16]:
t = ThetaLinesTransformer([0, 0.25, 0.75, 1])
t.fit(y)
y_t = t.transform(y)

fig, ax = plt.subplots()
y_t.plot(ax=ax, figsize=(12, 7))
plt.legend(
    ["theta=0, linear regression", "theta=0.25", "theta=0.75", "theta=1, original ts"]
)
plt.ylim(0, 900)
[16]:
(0.0, 900.0)
../../_images/examples_transformation_theta_transform_3_1.svg

theta=1 时,Theta-line 返回原始时间序列。

Theta 值 > 1 会增加局部曲率,Theta 系数越大,扩展程度越大。

[17]:
t_1 = ThetaLinesTransformer([0, 1, 2, 2.5])
t_1.fit(y)
y_t1 = t_1.transform(y)

fig, ax = plt.subplots()
y_t1.plot(ax=ax, figsize=(12, 7))
plt.legend(
    ["theta=0, linear regression", "theta=1, original ts", "theta=2", "theta=2.5"]
)
[17]:
<matplotlib.legend.Legend at 0x1b80996baf0>
../../_images/examples_transformation_theta_transform_5_1.svg
[ ]:


使用 nbsphinx 生成。Jupyter notebook 可在此处找到:这里