[英]ARIMA summary showing as SARIMAX
我有一个 ARIMA(1,1,1) model 我试图适应 dataframe 的股票价格。 dataframe 的索引是一个日期。
下面的代码可以编译,但它会生成 SARIMAX 摘要而不是 ARIMA(见图)。
from statsmodels.tsa.arima.model import ARIMA
dataset_for_prediction.index = dataset_for_prediction.index.to_period('B')
model = ARIMA(dataset_for_prediction['Adj Close'], order=(1,1,1))
model_fit = model.fit()
print(model_fit.summary())
我怎样才能得到 plot 的实际结果。 我尝试了以下但它只产生一条水平线。
from statsmodels.graphics.tsaplots import plot_predict
plot_predict(model_fit)
plt.show()
试图打印预测值:
print(model_fit.predict())
Output
Date
2014-12-31 0.000000
2015-01-02 108.382622
2015-01-05 109.424271
2015-01-06 107.839921
2015-01-07 105.537888
...
2022-04-25 133.380821
2022-04-26 134.080382
2022-04-27 131.454924
2022-04-28 130.273586
2022-04-29 130.850081
fig = plot_predict(model_fit, start=dataset_for_prediction.index[1], end=dataset_for_prediction.index[-1], ax=ax)
import yfinance as yf
from statsmodels.tsa.arima.model import ARIMA
from statsmodels.graphics.tsaplots import plot_predict
import matplotlib.pyplot as plt
dataset_for_prediction = yf.download('IBM', start='2015-01-01', end='2022-04-30')
dataset_for_prediction.index = dataset_for_prediction.index.to_period('B')
model = ARIMA(dataset_for_prediction['Adj Close'], order=(1, 1, 1))
model_fit = model.fit()
fig, ax = plt.subplots()
ax = dataset_for_prediction['Adj Close'].plot(ax=ax)
fig = plot_predict(model_fit, start=dataset_for_prediction.index[1], end=dataset_for_prediction.index[-1], ax=ax)
legend = ax.legend(loc='upper left')
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.