简体   繁体   中英

How to forecast for future dates using time series forecasting in 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)

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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