Python statsmodels ARIMA plot_predict:如何获取预测的数据?

4

我使用了ARIMAResults的plot_predict函数来预测未来5年的数据,结果还算合理。唯一的问题是,我需要将这些预测出来的数据用在Power Bi中!

我该如何查看这些数值(而不是在图表上)?

注意:我正在使用Python语言!

谢谢!


你能给一个具体的例子吗?例如,它可能看起来像这样:data = [ ... some data ...] 然后 plot_predict(data)。一旦你有了一个具体的例子,其他人就可以精确地给你解决问题的指导。 - Zephaniah Grunschlag
2个回答

4
你需要调用predict()方法而不是plot_predict()。这两个方法基本相同,参数也一样,但predict()将预测值作为数组返回,而plot_predict()则返回一个图形。
参考链接:

https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima_model.ARIMAResults.plot_predict.html#statsmodels.tsa.arima_model.ARIMAResults.plot_predict

https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima_model.ARIMAResults.predict.html#statsmodels.tsa.arima_model.ARIMAResults.predict


1

使用 predict() 代替 predict_plot()

print("Predicted Price pct change")
def plotARMA(df_accumulative,ax,label):
    result=df_accumulative
    result=result.rolling(window=45).mean().dropna()
    mod = sm.tsa.arima.ARIMA(result, order=(2,0,0))
    res = mod.fit()
    # Plot the original series and the forecasted series
    #res.plot_predict(start=0, end=400)
    df_accumulative.plot(ax=ax,label=label)
    res.predict().plot(ax=ax,label=label)

fig,ax = plt.subplots(figsize=(20,20))    
plotARMA(duke_accumulative,ax,"Duke")
plotARMA(nee_accumulative,ax,"Next Era")
plotARMA(xel_accumulative,ax,"Xel")
plt.legend(fontsize=8)
plt.title("ARMA")
plt.show()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接