Python statsmodels.tsa.arima_model.ARMA 模块已被弃用,如何解决?
在使用 Python 中的 statsmodels 库进行时间序列分析时,可能会遇到以下错误:
'Traceback (most recent call last):
File 'I:\math\2.py', line 84, in
statsmodels.tsa.arima.model.ARIMA makes use of the statespace framework and is both well tested and maintained. It also offers alternative specialized parameter estimators.'
该错误表示您使用了已被弃用的 statsmodels.tsa.arima_model.ARMA 模块。该模块已被移除,建议您使用 statsmodels.tsa.arima.model.ARIMA 模块或 statsmodels.tsa.SARIMAX 模块来替代。
statsmodels.tsa.arima.model.ARIMA 模块利用了状态空间框架,经过了充分的测试和维护,并提供了其他专门的参数估计器。
解决方案:
- 将代码中所有 statsmodels.tsa.arima_model.ARMA 模块的引用替换为 statsmodels.tsa.arima.model.ARIMA 模块或 statsmodels.tsa.SARIMAX 模块。
- 确保您已安装最新版本的 statsmodels 库。可以使用 pip install --upgrade statsmodels 命令升级库。
例如,将以下代码:
model = ARMA(pricing, order=(1, 1))
修改为:
model = ARIMA(pricing, order=(1, 1, 0))
或者使用 SARIMAX 模块:
model = SARIMAX(pricing, order=(1, 1, 0), seasonal_order=(0, 0, 0, 0))
通过以上步骤,您就可以解决 statsmodels.tsa.arima_model.ARMA 模块被弃用的问题,并继续使用 statsmodels 库进行时间序列分析。
原文地址: https://www.cveoy.top/t/topic/en0P 著作权归作者所有。请勿转载和采集!