facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.

Home Page:https://facebook.github.io/prophet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The fit method do not work with pystan==2.17.0.0

robsonpeixoto opened this issue · comments

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-0235c1cd9218> in <module>()
----> 1 m.fit(serie);

~/.pyenv/versions/3.6.2/envs/manhattan/lib/python3.6/site-packages/fbprophet/forecaster.py in fit(self, df, **kwargs)
    832             try:
    833                 params = model.optimizing(
--> 834                     dat, init=stan_init, iter=1e4, **kwargs)
    835             except RuntimeError:
    836                 params = model.optimizing(

~/.pyenv/versions/3.6.2/envs/manhattan/lib/python3.6/site-packages/pystan/model.py in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs)
    470             data = {}
    471         seed = pystan.misc._check_seed(seed)
--> 472         fit = self.fit_class(data, seed)
    473 
    474         m_pars = fit._get_param_names()

stanfit4anon_model_1fdd477dd8bcc50395c4e25c8741f1c1_7672185744958054027.pyx in stanfit4anon_model_1fdd477dd8bcc50395c4e25c8741f1c1_7672185744958054027.StanFit4Model.__init__()

TypeError: __init__() takes exactly 1 positional argument (2 given)

Thanks for the heads up on this. When fbprophet is installed, the models are compiled in stan and saved in a pickle. The issue here seems to be in loading the models pickled under an older version of pystan in the newer version of pystan. I was able to replicate this issue, and found that it was fixed by re-intsalling fbprophet:

sudo pip3 install -U fbprophet

Unit tests pass under the new Stan version.

Thanks a lot, @bletham. Maybe a troubleshooting section with this info will help a lot.

commented

Received this same error on my system with fbprophet updated from 0.1.1 to 0.2, and python 3.5 while using jupyter. Running sudo pip3 install -U fbprophet didn't resolve the issue for me. I found two possible workarounds though.

  • Keep the existing fbprophet 0.2 install and rollback pystan 2.17 to 2.14:
sudo -H pip3 install -U pystan==2.14

Or

  • Uninstall fbprophet 0.2, delete the cached wheel, install pystan 2.17, then reinstall fbprophet with pip:
sudo -H pip3 uninstall fbprophet pystan
sudo rm /path/to/fbprophet*.whl
sudo -H pip3 install pystan==2.17
sudo -H pip3 install fbprophet==0.2

Haven't tested this thoroughly but the fit error did go away.

Thanks @dbricare , that makes sense, the cached wheel would also contain the models compiled under the old pystan version. I think that pip3 --no-cache-dir install fbprophet would work, although removing the wheel seems like a better option.

Great success with this under anaconda Python 2.7. Thank you @bletham

sudo pip install -U fbprophet

I installed prophet 0.2 using conda, pystan version 2.14 under python 3.6. I get the following error:
'init() takes exactly 2 positional arguments (1 given)'

I received the same error TypeError: __init__() takes exactly 1 positional argument (2 given) and pip install -U fbprophet didn't resolve the issue under Python 3.6.3 :: Anaconda, Inc. but introduced a Cython error!

I used the following commands to finally get it working,

pip uninstall fbprophet pystan
pip --no-cache-dir install pystan==2.17
pip --no-cache-dir install fbprophet==0.2
conda install Cython --force

I added to the install directions that fbprophet may need to be re-installed after upgrading pystan.