facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.55k stars 4.54k forks source link

RuntimeError: Error during optimization! #2573

Open Tuyen92 opened 7 months ago

Tuyen92 commented 7 months ago

I'm encountering an issue with the usage of prophet.fit(), and I'm uncertain about how to resolve it. I'm using Python version 3.10.8, with Prophet version 1.1.5. Additionally, I have created a DataFrame named 'train' with two columns, 'ds' and 'y', to pass into the fit() function.

This is error return to me

Traceback (most recent call last):
  File "d:\dev.team.schedule.report\venv310devteam\lib\site-packages\prophet\models.py", line 121, in fit
    self.stan_fit = self.model.optimize(**args)
  File "d:\dev.team.schedule.report\venv310devteam\lib\site-packages\cmdstanpy\model.py", line 659, in optimize
    raise RuntimeError(msg)
RuntimeError: Error during optimization! Command 'D:\dev.team.schedule.report\venv310devteam\Lib\site-packages\prophet\stan_model\prophet_model.bin random seed=90356 data file=C:\Users\TUYEN~1.NGU\AppData\Local\Temp\tmpd5_o053z\ie1zkgh3.json init=C:\Users\TUYEN~1.NGU\AppData\Local\Temp\tmpd5_o053z\ass3difi.json output file=C:\Users\TUYEN~1.NGU\AppData\Local\Temp\tmpd5_o053z\prophet_modelw6ec5z94\prophet_model-20240424120047.csv method=optimize algorithm=lbfgs iter=10000' failed:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\dev.team.schedule.report\odooreport\fastapi_app\fast_api.py", line 359, in insert_forecast_one_project
    return insert_forecast_one_project_impl(target_db, is_considered_holidays)
  File "D:\dev.team.schedule.report\odooreport\fastapi_app\fast_api.py", line 236, in insert_forecast_one_project_impl
    forecasts = create_forecast_one_project_considering_seasonality(target_db=target_db)
  File "D:\dev.team.schedule.report\odooreport\odooreportapp\refactored_forecast.py", line 262, in create_forecast_one_project_considering_seasonality
    forecast_add_project_id = calculate_forecast_one_project_considering_seasonality(target_db)
  File "D:\dev.team.schedule.report\odooreport\odooreportapp\refactored_forecast.py", line 252, in calculate_forecast_one_project_considering_seasonality
    forecast = apply_considering_holiday_prophet_one_project(renamed_detail_cumulative_invoice_df, df_project_target, project, detail_invoice_df)
  File "D:\dev.team.schedule.report\odooreport\odooreportapp\refactored_forecast.py", line 134, in apply_considering_holiday_prophet_one_project
    prophet.fit(train)
  File "d:\dev.team.schedule.report\venv310devteam\lib\site-packages\prophet\forecaster.py", line 1232, in fit
    self.params = self.stan_backend.fit(stan_init, dat, **kwargs)
  File "d:\dev.team.schedule.report\venv310devteam\lib\site-packages\prophet\models.py", line 129, in fit
    self.stan_fit = self.model.optimize(**args)
  File "d:\dev.team.schedule.report\venv310devteam\lib\site-packages\cmdstanpy\model.py", line 659, in optimize
    raise RuntimeError(msg)
RuntimeError: Error during optimization! Command 'D:\dev.team.schedule.report\venv310devteam\Lib\site-packages\prophet\stan_model\prophet_model.bin random seed=59458 data file=C:\Users\TUYEN~1.NGU\AppData\Local\Temp\tmpd5_o053z\jygnbt31.json init=C:\Users\TUYEN~1.NGU\AppData\Local\Temp\tmpd5_o053z\s8jj1qt3.json output file=C:\Users\TUYEN~1.NGU\AppData\Local\Temp\tmpd5_o053z\prophet_model7mcrcczm\prophet_model-20240424120047.csv method=optimize algorithm=newton iter=10000' failed:
RikiSot commented 7 months ago

I'm also getting the same error. It seems there is a problem with cmdstanpy package

cmdstanpy - ERROR - Chain [1] error: terminated by signal 3221225657

I'm using Prophet 1.1.5 and Python 3.12.

EDIT: There are more issues opened for this like #2456 , some people think this is related to the OS. I'm on Windows btw

Tuyen92 commented 6 months ago

I'm on Window 11. I attempted to downgrade Prophet from version 1.1.5 to 1.1.1, and installed holidays==0.18.0. But it didn't work, the same error persists. I'm also using cmdstanpy==1.2.2

Parvez-Khan-1 commented 4 months ago

@Tuyen92 I am on Linux and this issue is fixed for me with below setup:

Python: 3.10.10 Prophet: 1.1.5

Pathi-rao commented 1 month ago

@Tuyen92 I am on Linux and this issue is fixed for me with below setup:

Python: 3.10.10 Prophet: 1.1.5

Hi, When I tried your solution, I was faced with a different error AttributeError:np.float_was removed in the NumPy 2.0 release. Usenp.float64instead. which is solved in this PR. Looks like a chicken egg problem to me

rajaditya-ai-developer commented 1 month ago

RuntimeError: Error during optimization! Command '/usr/local/lib/python3.11/site-packages/prophet/stan_model/prophet_model.bin random seed=49923 data file=/tmp/tmpeon52vld/ai_chsha.json init=/tmp/tmpeon52vld/8rgg4bmv.json output file=/tmp/tmpeon52vld/prophet_model99i3l0_s/prophet_model-20241014192626.csv method=optimize algorithm=newton iter=10000' failed: while hosting I am getting this error