【发布时间】:2022-01-13 05:20:26
【问题描述】:
我正在尝试学习如何根据 Statsmodel 库中的 ARIMA 模型预测数据,但我一直遇到问题。目前我只是试图将我的预测与实际情况对齐以测试我的模型,但我无法让 ARIMA 模型结果进行合作
import statsmodels.api as sm
model = sm.tsa.arima.ARIMA(train, order=(4,1,2))
result = model.fit()
result.summary()
step = 10
fc, se, conf = result.forecast(step)
这一切正常,但最后一步是抛出此错误
ValueError Traceback (most recent call last)
Input In [57], in <module>
1 step = 10
----> 3 fc, se, conf = result.forecast(step)
ValueError: too many values to unpack (expected 3)
我已经阅读了几个小时的文档,但我无法理解它。任何帮助将不胜感激
【问题讨论】:
-
嗨,你看
help(result.forecast)了吗?它说它返回预测值的平均值(并且只有那些)。所以它返回 1 件事,但你期望 3 件事,因此错误。我猜fc的意思是“预测”,对吧?然后直接fc = result.forecast(step)。conf是置信区间?然后你通过conf = result.get_forecast(step).conf_int()得到它(我同意 API 有点不直观)。不确定se是什么意思。 (参数估计的标准误差?然后是se = result.bse;你可以看到here。)
标签: python pandas matplotlib statsmodels arima