解决Python statsmodels中ARMA模型报错NotImplementedError问题
解决Python statsmodels中ARMA模型报错NotImplementedError问题在使用Python中的statsmodels库进行时间序列分析时,你可能会遇到以下错误信息:pythonTraceback (most recent call last): File 'I:/math/2.py', line 84, in model = ARMA(pricing, order=(1, 1)) File 'C:/Users/TX/AppData/Local/Programs/Python/Python39/lib/site-packages/statsmodels/tsa/arima_model.py', line 29, in init raise NotImplementedError(ARIMA_DEPRECATION_ERROR)NotImplementedError: statsmodels.tsa.arima_model.ARMA and statsmodels.tsa.arima_model.ARIMA havebeen removed in favor of statsmodels.tsa.arima.model.ARIMA (note the .between arima and model) and statsmodels.tsa.SARIMAX.statsmodels.tsa.arima.model.ARIMA makes use of the statespace framework andis both well tested and maintained. It also offers alternative specializedparameter estimators.### 报错原因这个错误是由于 statsmodels 库中的 ARMA 和 ARIMA 模型已被弃用。官方推荐使用 statsmodels.tsa.arima.model.ARIMA (注意 arima 和 model 之间的 '.') 和 statsmodels.tsa.SARIMAX 模型来替代。### 解决方案要解决此错误,您需要将代码中对已弃用 ARMA 模型的调用替换为 ARIMA 或 SARIMAX 模型。以下是如何使用 ARIMA 模型替换 ARMA 模型的示例:pythonimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom statsmodels.tsa.arima.model import ARIMA # 修改导入方式# ...你的代码...# 将ARMA模型替换为ARIMA模型model = ARIMA(pricing, order=(1, 1, 0)) # 注意参数的变化model_fit = model.fit()# ...你的代码...注意:* ARIMA 模型的 order 参数是一个三元组 (p, d, q),分别代表模型的自回归 (AR)、差分 (I) 和移动平均 (MA) 的阶数。 * 如果你需要使用更复杂的季节性 ARIMA 模型,可以使用 SARIMAX 模型。通过以上修改,你就可以解决 statsmodels 库中 ARMA 模型报错 NotImplementedError 的问题,并继续进行时间序列分析。
statsmodels 库中的 ARMA 和 ARIMA 模型已被弃用。官方推荐使用 statsmodels.tsa.arima.model.ARIMA (注意 arima 和 model 之间的 '.') 和 statsmodels.tsa.SARIMAX 模型来替代。### 解决方案要解决此错误,您需要将代码中对已弃用 ARMA 模型的调用替换为 ARIMA 或 SARIMAX 模型。以下是如何使用 ARIMA 模型替换 ARMA 模型的示例:pythonimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltfrom statsmodels.tsa.arima.model import ARIMA # 修改导入方式# ...你的代码...# 将ARMA模型替换为ARIMA模型model = ARIMA(pricing, order=(1, 1, 0)) # 注意参数的变化model_fit = model.fit()# ...你的代码...注意:* ARIMA 模型的 order 参数是一个三元组 (p, d, q),分别代表模型的自回归 (AR)、差分 (I) 和移动平均 (MA) 的阶数。 * 如果你需要使用更复杂的季节性 ARIMA 模型,可以使用 SARIMAX 模型。通过以上修改,你就可以解决 statsmodels 库中 ARMA 模型报错 NotImplementedError 的问题,并继续进行时间序列分析。
原文地址: https://www.cveoy.top/t/topic/en2B 著作权归作者所有。请勿转载和采集!