由于未公开完整结果(包括预测间隔等),因此存在一些与向后兼容性相关的问题。
现在就得到你想要的:使用 get_prediction 和 get_forecast 函数以及下面描述的参数
pred_res = sarimax_model.get_prediction(exog=ExogenousFeature_train.values.astype('float64'), full_results=True,alpha=0.05)
pred_means = pred_res.predicted_mean
# Specify your prediction intervals by alpha parameter. alpha=0.05 implies 95% CI
pred_cis = pred_res.conf_int(alpha=0.05)
# You can then plot it (import matplotlib first)
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(1,1,1)
#Actual data
ax.plot(y_train.astype('float64'), '--', color="blue", label='data')
# Means
ax.plot(pred_means, lw=1, color="black", alpha=0.5, label='SARIMAX')
ax.fill_between(pred_means.index, pred_cis.iloc[:, 0], pred_cis.iloc[:, 1], alpha=0.05)
ax.legend(loc='upper right')
plt.draw()
欲了解更多信息,请访问:
- https://github.com/statsmodels/statsmodels/issues/2823 https://github.com/statsmodels/statsmodels/issues/2823
- 作者的解决方案:http://www.statsmodels.org/dev/examples/notebooks/ generated/statespace_local_linear_trend.html http://www.statsmodels.org/dev/examples/notebooks/generated/statespace_local_linear_trend.html