Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

AttributeError: 'StanModel' object has no attribute 'fit_class' #689

Closed
allisonwang opened this issue Sep 28, 2018 · 2 comments
Closed

AttributeError: 'StanModel' object has no attribute 'fit_class' #689

allisonwang opened this issue Sep 28, 2018 · 2 comments

Comments

@allisonwang
Copy link

allisonwang commented Sep 28, 2018

I kept getting this error when trying to fit prophet model.

AttributeError                            Traceback (most recent call last)
<ipython-input-139-a8e399fdfab2> in <module>()
----> 1 m.fit(df)

~/env/lib/python3.6/site-packages/fbprophet/forecaster.py in fit(self, df, **kwargs)
   1001             try:
   1002                 params = model.optimizing(
-> 1003                     dat, init=stan_init, iter=1e4, **kwargs)
   1004             except RuntimeError:
   1005                 params = model.optimizing(

~/env/lib/python3.6/site-packages/pystan/model.py in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs)
    510             data = {}
    511         seed = pystan.misc._check_seed(seed)
--> 512         fit = self.fit_class(data, seed)
    513 
    514         m_pars = fit._get_param_names()

AttributeError: 'StanModel' object has no attribute 'fit_class'

Has anyone encountered this issue before? What could be causing this error?

@bletham
Copy link
Contributor

bletham commented Oct 16, 2018

Usually this is because PyStan is not working correctly. Could you run this code to check if it is?

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

Most commonly the issue with PyStan is getting the C++ compiler set up (especially in windows). For that I would refer to (https://pystan.readthedocs.io/en/latest/windows.html) . If you're using Anaconda, then it is best to install fbprophet through conda forge, as described in https://facebook.github.io/prophet/docs/installation.html

@allisonwang
Copy link
Author

thanks! I am installing this in Linux with pip but there might be something wrong when building the package. I will look into this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants