I got the following error message when trying to use the "fit" feature. I ran Python on Anaconda environment, with Pystan's 2.14 version, Pandas's 0.20.2 version, and Python's 3.5 version. I don't understand why I encounter this issue, so could anyone please help?
Error Message:
'WARNING:pystan:numpy.core.multiarray failed to import
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
WARNING:pystan:numpy.core.multiarray failed to import
WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.
AttributeError Traceback (most recent call last)
11 HAN_BIKE["ds"] = HAN_BIKE["ds"].values.astype('datetime64[D]')
12 m = Prophet()
---> 13 m.fit(HAN_BIKE)
/Applications/anaconda/lib/python3.5/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))
/Applications/anaconda/lib/python3.5/site-packages/pystan/model.py in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs)
466 data = {}
467
--> 468 fit = self.fit_class(data)
469
470 m_pars = fit._get_param_names()
AttributeError: 'StanModel' object has no attribute 'fit_class''
```
Sorry, but nobody could help me with the above issue?
To be able to isolate the issue, could you check if pystan is working?
import pystan
model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
model = pystan.StanModel(model_code=model_code) # this will take a minute
y = model.sampling(n_jobs=1).extract()['y']
y.mean() # should be close to 0
@bletham Thanks for your help. Yes, it does give me the result: 0.017287202743671251. It's weird FB doesn't even address this issue in the FAQ for FB prophet;p
I'm sorry to say that I'm really not sure what is happening here. Could you try re-installing fbprophet and seeing if there are any errors / warnings during install? If you're using Anaconda then conda install -c conda-forge fbprophet seems to be the best way to install.
Actually I think the issue is something with the numpy installation. Notice the warning that Pystan is giving about not being able to import numpy multiarray. Are you able to import numpy.core.multiarray? It then says "module compiled against API version 0xb but this version of numpy is 0xa".
Could you upgrade numpy to the latest version, and perhaps also pystan?
the pystan and fbprophet's isn't suitable, change the version will be fine.
the pystan and fbprophet's isn't suitable, change the version will be fine.
which version do you use?
This fixed it for me
I am having exactly the same problem when I instantiate the prophet model with:
m = Prophet()
m.fit(df)
I got:
AttributeError Traceback (most recent call last)
<ipython-input-15-1ab3c9387252> in <module>
1 m = Prophet()
----> 2 m.fit(df)
~\Anaconda3\envs\PystanandProphet\lib\site-packages\fbprophet\forecaster.py in fit(self, df, **kwargs)
~\Anaconda3\envs\PystanandProphet\lib\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()
AttributeError: 'StanModel' object has no attribute 'fit_class'
I tried to downgrade with pip install fbprophet==0.3.post2 , and also tried:
pip install fbprophet --no-cache-dir --no-binary :all:
but got the same...
Any suggestion?
Please, notice that @bletham Just reopened #775 ...which address this very same issue...
this is my package version, maybe will help you to solve your problem.
pystan 2.17.1.0
fbprophet 0.3.post2
I think pystan version is not ok.
From: Jose Luis Martinez notifications@github.com
Date: 2019-01-04 11:19:58
To: facebook/prophet prophet@noreply.github.com
Cc: zerogouzi g20178600@xs.ustb.edu.cn,Comment comment@noreply.github.com
Subject: Re: [facebook/prophet] StanModel' object has no attribute 'fit_class' Error (#249)
I am having exactly the same roblem when I instantiate the prophet model with:
m = Prophet()
m.fit(df)
I got:
AttributeError Traceback (most recent call last)
1 m = Prophet()
----> 2 m.fit(df)
~\Anaconda3\envs\PystanandProphetlib\site-packages\fbprophet\forecaster.py in fit(self, df, *kwargs)
~\Anaconda3\envs\PystanandProphetlib\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()
AttributeError: 'StanModel' object has no attribute 'fit_class'
I tried to install fbprophet 0.3.post2, , but got the same...
Any suggestion?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
As Sean described in #775, the current issue was not a locally-cached whl (as it was in this issue, and as I had initially thought in #775), but rather it was that we had inadvertently put a whl on pypi.
We removed the whl on pypi, and so this issue should now be resolved (again!) and if you pip install it should build properly.
how to fix this error.
ERROR: Command errored out with exit status 1:
command: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py'"'"'; __file__='"'"'C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-4c8jwmk6\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python37\Include\fbprophet'
cwd: C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\
Complete output (42 lines):
running install
running build
running build_py
creating build
creating buildlib
creating buildlib\fbprophet
creating buildlib\fbprophet\stan_models
Traceback (most recent call last):
File "
File "C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py", line 126, in
"""
File "c:\python37lib\site-packages\setuptools__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "c:\python37libdistutilscore.py", line 148, in setup
dist.run_commands()
File "c:\python37libdistutilsdist.py", line 966, in run_commands
self.run_command(cmd)
File "c:\python37libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "c:\python37lib\site-packages\setuptools\command\install.py", line 61, in run
return orig.install.run(self)
File "c:\python37libdistutils\command\install.py", line 545, in run
self.run_command('build')
File "c:\python37libdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\python37libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "c:\python37libdistutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\python37libdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\python37libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py", line 46, in run
build_stan_models(target_dir)
File "C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py", line 28, in build_stan_models
from pystan import StanModel
File "c:\python37lib\site-packages\pystan__init__.py", line 9, in
from pystan.api import stanc, stan
File "c:\python37lib\site-packages\pystanapi.py", line 13, in
import pystan._api # stanc wrapper
ImportError: DLL load failed: The specified module could not be found.
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py'"'"'; __file__='"'"'C:\Users\HP\AppData\Local\Temp\pip-install-k1eo64gl\fbprophet\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\HP\AppData\Local\Temp\pip-record-4c8jwmk6\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python37\Include\fbprophet' Check the logs for full command output.