【发布时间】:2019-09-07 06:39:26
【问题描述】:
我建立了一个时间序列模型并尝试预测结果
model = ARIMA(df_mat.Total_Issue_quantities, order=(5,0,0))
y_predict_log = model.predict(start=1, end=24, exog=None, dynamic=False)
【问题讨论】:
标签: python python-3.x dataframe time-series
我建立了一个时间序列模型并尝试预测结果
model = ARIMA(df_mat.Total_Issue_quantities, order=(5,0,0))
y_predict_log = model.predict(start=1, end=24, exog=None, dynamic=False)
【问题讨论】:
标签: python python-3.x dataframe time-series
错过了model.fit线
model_fit = model.fit(disp=0)
【讨论】:
为了使用 statsmodels 包中的 ARIMA 模型,您必须先拟合模型,然后再使用它进行预测。
考虑一个样本时间序列数据,
series = [266, 145.9, 183.1, 119.3, 180.3, 168.5, 231.8, 224.5, 192.8, 122.9, 336.5, 185.9, 194.3, 149.5, 210.1, 273.3, 191.4, 287,
226, 303.6, 289.9, 421.6, 264.5, 342.3, 339.7, 440.4, 315.9, 439.3, 401.3, 437.4, 575.5, 407.6, 682, 475.3, 581.3, 646.9]
为了像你想要的那样在statsmodels 的ARIMA 的帮助下进行预测,你必须定义模型并像这样拟合它,
model = ARIMA(series, order=(5,0,0))
model_fit = model.fit(disp=0)
那你得用拟合好的模型来做这样的预测,
model_fit.predict(start=1, end=24, exog=None, dynamic=False)
# Output : array([285.26079759, 241.67873214, 188.09176114, 172.71030303,
151.02883535, 171.42694684, 187.24591603, 222.14251879,
231.60804343, 200.38894148, 165.46244686, 276.73489965,
234.58863518, 189.25204514, 175.23997131, 207.32713479,
259.00583598, 226.21898223, 261.36238407, 255.73519862,
285.57681894, 310.52631127, 376.59078703, 314.29265595])
【讨论】: