statsmodel /指数平滑是否正常工作?

问题描述

我正在使用statsmodels和指数平滑方法进行时间序列分析。我正在尝试从中复制结果

https://www.statsmodels.org/devel/examples/notebooks/generated/exponential_smoothing.html

具有特定的dataframe(格式与示例相同,但只有一个结果)。 这是代码行:

from statsmodels.tsa.api import ExponentialSmoothing,SimpleExpSmoothing,Holt

fit = ExponentialSmoothing(dataframe,seasonal_periods=4,trend='add',seasonal='mul',initialization_method="estimated").fit()
simulations = fit.simulate(5,repetitions=100,error='mul')
fit.fittedvalues.plot(ax=ax,style='--',color='green')
simulations.plot(ax=ax,style='-',alpha=0.05,color='grey',legend=False)
fit.forecast(8).rename('Holt-Winters (add-mul-seasonal)').plot(ax=ax,marker='o',color='green',legend=True)

但是,当我运行它时,我得到了错误

TypeError: __init__() got an unexpected keyword argument 'initialization_method'

但是当我在ExponentialSmoothing中检查statsmodel的参数时,initialization_method是其中之一,所以我不知道在那里会发生什么。

向前移动,我从代码中的initialization_method的参数中删除了ExponentialSmoothing,然后在下面的行中出现了另一个错误

AttributeError: 'ExponentialSmoothing' object has no attribute 'simulate'

再次,我去检查simulate的最新版本中是否不弃用statsmodels,否,它仍然是一个属性。

我升级了statsmodels,我升级了pip,但仍然出现相同的错误。

那是怎么回事?

在此先感谢您的帮助!

解决方法

实际上,先前版本中存在一个错误,该错误已在新版本的statsmodels中得到纠正。只需更新到statsmodels 0.12.0即可解决此问题。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...