无法在Python上使用Holt Winters模型进行多步预测

时间:2019-10-25 07:22:26

标签: python statsmodels forecasting holtwinters

我有以下代码,这些代码将创建霍尔特模型进行预测并尝试“样本外”预测。我尝试在.forecast()方法中添加“ step =“参数来预测接下来的4个时间戳,但只显示一个预测值,这是我的代码:

from statsmodels.tsa.api import Holt
import pickle

# create and save model
final_h = dataset.values
# fit model
model_h = Holt(final_h)
model_fit_h = model_h.fit(smoothing_level=0.8, smoothing_slope=0.2,optimized=False)
# save model
model_fit_h.save('model_h.pkl')

#load model and do forecast
model_fit_se = pickle.load(open('model_se.pkl', 'rb'))
yhat = model_fit_se.forecast(steps=4)[0]
print('Predicted: %.3f' % yhat)

这是我的输出

Out[24]: 63.54036287190339

但是我希望4是因为yhat = model_fit_se.forecast(steps = 4)[0]

0 个答案:

没有答案