簡體   English   中英

Python Statsmodels - AttributeError:“ARMAResults”對象沒有屬性“plot_predict”

[英]Python Statsmodels - AttributeError: 'ARMAResults' object has no attribute 'plot_predict'

我正在嘗試從http://statsmodels.sourceforge.net/devel/examples/notebooks/generated/tsa_arma_0.html運行以下 Statsmodels 示例。

fig, ax = plt.subplots(figsize=(12, 8))
ax = dta.ix['1950':].plot(ax=ax)
fig = arma_mod30.plot_predict('1990', '2012', dynamic=True, ax=ax, plot_insample=False)

運行上面的代碼會給出下面的錯誤消息。 即使升級到 Statsmodels 6,我也遇到了同樣的錯誤。

    AttributeError                            Traceback (most recent call last)
    <ipython-input-69-2a5da9c756f0> in <module>()
          1 fig, ax = plt.subplots(figsize=(12, 8))
          2 ax = dta.ix['1950':].plot(ax=ax)
    ----> 3 fig = arma_mod30.plot_predict('1990', '2012', dynamic=True, ax=ax,         plot_insample=False)

C:\Anaconda\lib\site-packages\statsmodels\base\wrapper.pyc in __getattribute__(self, attr)
     33             pass
     34 
---> 35         obj = getattr(results, attr)
     36         data = results.model.data
     37         how = self._wrap_attrs.get(attr)

AttributeError: 'ARMAResults' object has no attribute 'plot_predict'

有什么建議么?

遵循以下評論后,此問題已得到解決。 謝謝。

我剛剛在 statsmodels 0.13.2 中遇到了同樣的問題。 在深入研究他們的發行說明后,我可以看到繪圖功能已被分離出來。 代替

arma_mod30.plot_predict(...)

嘗試

from statsmodels.graphics.tsaplots import plot_predict


plot_predict(arma_mod30, ...)

希望這可以幫助

也許是statsmodels的版本實現了這一點。 在升級包到 0.6.1 之前嘗試檢查statsmodels的版本

 >>> import statsmodels
 >>> statsmodels.__version__

 $ pip install statsmodels --upgrade

有關更多信息,請單擊statsmodels.github 上的此問題

我也遇到了這個問題,# pip install statsmodels==0.11.0版本解決了這個問題。 更新所有 python 包后出現此錯誤。 總帳

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM