[英]python statsmodels ARIMA plot_predict: How to get the data predicted?
I used ARIMAResults' plot_predict
function to predict 5 years in advance what the data would look like and it's fairly reasonable.我使用 ARIMAResults 的
plot_predict
函数提前 5 年预测数据的样子,这是相当合理的。 The only thing is, I need that data that was predicted for Power Bi!唯一的问题是,我需要为 Power Bi 预测的数据!
How can I actually see those values (not on the plot)?我如何才能真正看到这些值(不在情节上)?
Note: I am using python!注意:我正在使用 python!
Thanks!谢谢!
You need to call the predict()
method instead of plot_predict()
.您需要调用
predict()
方法而不是plot_predict()
。 It is more or less the same method with same parameters, but predict()
returns the predicted values as an array while plot_predict()
returns a figure.它或多或少是具有相同参数的相同方法,但
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.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 https://www.statsmodels.org/stable/generated/statsmodels.tsa.arima_model.ARIMAResults.predict.html#statsmodels.tsa.arima_model.ARIMAResults.predict
use predict instead of predict_plot()使用 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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.