时间序列 - 逐步验证



在时间序列建模中,随着时间的推移,预测会变得越来越不准确,因此一种更实际的方法是在获得实际数据后用这些数据重新训练模型,以便进行进一步的预测。由于训练统计模型不会耗费大量时间,所以逐步验证是最受青睐的解决方案,它可以得到最准确的结果。

让我们对自己的数据应用一步一步的逐步验证,并将它与我们之前获得的结果进行比较。

In [333]

prediction = []
data = train.values
for t In test.values:
   model = (ExponentialSmoothing(data).fit())
   y = model.predict()
   prediction.append(y[0])
   data = numpy.append(data, t)

In [335]

test_ = pandas.DataFrame(test)
test_['predictionswf'] = prediction

In [341]

plt.plot(test_['T'])
plt.plot(test_.predictionswf, '--')
plt.show()
Code Snippet 18

In [340]

error = sqrt(metrics.mean_squared_error(test.values,prediction))
print ('Test RMSE for Triple Exponential Smoothing with Walk-Forward Validation: ', error)
Test RMSE for Triple Exponential Smoothing with Walk-Forward Validation:  11.787532205759442

我们可以看到,我们的模型现在表现得要好得多。实际上,它紧密地遵循了趋势,在图中,预测值与实际值完全重叠。你可以在 ARIMA 模型上尝试应用逐步验证。

广告
© . All rights reserved.