Time Series 简明教程
Time Series - Exponential Smoothing
在本章中,我们将讨论时间序列指数平滑涉及的技术。
In this chapter, we will talk about the techniques involved in exponential smoothing of time series.
Simple Exponential Smoothing
指数平滑是一种通过在一段时间内对数据分配指数递减的权重来平滑单变量时间序列的技术。
Exponential Smoothing is a technique for smoothing univariate time-series by assigning exponentially decreasing weights to data over a time period.
在数学上,给定时间 t 时的值 y_(t+1|t) 时,时间“t+1”时的变量值定义为 −
Mathematically, the value of variable at time ‘t+1’ given value at time t, y_(t+1|t) is defined as −
y_{t+1|t}\:=\:\alpha y_{t}\:+\:\alpha\lgroup1 -\alpha\rgroup y_{t-1}\:+\alpha\lgroup1-\alpha\rgroup^{2}\:y_{t-2}\:+\:…+y_{1}
y_{t+1|t}\:=\:\alpha y_{t}\:+\:\alpha\lgroup1 -\alpha\rgroup y_{t-1}\:+\alpha\lgroup1-\alpha\rgroup^{2}\:y_{t-2}\:+\:…+y_{1}
其中,0≤α≤1 是平滑参数,并且
where,$0\leq\alpha \leq1$ is the smoothing parameter, and
$y_{1},….,y_{t}$ 是网络流量在时间点 1、2、3、… 、t 的前值。
$y_{1},….,y_{t}$ are previous values of network traffic at times 1, 2, 3, … ,t.
这是建模没有明显趋势或季节性的时间序列的一种简单方法。但指数平滑也可用于具有趋势和季节性的时间序列。
This is a simple method to model a time series with no clear trend or seasonality. But exponential smoothing can also be used for time series with trend and seasonality.
Triple Exponential Smoothing
三重指数平滑 (TES) 或霍尔特冬季方法应用指数平滑三次 - 水平平滑 $l_{t}$、趋势平滑 $b_{t}$ 和季节性平滑 $S_{t}$,其中 $\alpha$, $\beta^{*}$ 和 $\gamma$ 作为平滑参数,“m”为季节性频率,即一年中的季节数。
Triple Exponential Smoothing (TES) or Holt’s Winter method, applies exponential smoothing three times - level smoothing $l_{t}$, trend smoothing $b_{t}$, and seasonal smoothing $S_{t}$, with $\alpha$, $\beta^{*}$ and $\gamma$ as smoothing parameters with ‘m’ as the frequency of the seasonality, i.e. the number of seasons in a year.
根据季节性分量的性质,TES 有两种类别−
According to the nature of the seasonal component, TES has two categories −
-
Holt-Winter’s Additive Method − When the seasonality is additive in nature.
-
Holt-Winter’s Multiplicative Method − When the seasonality is multiplicative in nature.
对于非季节性时间序列,我们只有趋势平滑和水平平滑,这称为霍尔特线性趋势法。
For non-seasonal time series, we only have trend smoothing and level smoothing, which is called Holt’s Linear Trend Method.
让我们尝试对我们的数据应用三重指数平滑。
Let’s try applying triple exponential smoothing on our data.
输入[316]:
In [316]:
from statsmodels.tsa.holtwinters import ExponentialSmoothing
model = ExponentialSmoothing(train.values, trend= )
model_fit = model.fit()
输入[322]:
In [322]:
predictions_ = model_fit.predict(len(test))
输入[325]:
In [325]:
plt.plot(test.values)
plt.plot(predictions_[1:1871])
输出[325]:
Out[325]:
[<matplotlib.lines.Line2D at 0x1eab00f1cf8>]
在这里,我们用训练集训练了一次模型,然后我们继续做出预测。一种更现实的方法是在一个或多个时间步之后重新训练模型。当我们从训练数据“直到时间‘t’”获得时间“t+1”的预测时,下一次时间“t+2”的预测可以使用训练数据“直到时间‘t+1’”来做出,因为那时将知道时间“t+1”的实际值。这种为一个或多个未来步做出预测然后重新训练模型的方法称为滚动预测或向前验证。
Here, we have trained the model once with training set and then we keep on making predictions. A more realistic approach is to re-train the model after one or more time step(s). As we get the prediction for time ‘t+1’ from training data ‘til time ‘t’, the next prediction for time ‘t+2’ can be made using the training data ‘til time ‘t+1’ as the actual value at ‘t+1’ will be known then. This methodology of making predictions for one or more future steps and then re-training the model is called rolling forecast or walk forward validation.