【问题标题】:Python ARIMA Forecast is showing a FlatlinePython ARIMA 预测显示扁平线
【发布时间】:2020-01-07 19:50:52
【问题描述】:

我正在尝试预测标准普尔 500 指数。但是,我得到的预测是平线(没有季节性或任何其他因素)。尝试使用 python Pyramid Arima 库。数据是标准普尔 500 (SPY) 指数,每日“收盘价”。

对 auto_arima 函数有任何建议的更改吗?有没有办法对此进行调整,以便最终预测显示趋势和季节性而不是平坦线?

import pmdarima as pm

smodel = pm.auto_arima(data, start_p=0, start_q=0,
                         test='adf',
                         max_p=4, max_q=4, m=7,
                         start_P=0, seasonal=True,
                         d=None, D=1, trace=True,
                         error_action='ignore',  
                         suppress_warnings=True, 
                         stepwise=True)

smodel.summary()

# Forecast
n_periods = 52
fitted, confint = smodel.predict(n_periods=n_periods, return_conf_int=True)
index_of_fc = pd.date_range(data.index[-1], periods = n_periods, freq='MS')

# make series for plotting purpose
fitted_series = pd.Series(fitted, index=index_of_fc)
lower_series = pd.Series(confint[:, 0], index=index_of_fc)
upper_series = pd.Series(confint[:, 1], index=index_of_fc)

# Plot
plt.plot(data)
plt.plot(fitted_series, color='darkgreen')
plt.fill_between(lower_series.index, 
                 lower_series, 
                 upper_series, 
                 color='k', alpha=.15)

plt.title("SARIMA - Final Forecast of SPY")
plt.show()

【问题讨论】:

    标签: python forecasting arima pyramid-arima pmdarima


    【解决方案1】:

    当您的历史数据没有很强的季节性并且预测模型发现难以预测那里的未来数据点时,就会发生这种情况,因此它只是取您之前的值的平均值并预测为未来。因此,您将获得直线。

    【讨论】:

    • 谢谢!作为对此的一个实验,我试图从过去提供更少的数据点,那里有更多的趋势。完成此操作后,它的预测确实超出了一直以来的平线平均值。
    猜你喜欢
    • 2016-02-13
    • 2023-03-30
    • 2021-08-22
    • 2021-03-01
    • 2020-04-07
    • 1970-01-01
    • 1970-01-01
    • 2017-05-01
    • 2017-07-28
    相关资源
    最近更新 更多