I have created a model using the pmdarima module's pipeline method
fit2 = Pipeline([
('boxcox', BoxCoxEndogTransformer(lmbda2=1e-6)),
('arima', pmd.AutoARIMA(trace=True,
suppress_warnings=True,
m=12,
stepwise=True))])
and fitted the model using the train data set
fitted = fit2.fit(train)
And were able to perform predictions. Afterwards, tried to persists the model as a pickle file
pickle_tgt = "arima.pkl"
joblib.dump(fitted, pickle_tgt, compress=3)
then I read the pickle file back into another python instance
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())
However, when I tried to perform prediction using the model I'v imported
fc, confint = model.predict(n_periods=24, return_conf_int=True)
it fails and returns the below stacktrace
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'
The pmdarima version is 1.6.0, I'v tried setting _k_trend = 0 variable in the sarimax.py file but it does not seems to have any effect. Anyone has a work around to this ?
Apparently there was an version compatibility issue while installing pmdarima in colab and local env, find more information here