繁体   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