gpt4 book ai didi

python - 统计模型 ARIMA : how to get confidence/prediction interval?

转载 作者:行者123 更新时间:2023-12-04 08:46:40 27 4
gpt4 key购买 nike

如何生成“较低”和“较高”的预测,而不仅仅是“yhat”?

import statsmodels
from statsmodels.tsa.arima.model import ARIMA

assert statsmodels.__version__ == '0.12.0'

arima = ARIMA(df['value'], order=order)
model = arima.fit()
现在我可以生成“yhat”预测
yhat = model.forecast(123)
并获得模型参数的置信区间(但不是预测):
model.conf_int()
但如何生成 yhat_loweryhat_upper预测?

最佳答案

一般来说,forecastpredict方法只产生点预测,而 get_forecastget_prediction方法产生完整的结果,包括预测区间。
在您的示例中,您可以执行以下操作:

forecast = model.get_forecast(123)
yhat = forecast.predicted_mean
yhat_conf_int = forecast.conf_int(alpha=0.05)
如果您的数据是 Pandas 系列,则 yhat_conf_int将是一个包含两列的 DataFrame, lower <name>upper <name> ,其中 <name>是 Pandas 系列的名称。
如果您的数据是 numpy 数组(或 Python 列表),则 yhat_conf_int将是 (n_forecasts, 2)数组,其中第一列是区间的下部,第二列是区间的上部。

关于python - 统计模型 ARIMA : how to get confidence/prediction interval?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64277905/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com