Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional library support for SARIMAX models from darts package? #2338

Open
akshobhya95 opened this issue Apr 17, 2024 · 5 comments
Open

Additional library support for SARIMAX models from darts package? #2338

akshobhya95 opened this issue Apr 17, 2024 · 5 comments
Labels
question Further information is requested

Comments

@akshobhya95
Copy link

Hi ,
I was looking into this github and I see that I am also facing similar issue over darts package to support for SARIMA and SARIMAX models to use it #854 ?

I tried installing u8darts[all] from the requirements.txt but I don't find these models to be specific. Kindly showcase the path if it already exists? else is there a similar workaround to use specific to SARIMAX models. I don't need to use ARIMA for my case.

-Kind Regards ,
Akshobhya.

@akshobhya95 akshobhya95 added the triage Issue waiting for triaging label Apr 17, 2024
@madtoinou madtoinou added question Further information is requested and removed triage Issue waiting for triaging labels Apr 18, 2024
@madtoinou
Copy link
Collaborator

Hi @akshobhya95,

The closing message from the linked issue is saying that the Darts ARIMA model is a wrapper around statsmodel ARIMA, which according to their own documentation, is an interface to the ARIMA-based models (including SARIMA) : here. However, Darts also adds exogenous variables support (covariates), hence making it equivalent to the SARIMAX model. The only difference is that some of SARIMAX' arguments such as time_varying_regression, mle_regression, simple_differencing or hamilton_representation are not accessible.

Does it answer your question?

@akshobhya95
Copy link
Author

Hi @madtoinou ,
I tried with the above suggestion as mentioned over the github link, but especially with ARIMA model test I am hitting this LU decomposition error in the middle of generating forecasts specifically hitting with ARIMA models for my dataset whereas for the rest of the models it is working fine.

Generating forecasts...
C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\base\model.py:607: ConvergenceWarning: Maximum Likelihood optimization failed to converge. Check mle_retvals
warnings.warn("Maximum Likelihood optimization failed to "
19%|█████████████████████████▏ | 243/1266 [04:13<17:48, 1.04s/it]
Traceback (most recent call last):
File "C:\Users\aksho\anaconda3\conformal-time-series\tests\base_test.py", line 86, in
data['forecasts'] = generate_forecasts(data, **args['sequences'][0])
File "C:\Users\aksho\anaconda3\conformal-time-series\tests..\core\model_scores.py", line 90, in generate_forecasts
model_forecasts = model.historical_forecasts(y,future_covariates=exog,forecast_horizon=fit_every, retrain=retrain, verbose=True).values()[:,0].squeeze()
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\darts\utils\utils.py", line 143, in sanitized_method
return method_to_sanitize(self, *only_args.values(), **only_kwargs)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\darts\models\forecasting\forecasting_model.py", line 1051, in historical_forecasts
model._fit_wrapper(
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\darts\models\forecasting\forecasting_model.py", line 386, in _fit_wrapper
self.fit(series=series, **add_kwargs, **kwargs)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\darts\models\forecasting\forecasting_model.py", line 2788, in fit
return self._fit(series, future_covariates=future_covariates)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\darts\models\forecasting\arima.py", line 167, in _fit
self.model = m.fit()
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\tsa\arima\model.py", line 395, in fit
res = super().fit(
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py", line 703, in fit
mlefit = super().fit(start_params, method=method,
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\base\model.py", line 566, in fit
xopt, retvals, optim_settings = optimizer._fit(f, score, start_params,
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\base\optimizer.py", line 243, in _fit
xopt, retvals = func(objective, gradient, start_params, fargs, kwargs,
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\base\optimizer.py", line 660, in _fit_lbfgs
retvals = optimize.fmin_l_bfgs_b(func, start_params, maxiter=maxiter,
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\scipy\optimize_lbfgsb_py.py", line 237, in fmin_l_bfgs_b
res = _minimize_lbfgsb(fun, x0, args=args, jac=jac, bounds=bounds,
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\scipy\optimize_lbfgsb_py.py", line 407, in _minimize_lbfgsb
f, g = func_and_grad(x)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\scipy\optimize_differentiable_functions.py", line 296, in fun_and_grad
self._update_fun()
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\scipy\optimize_differentiable_functions.py", line 262, in _update_fun
self._update_fun_impl()
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\scipy\optimize_differentiable_functions.py", line 163, in update_fun
self.f = fun_wrapped(self.x)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\scipy\optimize_differentiable_functions.py", line 145, in fun_wrapped
fx = fun(np.copy(x), *args)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\base\model.py", line 534, in f
return -self.loglike(params, *args) / nobs
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\tsa\statespace\mlemodel.py", line 938, in loglike
loglike = self.ssm.loglike(complex_step=complex_step, **kwargs)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\tsa\statespace\kalman_filter.py", line 1001, in loglike
kfilter = self._filter(**kwargs)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\tsa\statespace\kalman_filter.py", line 921, in _filter
self._initialize_state(prefix=prefix, complex_step=complex_step)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\statsmodels\tsa\statespace\representation.py", line 1058, in _initialize_state
self._statespaces[prefix].initialize(self.initialization,
File "statsmodels\tsa\statespace\_representation.pyx", line 1373, in statsmodels.tsa.statespace._representation.dStatespace.initialize
File "statsmodels\tsa\statespace\_representation.pyx", line 1362, in statsmodels.tsa.statespace._representation.dStatespace.initialize
File "statsmodels\tsa\statespace\_initialization.pyx", line 288, in statsmodels.tsa.statespace._initialization.dInitialization.initialize
File "statsmodels\tsa\statespace\_initialization.pyx", line 406, in statsmodels.tsa.statespace._initialization.dInitialization.initialize_stationary_stationary_cov
File "statsmodels\tsa\statespace\_tools.pyx", line 1548, in statsmodels.tsa.statespace._tools._dsolve_discrete_lyapunov
numpy.linalg.LinAlgError: LU decomposition error.

But I get your point with the above explanation makes sense to me it answers my question. Thanks for your response.

-Kind Regards ,
Akshobhya.

@akshobhya95
Copy link
Author

Hi @madtoinou ,
My bad I accidentally submitted my update with closing comments, Still I had one more query about the DARTS package used in ARIMA, as you said DARTS in ARIMA supports only fewer hyper tuning parameters for my case I was hitting this LU decomposition error as I have highlighted in above update, In one of the workarounds I need to hyper tune it by setting and check enforce_stationarity= False ARIMA
But unfortunately I don't see this hyperparameter being used in DARTS ? is my understanding right that DARTS in ARIMA only supports fewer hypertuning parameters ? else How do we set this explicitly using DARTS?

Generating forecasts...
Traceback (most recent call last):
File "C:\Users\aksho\anaconda3\conformal-time-series\tests\base_test.py", line 86, in
data['forecasts'] = generate_forecasts(data, **args['sequences'][0])
File "C:\Users\aksho\anaconda3\conformal-time-series\tests..\core\model_scores.py", line 71, in generate_forecasts
model = ARIMA(p=3,d=0,q=0,seasonal_order=(1,1,1,7),enforce_stationarity=False)
File "C:\Users\aksho\anaconda3\envs\qls\lib\site-packages\darts\models\forecasting\forecasting_model.py", line 114, in call
return super().call(**all_params)
TypeError: ARIMA.init() got an unexpected keyword argument 'enforce_stationarity'

I see that the enforce_stationarity argument is also involved in the case so kindly confirm on this check.

@madtoinou
Copy link
Collaborator

Hi @akshobhya95, Darts is indeed no giving access to these arguments and I added it to the roadmap.

In the meantime, you could try to make your series stationarity so that you don't have to change the enforce_stationarity argument.

@akshobhya95
Copy link
Author

Sure Thanks for your Confirmation on this @madtoinou.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants