我建立了一个时间序列模型,并试图预测结果
model = ARIMA(df_mat.Total_Issue_quantities, order=(5,0,0))
y_predict_log = model.predict(start=1, end=24, exog=None, dynamic=False)
答案 0 :(得分:1)
缺少model.fit行
model_fit = model.fit(disp=0)
答案 1 :(得分:1)
要使用ARIMA
包中的statsmodels
模型,您必须先对其进行拟合,然后再进行预测。
考虑样本时间序列数据,
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]
为了借助ARIMA
从statsmodels
进行预测,您必须定义模型并像这样进行拟合,
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])