Holt-Winters预测算法的预测失败

问题描述 投票:0回答:1

我尝试使用Holt-Winters算法预测时间序列。问题是输出完全错误(此设置中的直线)。

我使用statsmodels实现,但不确定'seasonal_periods'参数。最初,我尝试使用60 * 24,因为数据的频率为一分钟,季节性为一天。但是几分钟后我停止了算法,因为我认为运行时间不会那么长。将参数设置为365(每年的天数),我得到的结果如下图所示。即使使用较低的值,运行时间仍为5-10分钟。这是Holt-Winters算法的惯用方法吗?

这是我的代码:

model = ExponentialSmoothing(train_forecast_data_df, seasonal='mul', seasonal_periods=365).fit()
pred = model.predict(start=test_forecast_data_df.index.min(), end=test_forecast_data_df.index.max())

fig, ax = plt.subplots(1, 1, figsize=(16, 4))
ax.plot(train_forecast_data_df.index, train_forecast_data_df, label='Train')
ax.plot(pred.index, pred, label='Holt-Winters', alpha=0.7, c='r', linestyle='-')
ax.plot(test_forecast_data_df.index, test_forecast_data_df, label='Test', alpha=0.7)

ax.legend(loc='best')

这里是结果。蓝色是火车数据,橙色是测试数据,红色是预测。forecasting of timeseries

我希望有人可以帮助我。

python time-series statsmodels forecasting holtwinters
1个回答
0
投票

根据我在您的图中看到的,您只有五天的数据。如果您每天都在寻找季节性,则可以使用Seasonal_periods =每天拥有的样本数。那将是您对1440的第一个猜测。

我的数据包含34951个样本,我的代码在下面(不幸的是,是的,运行大约需要一个小时)。m_h = 8760fit_yvth = ExponentialSmoothing((yv_trainh),season_periods = m_h,趋势='add',季节性='mul',阻尼= True).fit()yv_hath = fit_yvth.forecast(len(yv_th))

您可以做的另一件事是对数据重新采样,以减少处理速度更快的数据。我使用了4年的宝贵数据。每小时数据需要大约一个小时才能完成,而每天数据只需不到一分钟即可运行。 (将我的数据的season_periods减少为m_d = 365和1457个样本)

使用:train_h = train.resample('H')。mean()。bfill()

如果您不想直奔小时,可以对较小的块进行重新采样,例如,如下所示,将对5分钟进行重新采样。

train_5m = train.resample('5M')。mean()。bfill()

Below is the output after letting the code do it's thing.

© www.soinside.com 2019 - 2024. All rights reserved.