ARIMA模型预测与实际差异

时间:2019-05-28 14:34:50

标签: python-3.x statsmodels

我有2018年的日销售数据,并通过应用网格搜索(用于循环)对ARIMA模型进行了分析,得出了(0,1,2)等最佳值,RMSE值是61.562。

我的天真的预测模型的RMSE值(126.39)小于ARIMA的RMSE(61.562),所以我认为ARIMA模型的效果很好?

我在理解ARIMA预测值与预期值之间的差异时遇到困难,并想知道模型执行者是否表现良好以及差异是否可以接受。

已随附ARIMA测试和预测图的屏幕截图。

Predict Vs Test

ARIMA的输出

Train Set Lenght: 736
Test Set Lenght: 380
>Predicted=15.584, Expected= 20
>Predicted=18.602, Expected= 10
>Predicted=14.051, Expected= 30
>Predicted=22.576, Expected= 60
>Predicted=34.849, Expected= 10
>Predicted=16.423, Expected= 50
>Predicted=35.823, Expected= 54
>Predicted=36.277, Expected=  6
>Predicted=19.700, Expected= 35
>Predicted=32.607, Expected=  1
>Predicted=16.107, Expected= 36
>Predicted=31.214, Expected= 20
>Predicted=22.272, Expected=  4
>Predicted=17.035, Expected=  4
>Predicted=15.497, Expected=  8
>Predicted=15.150, Expected=  3
>Predicted=11.664, Expected=  3
>Predicted=10.629, Expected=  3
>Predicted=9.278, Expected=  3
>Predicted=8.268, Expected=  4
>Predicted=7.810, Expected=  4
>Predicted=7.114, Expected=  4
>Predicted=6.610, Expected=  4
>Predicted=6.168, Expected=  2
>Predicted=4.964, Expected= 12
>Predicted=8.790, Expected= 16
ARIMA Code snippet
train_series=north_top_painter_df["Volume"].values
train_size = int(len(train_series) * 0.66)
x_train, x_test = train_series[0:train_size], train_series[train_size:]
print('Train Set Lenght:',len(x_train))
print('Test Set Lenght:',len(x_test))
# walk-forward validation
history = [i for i in x_train]
predictions = list()

for i in range(len(x_test)):
  # predict
  model = ARIMA(history, order=(0,1,2))
  model_fit = model.fit(disp=0)
  #y_pred=model_fit.predict(start=len(train), end=len(train)+len(test)-1, dynamic=False)
  y_pred = model_fit.forecast()[0]
  predictions.append(y_pred)
  #observation
  test_obs = x_test[i]
  history.append(test_obs)
  print('>Predicted=%.3f, Expected=%3.f' % (y_pred, test_obs))
# report performance
rmse = sqrt(mean_squared_error(x_test, predictions))
print('RMSE: %.3f' % rmse)
plt.plot(x_test, label = "Test",color='blue') 
#plt.plot(y_pred)
plt.plot(predictions, color = 'red', label = "Predict") 
plt.legend(loc='best')
plt.show()

0 个答案:

没有答案