【问题标题】:How to forecast for future dates using time series forecasting in Python?如何使用 Python 中的时间序列预测来预测未来日期?
【发布时间】:2020-06-01 17:35:57
【问题描述】:

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

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 年全年?

【问题讨论】:

    标签: python time-series statsmodels arima


    【解决方案1】:

    我找到了解决办法,其实很简单:

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

    【讨论】:

    • 另一种选择是使用model_fit.forecast('2023-12-01')
    • 它根本不起作用
    猜你喜欢
    • 2019-11-02
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    • 2020-08-19
    • 1970-01-01
    • 2018-05-09
    • 2020-09-28
    相关资源
    最近更新 更多