【问题标题】:Python ARIMA predictions returning NaNsPython ARIMA 预测返回 NaN
【发布时间】:2020-04-07 03:24:49
【问题描述】:

我正在尝试使用 ARIMA 进行简单的预测。下面的代码生成所有 NaN 作为 (1,1,3) 顺序参数的输出,但是对于 (1,1,2) 和 (1,1,4) 的顺序参数,我能够得到正确的(数字) 输出。同样的功能可以正常工作,在其他一些旧/新版本的 pandas、statsmodels 和 pmdarima 的安装中。我在 Stackoverflow 中检查了相关问题,但由于具有相同参数的相同函数在其他库中工作,我认为 (1,1,3) 的 order 参数没有任何问题,并且错误可能与库版本或其他一些配置。任何帮助表示赞赏。

from statsmodels.tsa.arima_model import ARIMA
    def testarima():
        trainseries = pd.Series([600.00,10.00,405.00,900.00,500.00,500.00,500.00,500.00,500.00,
                                 500.00,1000.00,533.00,2784.11,1775.00,300.00,4289.42,1270.00,
                                 500.00,2145.00,1650.00,1750.00,785.00,4137.50,2450.00,2194.00,
                                 1750.00,1000.00,2250.00,1000.00,1055.98,1000.00,250.00,450.00,
                                 540.00,2247.50,200.00,820.00,570.00,555.00])
        model = ARIMA(trainseries, order=(1, 1, 3))
        # print("train: " + str(train))
        try:
            model_fit = model.fit(disp=0)            
            fc, se, conf = model_fit.forecast(24, alpha=0.05)
            print('result: '+str(fc))
            return fc
        except:
            return np.zeros(24)

statsmodels v 0.10.2 pmdarima v 1.5.1 熊猫 0.25.3 蟒蛇3.7.5

有警告输出

C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\statsmodels\tsa\kalmanf\kalmanfilter.py:225: RuntimeWarning: 在日志中遇到无效值 Z_mat.astype(complex), R_mat, T_mat)

C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\statsmodels\tsa\kalmanf\kalmanfilter.py:225: RuntimeWarning: 在 true_divide 中遇到无效值 Z_mat.astype(complex), R_mat, T_mat)

C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\statsmodels\base\model.py:492: HessianInversionWarning: Inverting hessian failed, no bse or cov_params available '可用',HessianInversionWarning)

但在其他安装中也出现了这些警告,但我得到了正确的数字输出

【问题讨论】:

    标签: python statsmodels arima


    【解决方案1】:

    使用熊猫版本 0.22.0.0 它没有解决然后避免 statsmodel 只是导入 ARIMA,如果你在 colab 中使用 tensorflow 它不支持 tensorflow 2 版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 2016-02-13
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 2019-12-31
      • 2021-03-01
      相关资源
      最近更新 更多