未来24小时的预测

时间:2018-11-28 05:55:12

标签: python machine-learning time-series autoregressive-models

我已经能够成功实现在互联网(https://machinelearningmastery.com/autoregression-models-time-series-forecasting-python/)上找到的代码,因此我可以通过时间序列的自回归模型预测未来7天的温度。您可以在下面找到用于进行这些预测的代码:

X = temp.values
train, test = X[1:len(X)-7], X[len(X)-7:]
# On entraîne le modèle d'autoregression
model = AR(train)
model_fit = model.fit()
print('Lag: %s' % model_fit.k_ar)
print('Coefficients: %s' % model_fit.params)
#On effectue des predictions
predictions = model_fit.predict(start=len(train), end=len(train)+len(test)-1, dynamic=False)
for i in range(len(predictions)):
    print('predicted=%f, expected=%f' % (predictions[i], test[i]))
error = mean_squared_error(test, predictions)

但是我想做的是预测未来12或24小时,而不是未来几天。你能帮我这个忙吗?

谢谢。

0 个答案:

没有答案