繁体   English   中英

Python ARIMA Forecast 显示平线

[英]Python ARIMA Forecast is showing a Flatline

我正在尝试预测标准普尔 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()

在此处输入图片说明

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

暂无
暂无

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

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