如何使用 Python 中的时间序列预测来预测未来日期? [英] How to forecast for future dates using time series forecasting in Python?

查看:52
本文介绍了如何使用 Python 中的时间序列预测来预测未来日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是时间序列预测的新手,并制作了以下模型:

I am new to time series forecasting and have made the following model:

df = pd.read_csv('timeseries_data.csv', index_col="Month")

# ARMA
from statsmodels.tsa.arima_model import ARMA
from random import random
# contrived dataset
data = df
# fit model
model = ARMA(data, order=(2, 1))
model_fit = model.fit(disp=False)
# make prediction
yhat = model_fit.predict()
print(yhat)

以上代码预测df中的数据点.但是如果我想预测未来的某个日期该怎么办?例如:2022 年全年?

The above code predicts for the data points in df. But what should I do if I want to predict for some future date? For example: For the entire year of 2022?

推荐答案

我找到了解决方案,其实很简单:

I found the solution, it was actually very simple:

arma_df = model_fit.predict(start='2020-01-01', end='2023-12-01')

这篇关于如何使用 Python 中的时间序列预测来预测未来日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆