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.42k stars 4.53k forks source link

RuntimeError: Something went wrong after call_sampler. #192

Closed adacumos closed 7 years ago

adacumos commented 7 years ago

I'm fitting my data about 50 csv files but Prophet crashes and throwing runtime errors. This only happened when I switched to Ubuntu 16. On Windows, prophet runs without error.

`Optimization terminated with error:

Line search failed to achieve a sufficient decrease, no more progress can be made Traceback (most recent call last): File "get_predictions.py", line 283, in m.fit(df) File "/home/arvin/anaconda3/envs/devenv/lib/python3.5/site-packages/fbprophet-0.1.1-py3.5.egg/fbprophet/forecaster.py", line 536, in fit params = model.optimizing(dat, init=stan_init, iter=1e4, **kwargs) File "/home/user/anaconda3/envs/devenv/lib/python3.5/site-packages/pystan/model.py", line 510, in optimizing ret, sample = fit._call_sampler(stan_args) File "stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8714900159976324877.pyx", line 814, in stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8714900159976324877.StanFit4Model._call_sampler (/tmp/tmp6in6jxib/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8714900159976324877.cpp:16904) File "stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8714900159976324877.pyx", line 401, in stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8714900159976324877._call_sampler (/tmp/tmp6in6jxib/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8714900159976324877.cpp:8973) RuntimeError: Something went wrong after call_sampler. ` TIA

adacumos commented 7 years ago

This is my data daily close of a stock price.

ds,y 04/01/2016,0.072 04/04/2016,0.069 04/05/2016,0.061 04/06/2016,0.063 04/07/2016,0.062 04/08/2016,0.062 04/11/2016,0.061 04/12/2016,0.065 04/13/2016,0.064 04/14/2016,0.065 04/15/2016,0.064 04/18/2016,0.062 04/19/2016,0.062 04/20/2016,0.062 04/21/2016,0.059 04/22/2016,0.058 04/25/2016,0.057 04/26/2016,0.057 04/27/2016,0.054 04/28/2016,0.054 04/29/2016,0.058 05/02/2016,0.055 05/03/2016,0.055 05/04/2016,0.055 05/05/2016,0.055 05/06/2016,0.055 05/10/2016,0.054 05/11/2016,0.057 05/12/2016,0.058 05/13/2016,0.058 05/16/2016,0.059 05/17/2016,0.059 05/18/2016,0.058 05/19/2016,0.058 05/20/2016,0.055 05/23/2016,0.054 05/24/2016,0.054 05/25/2016,0.052 05/26/2016,0.052 05/27/2016,0.053 05/30/2016,0.053 05/31/2016,0.058 06/01/2016,0.058 06/02/2016,0.058 06/03/2016,0.058 06/06/2016,0.059 06/07/2016,0.061 06/08/2016,0.061 06/09/2016,0.059 06/10/2016,0.058 06/13/2016,0.057 06/14/2016,0.056 06/15/2016,0.058 06/16/2016,0.059 06/17/2016,0.058 06/20/2016,0.059 06/21/2016,0.061 06/22/2016,0.062 06/23/2016,0.062 06/24/2016,0.059 06/27/2016,0.059 06/28/2016,0.059 06/29/2016,0.059 06/30/2016,0.058 07/01/2016,0.058 07/04/2016,0.059 07/05/2016,0.058 07/07/2016,0.058 07/08/2016,0.058 07/11/2016,0.06 07/12/2016,0.06 07/13/2016,0.059 07/14/2016,0.088 07/15/2016,0.099 07/18/2016,0.094 07/19/2016,0.102 07/20/2016,0.107 07/21/2016,0.097 07/22/2016,0.099 07/25/2016,0.099 07/26/2016,0.099 07/27/2016,0.1 07/28/2016,0.118 07/29/2016,0.114 08/01/2016,0.109 08/02/2016,0.108 08/03/2016,0.105 08/04/2016,0.103 08/05/2016,0.103 08/08/2016,0.103 08/09/2016,0.101 08/10/2016,0.103 08/11/2016,0.095 08/12/2016,0.093 08/15/2016,0.095 08/16/2016,0.099 08/17/2016,0.097 08/18/2016,0.095 08/19/2016,0.095 08/22/2016,0.094 08/23/2016,0.097 08/24/2016,0.093 08/25/2016,0.093 08/26/2016,0.1 08/30/2016,0.098 08/31/2016,0.095 09/01/2016,0.093 09/02/2016,0.094 09/05/2016,0.098 09/06/2016,0.098 09/07/2016,0.107 09/08/2016,0.1 09/09/2016,0.099 09/13/2016,0.093 09/14/2016,0.094 09/15/2016,0.096 09/16/2016,0.101 09/19/2016,0.1 09/20/2016,0.096 09/21/2016,0.099 09/22/2016,0.1 09/23/2016,0.102 09/26/2016,0.098 09/27/2016,0.095 09/28/2016,0.099 09/29/2016,0.098 09/30/2016,0.097 10/03/2016,0.094 10/04/2016,0.094 10/05/2016,0.094 10/06/2016,0.094 10/07/2016,0.094 10/10/2016,0.094 10/11/2016,0.094 10/12/2016,0.09 10/13/2016,0.083 10/14/2016,0.089 10/17/2016,0.087 10/18/2016,0.085 10/19/2016,0.086 10/20/2016,0.085 10/21/2016,0.084 10/24/2016,0.084 10/25/2016,0.085 10/26/2016,0.084 10/27/2016,0.084 10/28/2016,0.083 11/02/2016,0.083 11/03/2016,0.083 11/04/2016,0.084 11/07/2016,0.082 11/08/2016,0.082 11/09/2016,0.078 11/10/2016,0.078 11/11/2016,0.075 11/14/2016,0.073 11/15/2016,0.072 11/16/2016,0.073 11/17/2016,0.073 11/18/2016,0.077 11/21/2016,0.075 11/22/2016,0.072 11/23/2016,0.07 11/24/2016,0.071 11/25/2016,0.07 11/28/2016,0.068 11/29/2016,0.071 12/01/2016,0.068 12/02/2016,0.07 12/05/2016,0.069 12/06/2016,0.071 12/07/2016,0.069 12/08/2016,0.068 12/09/2016,0.07 12/12/2016,0.074 12/13/2016,0.072 12/14/2016,0.072 12/15/2016,0.07 12/16/2016,0.07 12/19/2016,0.066 12/20/2016,0.065 12/21/2016,0.065 12/22/2016,0.063 12/23/2016,0.062 12/27/2016,0.062 12/28/2016,0.062 12/29/2016,0.063 01/03/2017,0.064 01/04/2017,0.068 01/05/2017,0.069 01/06/2017,0.069 01/09/2017,0.069 01/10/2017,0.071 01/11/2017,0.07 01/12/2017,0.07 01/13/2017,0.072 01/16/2017,0.073 01/17/2017,0.074 01/18/2017,0.07 01/19/2017,0.071 01/20/2017,0.072 01/23/2017,0.071 01/24/2017,0.072 01/25/2017,0.072 01/26/2017,0.072 01/27/2017,0.072 01/30/2017,0.07 01/31/2017,0.071 02/01/2017,0.069 02/02/2017,0.068 02/03/2017,0.067 02/06/2017,0.065 02/07/2017,0.065 02/08/2017,0.066 02/09/2017,0.066 02/10/2017,0.065 02/13/2017,0.064 02/14/2017,0.065 02/15/2017,0.065 02/16/2017,0.065 02/17/2017,0.066 02/20/2017,0.067 02/21/2017,0.066 02/22/2017,0.065 02/23/2017,0.066 02/24/2017,0.066 03/02/2017,0.066 03/03/2017,0.065 03/06/2017,0.065 03/07/2017,0.064 03/08/2017,0.064 03/09/2017,0.065 03/10/2017,0.067 03/13/2017,0.065 03/14/2017,0.064 03/15/2017,0.064 03/16/2017,0.072 03/17/2017,0.074 03/20/2017,0.075 03/21/2017,0.075 03/22/2017,0.073 03/23/2017,0.073 03/24/2017,0.074 03/27/2017,0.079 03/28/2017,0.078 03/29/2017,0.08 03/30/2017,0.078 03/31/2017,0.074 04/03/2017,0.071 04/04/2017,0.074 04/05/2017,0.072 04/06/2017,0.071 04/07/2017,0.073 04/10/2017,0.07 04/11/2017,0.07 04/12/2017,0.071 04/17/2017,0.072 04/18/2017,0.075 04/19/2017,0.074 04/20/2017,0.072 04/21/2017,0.072 04/24/2017,0.088 04/25/2017,0.085 04/26/2017,0.087 04/27/2017,0.093 05/02/2017,0.092 05/03/2017,0.091 05/04/2017,0.092 05/05/2017,0.093 05/08/2017,0.09 05/09/2017,0.086 05/09/2017,0.086 05/10/2017,0.089 05/11/2017,0.089 05/12/2017,0.089 05/15/2017,0.086 05/16/2017,0.087 05/17/2017,0.087 05/18/2017,0.085 05/19/2017,0.087 05/22/2017,0.087

fountainheadpro commented 7 years ago

I'm getting the same error on Mac: Disabling weekly seasonality. Run prophet with weekly_seasonality=True to override this.

RuntimeError Traceback (most recent call last)

in () 3 ts=pd.DataFrame(data={'ds': store_info.index.values, 'y': store_info['trade']}) 4 pr = Prophet() ----> 5 pr.fit(ts) 6 #future = pr.make_future_dataframe(periods=12) 7 #future /Users/szelvenskiy/anaconda2/lib/python2.7/site-packages/fbprophet/forecaster.pyc in fit(self, df, **kwargs) 533 534 else: --> 535 params = model.optimizing(dat, init=stan_init, iter=1e4, **kwargs) 536 for par in params: 537 self.params[par] = params[par].reshape((1, -1)) /Users/szelvenskiy/anaconda2/lib/python2.7/site-packages/pystan/model.pyc in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs) 508 stan_args = pystan.misc._get_valid_stan_args(stan_args) 509 --> 510 ret, sample = fit._call_sampler(stan_args) 511 pars = pystan.misc._par_vector2dict(sample['par'], m_pars, p_dims) 512 if not as_vector: stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8842012118624695346.pyx in stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8842012118624695346.StanFit4Model._call_sampler (/var/folders/sp/05s637fx0q3f0dm7ws_2618r0000gp/T/tmpMejYXT/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8842012118624695346.cpp:16904)() stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8842012118624695346.pyx in stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8842012118624695346._call_sampler (/var/folders/sp/05s637fx0q3f0dm7ws_2618r0000gp/T/tmpMejYXT/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_8842012118624695346.cpp:8973)() RuntimeError: Something went wrong after call_sampler.
fountainheadpro commented 7 years ago

Here is the data: ds y 0 2012-05-01 1 1 2012-08-01 1 2 2012-11-01 2 3 2013-04-01 1 4 2013-06-01 1 5 2013-08-01 1 6 2014-05-01 1 7 2015-11-01 1 8 2016-06-01 1 9 2016-07-01 2 10 2016-10-01 1 11 2016-11-01 1 12 2016-12-01 2 13 2017-01-01 1 14 2017-02-01 3

fountainheadpro commented 7 years ago

In fact, it's not related to data. Same data is processed fine until. Now any call to .fit method fails. Even if it worked before with the same dataset.

adacumos commented 7 years ago

Got it fixed when I upgraded to ubuntu 16.0 weird huh

bletham commented 7 years ago

I'm not sure what is causing this, other than that it seems to be happening inside of Stan. Maybe the update to ubuntu 16.0 also upgraded Stan?

@fountainheadpro if this still isn't working could you see what version of pystan you're running?

kevindu1993 commented 7 years ago

I have the same error: here is the data that I got error: "ds","y" 2017-03-10,166 2017-03-11,167 2017-03-12,168 2017-03-13,169 2017-03-14,170

but when I change the data to this, it run successfully: "ds","y" 2017-03-10,1 2017-03-11,2 2017-03-12,3 2017-03-13,4 2017-03-14,5

kevindu1993 commented 7 years ago

here is the error: File "./prophet.py", line 10, in m.fit(df); File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fbprophet/forecaster.py", line 535, in fit params = model.optimizing(dat, init=stan_init, iter=1e4, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pystan/model.py", line 510, in optimizing ret, sample = fit._call_sampler(stan_args) File "stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3890433898330113621.pyx", line 814, in stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3890433898330113621.StanFit4Model._call_sampler (/var/folders/_3/fj7g23z935150t_q4s8xdsz00000gn/T/tmp_u6cg9mb/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3890433898330113621.cpp:16904) File "stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3890433898330113621.pyx", line 401, in stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3890433898330113621._call_sampler (/var/folders/_3/fj7g23z935150t_q4s8xdsz00000gn/T/tmp_u6cg9mb/stanfit4anon_model_7a788197ac3493030b72020b9ffdbe7d_3890433898330113621.cpp:8973) RuntimeError: Something went wrong after call_sampler.

AlexBanksWatson commented 7 years ago

Working for some but not all of my test series. Not sure why some sets of values seem to fail...

Input: example.txt

Error:


RuntimeError Traceback (most recent call last)

in () 1 # Fit data ----> 2 p.fit(data) F:\Anaconda3\lib\site-packages\fbprophet\forecaster.py in fit(self, df, **kwargs) 533 534 else: --> 535 params = model.optimizing(dat, init=stan_init, iter=1e4, **kwargs) 536 for par in params: 537 self.params[par] = params[par].reshape((1, -1)) F:\Anaconda3\lib\site-packages\pystan\model.py in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs) 508 stan_args = pystan.misc._get_valid_stan_args(stan_args) 509 --> 510 ret, sample = fit._call_sampler(stan_args) 511 pars = pystan.misc._par_vector2dict(sample['par'], m_pars, p_dims) 512 if not as_vector: stanfit4anon_model_9c941523472e65f75f241e35a8769919_8513495007735644422.pyx in stanfit4anon_model_9c941523472e65f75f241e35a8769919_8513495007735644422.StanFit4Model._call_sampler (C:\Users\ALEXAN~1\AppData\Local\Temp\tmpocoa45n9\stanfit4anon_model_9c941523472e65f75f241e35a8769919_8513495007735644422.cpp:17112)() stanfit4anon_model_9c941523472e65f75f241e35a8769919_8513495007735644422.pyx in stanfit4anon_model_9c941523472e65f75f241e35a8769919_8513495007735644422._call_sampler (C:\Users\ALEXAN~1\AppData\Local\Temp\tmpocoa45n9\stanfit4anon_model_9c941523472e65f75f241e35a8769919_8513495007735644422.cpp:8986)() RuntimeError: Something went wrong after call_sampler. Running on Python3 in Windows environment.
bletham commented 7 years ago

OK it seems that in some situations the LBFGS optimizer is failing to converge, and this is making pystan error out. In https://github.com/facebookincubator/prophet/commit/f7becb0942cd0a005d72ae307aefee431fa962d7, if LBFGS fails we fall back to Newton. This fixes the issue for the dataset from @arvindacumos . Could others who are running into this issue install from github and see if this commit fixes it for you?

AlexBanksWatson commented 7 years ago

@bletham Thanks - resolves my issue.