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

2024-09-19 20:59:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用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'

但是当我检查statsmodelExponentialSmoothing的参数时,initialization_method就是其中之一,所以我不知道那里发生了什么

向前看,我从代码中的ExponentialSmoothing参数中删除了initialization_method,然后在下面的一行中得到另一个错误

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

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

我升级了statsmodels,升级了pip,但仍然得到相同的错误

那里发生了什么事

提前感谢您的帮助


Tags: 代码dataframeplotstyle错误axmethodfit