简体   繁体   English

通过Statsmodels进行时间序列预测

[英]Time series forecasting via Statsmodels

I used the following code the make some predictions : 我使用以下代码进行一些预测:

Just to give your a quick look at the dataset (df.head()): 只是为了让您快速浏览数据集(df.head()):

  places_occupees                date
0              238 2017-01-01 00:00:00
1              238 2017-01-01 00:01:00
2              238 2017-01-01 00:02:00
3              238 2017-01-01 00:03:00
4              238 2017-01-01 00:04:00

Then I make predictions for the 7 days to come: 然后,我对接下来的7天进行预测:

X = places.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)

I get the following output: 我得到以下输出:

在此处输入图片说明

This is how the plot looks like: 这是情节的样子:

在此处输入图片说明

But what I really want to do is to make some predictions for the next 24 hours and not for the next 7 days. 但是我真正想做的是对接下来的24小时而不是接下来的7天做出一些预测。 How can I do that? 我怎样才能做到这一点? How shoud I modify the code above? 我应该如何修改上面的代码?

Thanks in advance. 提前致谢。

您应该编码

train, test = X[:-30], X[-30:]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM