pmdarima autoarima 预测方法 returns ''SARIMAX' 对象没有属性 '_k_trend' '

pmdarima autoarima prediction method returns ''SARIMAX' object has no attribute '_k_trend' '

我使用 pmdarima 模块的管道方法创建了一个模型

fit2 = Pipeline([
('boxcox', BoxCoxEndogTransformer(lmbda2=1e-6)),
('arima', pmd.AutoARIMA(trace=True,
                       suppress_warnings=True,
                       m=12,
                       stepwise=True))])

并使用训练数据集拟合模型

fitted = fit2.fit(train)

并且能够进行预测。之后,尝试将模型保存为泡菜文件

pickle_tgt = "arima.pkl"
joblib.dump(fitted, pickle_tgt, compress=3)

然后我将 pickle 文件读回另一个 python 实例

def get_model(product_id):
  file_path = "collector/resources/" + product_id
  try:
      model = joblib.load(file_path)
      return model
  except Exception:
      print(traceback.format_exc())

但是,当我尝试使用我导入的模型进行预测时

fc, confint = model.predict(n_periods=24, return_conf_int=True)

失败并且returns下面的堆栈跟踪

    fc, confint = model.predict(n_periods=n_periods, return_conf_int=True)
  File "C:\Users\collector\venv\lib\site-packages\pmdarima\pipeline.py", line 436, in predict
    alpha=alpha, **predict_kwargs)
  File "C:\Users\collector\venv\lib\site-packages\pmdarima\utils\metaestimators.py", line 53, in <lambda>
    out = (lambda *args, **kwargs: self.fn(obj, *args, **kwargs))
  File "C:\Users\collector\venv\lib\site-packages\pmdarima\arima\auto.py", line 184, in predict
    return_conf_int=return_conf_int, alpha=alpha)
  File "C:\Users\collector\venv\lib\site-packages\pmdarima\arima\arima.py", line 651, in predict
    alpha=alpha)
  File "C:\Users\collector\venv\lib\site-packages\pmdarima\arima\arima.py", line 86, in _seasonal_prediction_with_confidence
    **kwargs)
  File "C:\Users\collector\venv\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py", line 3234, in get_prediction
    transformed=True, includes_fixed=True, **kwargs)
  File "C:\Users\collector\venv\lib\site-packages\statsmodels\tsa\statespace\sarimax.py", line 1732, in _get_extension_time_varying_matrices
    if not self.simple_differencing and self._k_trend > 0:
AttributeError: 'SARIMAX' object has no attribute '_k_trend'

pmdarima 版本是1.6.0,我试过在sarimax.py 文件里设置_k_trend = 0 变量,但似乎没有任何效果。有人对此有解决办法吗?

显然在 colab 和本地环境中安装 pmdarima 时存在版本兼容性问题,请查找更多信息here