我正在使用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, style='--', marker='o', color='green', legend=True)
然而,当我运行它时,我得到了错误
TypeError: __init__() got an unexpected keyword argument 'initialization_method'
但是当我检查statsmodel
中ExponentialSmoothing
的参数时,initialization_method
就是其中之一,所以我不知道那里发生了什么
向前看,我从代码中的ExponentialSmoothing
参数中删除了initialization_method
,然后在下面的一行中得到另一个错误
AttributeError: 'ExponentialSmoothing' object has no attribute 'simulate'
我再次检查simulate
是否在最新版本的statsmodels
中被弃用,否,它仍然是一个属性
我升级了statsmodels
,升级了pip
,但仍然得到相同的错误
那里发生了什么事
提前感谢您的帮助
事实上,以前的版本中有一个bug,在新版本的statsmodels中得到了纠正。只需更新到statsmodels 0.12.0,此问题就解决了
相关问题 更多 >
编程相关推荐