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.27k stars 4.51k forks source link

Error during optimization since upgrade from 1.1.1 -> 1.1.2 #2356

Open Roymprog opened 1 year ago

Roymprog commented 1 year ago

Version: 1.1.2 Minimum reproducible example:

from datetime import datetime
from prophet import Prophet

df = pd.DataFrame([
    {"unique_id": 1, "ds": datetime(2022, 12, 1), "y":5.0},
    {"unique_id": 1, "ds": datetime(2022, 11, 1), "y":2.0},
])

def_model = Prophet(
    yearly_seasonality=False,
    weekly_seasonality=False,
    daily_seasonality=False,
    interval_width=0.95,
    seasonality_mode="multiplicative",
    changepoint_prior_scale=0.05,
    growth="linear",
)
def_model.add_seasonality(name="Yearly", period=365.25, fourier_order=2)

# Fit the model to the training data
def_model.fit(df)

Output:

INFO:prophet:n_changepoints greater than number of observations. Using 0.
DEBUG:cmdstanpy:input tempfile: /tmp/tmp6m8x14sl/o5ptazg8.json
DEBUG:cmdstanpy:input tempfile: /tmp/tmp6m8x14sl/qfg653ho.json
DEBUG:cmdstanpy:idx 0
DEBUG:cmdstanpy:running CmdStan, num_threads: None
DEBUG:cmdstanpy:CmdStan args: ['/home/username/.cache/pypoetry/virtualenvs/forecast--1ch3c7_-py3.9/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin', 'random', 'seed=32555', 'data', 'file=/tmp/tmp6m8x14sl/o5ptazg8.json', 'init=/tmp/tmp6m8x14sl/qfg653ho.json', 'output', 'file=/tmp/tmp6m8x14sl/prophet_modely3i8ygfr/prophet_model-20230126120845.csv', 'method=optimize', 'algorithm=newton', 'iter=10000']
12:08:45 - cmdstanpy - INFO - Chain [1] start processing
INFO:cmdstanpy:Chain [1] start processing
12:08:45 - cmdstanpy - INFO - Chain [1] done processing
INFO:cmdstanpy:Chain [1] done processing
12:08:45 - cmdstanpy - ERROR - Chain [1] error: terminated by signal 11 Unknown error -11
ERROR:cmdstanpy:Chain [1] error: terminated by signal 11 Unknown error -11
Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?161372e0-cd3f-435b-be92-e5778487d6a7)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[16], line 23
     20 def_model.add_seasonality(name="Yearly", period=365.25, fourier_order=2)
     22 # Fit the model to the training data
---> 23 def_model.fit(df)
     25 # start_time = time.time()
     26 # forecast_prophet = pd.concat(
     27 #         dd.compute(*[dask.delayed(make_prophet)(entity, train_df) for entity in train_df.entity.unique()])
   (...)
     30 # elapsed_time = end_time - start_time
     31 # print(f"Elapsed time: {elapsed_time:.2f} seconds")

File ~/.cache/pypoetry/virtualenvs/forecast--1ch3c7_-py3.9/lib/python3.9/site-packages/prophet/forecaster.py:1181, in Prophet.fit(self, df, **kwargs)
   1179     self.params = self.stan_backend.sampling(stan_init, dat, self.mcmc_samples, **kwargs)
   1180 else:
-> 1181     self.params = self.stan_backend.fit(stan_init, dat, **kwargs)
   1183 self.stan_fit = self.stan_backend.stan_fit
   1184 # If no changepoints were requested, replace delta with 0s

File ~/.cache/pypoetry/virtualenvs/forecast--1ch3c7_-py3.9/lib/python3.9/site-packages/prophet/models.py:100, in CmdStanPyBackend.fit(self, stan_init, stan_data, **kwargs)
     97 except RuntimeError as e:
     98     # Fall back on Newton
     99     if not self.newton_fallback or args['algorithm'] == 'Newton':
--> 100         raise e
...
--> 738         raise RuntimeError(msg)
    739 mle = CmdStanMLE(runset)
    740 return mle

RuntimeError: Error during optimization! Command '/home/username/.cache/pypoetry/virtualenvs/forecast--1ch3c7_-py3.9/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin random seed=32555 data file=/tmp/tmp6m8x14sl/o5ptazg8.json init=/tmp/tmp6m8x14sl/qfg653ho.json output file=/tmp/tmp6m8x14sl/prophet_modely3i8ygfr/prophet_model-20230126120845.csv method=optimize algorithm=newton iter=10000' failed:

When I run the command from the log I get a Segmentation fault like this:

/home/username/.cache/pypoetry/virtualenvs/forecast--1ch3c7_-py3.9/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin random seed=61655 data file=/tmp/tmp6m8x14sl/t6aoslvh.json init=/tmp/tmp6m8x14sl/qmjcj183.json output file=/tmp/tmp6m8x14sl/prophet_model_x1hgw42/prophet_model-20230126120014.csv method=optimize algorithm=newton iter=10000

This makes me think prophet_model.bin is somehow corrupted.

hemajv commented 1 year ago

@Roymprog I get the same error too. See #2354

daniellevinson commented 1 year ago

Getting the same error, left a comment in #2354

AzamBukhari commented 1 year ago

IDE: Visual Studio Code OS: Windows : 11 Environement: miniconda: Python Version: 3.10.11 Prophet version 1.1.4 cmdstanpy version: 1.1.0


RuntimeError Traceback (most recent call last) File c:\Users\azamb\miniconda3\envs\tf_env\lib\site-packages\prophet\models.py:90, in CmdStanPyBackend.fit(self, stan_init, stan_data, kwargs) 89 try: ---> 90 self.stan_fit = self.model.optimize(args) 91 except RuntimeError as e: 92 # Fall back on Newton

File c:\Users\azamb\miniconda3\envs\tf_env\lib\site-packages\cmdstanpy\model.py:738, in CmdStanModel.optimize(self, data, seed, inits, output_dir, sig_figs, save_profile, algorithm, init_alpha, tol_obj, tol_rel_obj, tol_grad, tol_rel_grad, tol_param, history_size, iter, save_iterations, require_converged, show_console, refresh, time_fmt, timeout) 737 else: --> 738 raise RuntimeError(msg) 739 mle = CmdStanMLE(runset)

RuntimeError: Error during optimization! Command 'C:\Users\azamb\miniconda3\envs\tf_env\Lib\site-packages\prophet\stan_model\prophet_model.bin random seed=88646 data file=C:\Users\azamb\AppData\Local\Temp\tmpawxd4uzm\t1k02ldr.json init=C:\Users\azamb\AppData\Local\Temp\tmpawxd4uzm\4dz8js4j.json output file=C:\Users\azamb\AppData\Local\Temp\tmpawxd4uzm\prophet_model02tsxu8f\prophet_model-20230621160805.csv method=optimize algorithm=lbfgs iter=10000' failed:

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last) Cell In[8], line 4 1 #Initialize the model and fit the data 2 #call the model 3 m = Prophet(daily_seasonality=True) ----> 4 m.fit(df)

File c:\Users\azamb\miniconda3\envs\tf_env\lib\site-packages\prophet\forecaster.py:1181, in Prophet.fit(self, df, **kwargs) ... --> 738 raise RuntimeError(msg) 739 mle = CmdStanMLE(runset) 740 return mle

RuntimeError: Error during optimization! Command 'C:\Users\azamb\miniconda3\envs\tf_env\Lib\site-packages\prophet\stan_model\prophet_model.bin random seed=59954 data file=C:\Users\azamb\AppData\Local\Temp\tmpawxd4uzm\1y2fhr5x.json init=C:\Users\azamb\AppData\Local\Temp\tmpawxd4uzm\s986b71d.json output file=C:\Users\azamb\AppData\Local\Temp\tmpawxd4uzm\prophet_model9m239t2w\prophet_model-20230621160805.csv method=optimize algorithm=newton iter=10000' failed: Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...