-
Notifications
You must be signed in to change notification settings - Fork 283
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
[Model forecast] Exception: No regressors provided #435
Comments
It seems the error was caused by the extra column that was present (other than ds, and y), |
Hi, I actually have the same issue when adding exogenous data. Thank you |
Hey @NasreddineD! Thank you for using statsforecast and letting us know about the issue. Could you share a reproducible example to dig into the problem? |
Hi @FedericoGarza, please find below the code:
Please note: There is no error with only "ds", "y" and "unique_id" |
hey @NasreddineD! Thank you. If you include exogenous variables in your data, once you call Please let us know if something else needs to be clarified. :) |
For posterity, this is the fixed link which is broken in FG's post above https://nixtla.github.io/statsforecast/docs/how-to-guides/exogenous.html |
What happened + What you expected to happen
RemoteTraceback Traceback (most recent call last)
RemoteTraceback:
"""
Traceback (most recent call last):
File "/anaconda/envs/jupyter_env/lib/python3.8/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py", line 199, in forecast
raise error
File "/anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py", line 185, in forecast
res_i = model.forecast(
File "/anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/models.py", line 345, in forecast
fcst = forecast_arima(mod, h, xreg=X_future, level=level)
File "/anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/arima.py", line 1485, in forecast_arima
raise Exception("No regressors provided")
Exception: No regressors provided
"""
The above exception was the direct cause of the following exception:
Exception Traceback (most recent call last)
Cell In[92], line 1
----> 1 forecasts_df = sf.forecast(h=14 , level=[90])
3 forecasts_df.head()
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py:680, in _StatsForecast.forecast(self, h, df, X_df, level, fitted, sort_df)
670 res_fcsts = self.ga.forecast(
671 models=self.models,
672 h=h,
(...)
677 verbose=self.verbose,
678 )
679 else:
--> 680 res_fcsts = self.forecast_parallel(h=h, fitted=fitted, X=X, level=level)
681 if fitted:
682 self.fcst_fitted_values = res_fcsts["fitted"]
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py:939, in _StatsForecast._forecast_parallel(self, h, fitted, X, level)
927 future = executor.apply_async(
928 ga.forecast,
929 (
(...)
936 ),
937 )
938 futures.append(future)
--> 939 out = [f.get() for f in futures]
940 fcsts = [d["forecasts"] for d in out]
941 fcsts = np.vstack(fcsts)
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py:939, in (.0)
927 future = executor.apply_async(
928 ga.forecast,
929 (
(...)
936 ),
937 )
938 futures.append(future)
--> 939 out = [f.get() for f in futures]
940 fcsts = [d["forecasts"] for d in out]
941 fcsts = np.vstack(fcsts)
File /anaconda/envs/jupyter_env/lib/python3.8/multiprocessing/pool.py:771, in ApplyResult.get(self, timeout)
769 return self._value
770 else:
--> 771 raise self._value
File /anaconda/envs/jupyter_env/lib/python3.8/multiprocessing/pool.py:125, in worker()
123 job, i, func, args, kwds = task
124 try:
--> 125 result = (True, func(*args, **kwds))
126 except Exception as e:
127 if wrap_exception and func is not _helper_reraises_exception:
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py:199, in forecast()
190 res_i = fallback_model.forecast(
191 h=h,
192 y=y_train,
(...)
196 **kwargs,
197 )
198 else:
--> 199 raise error
200 cols_m = [
201 key
202 for key in res_i.keys()
203 if any(key.startswith(m) for m in matches)
204 ]
205 fcsts_i = np.vstack([res_i[key] for key in cols_m]).T
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/core.py:185, in forecast()
183 kwargs["level"] = level
184 try:
--> 185 res_i = model.forecast(
186 h=h, y=y_train, X=X_train, X_future=X_f, fitted=fitted, **kwargs
187 )
188 except Exception as error:
189 if fallback_model is not None:
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/models.py:345, in forecast()
307 with np.errstate(invalid="ignore"):
308 mod = auto_arima_f(
309 x=y,
310 d=self.d,
(...)
343 period=self.season_length,
344 )
--> 345 fcst = forecast_arima(mod, h, xreg=X_future, level=level)
346 res = {"mean": fcst["mean"]}
347 if fitted:
File /anaconda/envs/jupyter_env/lib/python3.8/site-packages/statsforecast/arima.py:1485, in forecast_arima()
1483 elif usexreg:
1484 if xreg is None:
-> 1485 raise Exception("No regressors provided")
1486 # ncxreg = len([ncoef for ncoef in model['coef'].keys() if 'ex_' in ncoef])
1487 # if xreg.shape[1] != ncxreg:
1488 # raise Exception('Number of regressors does not match fitted model"')
1489 pred, se = predict_arima(model, n_ahead=h, newxreg=xreg)
Exception: No regressors provided
Versions / Dependencies
1.4.0
AzureML Environment
Reproduction script
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA, AutoETS, Naive
season_length = 52 # Weekly data 12 # Monthly data
horizon = 14 # Predict the lenght of the test df
Include the models you imported
models = [
AutoARIMA(season_length=season_length),
AutoETS(season_length=season_length),
Naive()
]
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA, AutoETS, Naive
season_length = 52 # Weekly data 12 # Monthly data
horizon = 14 # Predict the lenght of the test df
Include the models you imported
models = [
AutoARIMA(season_length=season_length),
AutoETS(season_length=season_length),
Naive()
]
Instansiate the StatsForecast class as sf
sf = StatsForecast(
df=y_train_short,
models=models,
freq='W',
n_jobs=-1
)
forecasts_df = sf.forecast(h=14 , level=[90])
forecasts_df.head()
Issue Severity
High: It blocks me from completing my task.
The text was updated successfully, but these errors were encountered: