Prophet: MCMC sampling gives STAN max_treedepth warning, but fit() does not accept max_treedepth

Created on 25 Jan 2019  路  2Comments  路  Source: facebook/prophet

First, thanks for such a great library. I'm fitting a timeseries with MCMC sampling in Python:

p = Prophet(mcmc_samples=100)
p.fit(df)

But I get warnings from STAN:

WARNING:pystan:Rhat above 1.1 or below 0.9 indicates that the chains very likely have not mixed
WARNING:pystan:19 of 200 iterations saturated the maximum tree depth of 10 (9.5 %)
WARNING:pystan:Run again with max_treedepth larger than 10 to avoid saturation

If I try setting max_treedepth in fit():

p.fit(df, max_treedepth=12)

I'm told that's not a valid argument to pystan.model.sampling():

ValueError                                Traceback (most recent call last)
<ipython-input-523-096dc4965ed5> in <module>
      1 p = Prophet(mcmc_samples=100)
----> 2 p.fit(df, max_treedepth=12)

/python3.6/site-packages/fbprophet/forecaster.py in fit(self, df, **kwargs)
   1081             )
   1082             args.update(kwargs)
-> 1083             stan_fit = model.sampling(**args)
   1084             for par in stan_fit.model_pars:
   1085                 self.params[par] = stan_fit[par]

/python3.6/site-packages/pystan/model.py in sampling(self, data, pars, chains, iter, warmup, thin, seed, init, sample_file, diagnostic_file, verbose, algorithm, control, n_jobs, **kwargs)
    752         for arg in kwargs:
    753             if arg not in valid_args:
--> 754                 raise ValueError("Parameter `{}` is not recognized.".format(arg))
    755 
    756         args_list = pystan.misc._config_argss(chains=chains, iter=iter,

ValueError: Parameter `max_treedepth` is not recognized.

Most helpful comment

Solved my own problem researching this issue. From the pystan docs, max_treedepth is specified in the control dict:

p.fit(df, control={'max_treedepth': 12})

Hope this helps anyone else searching for this.

All 2 comments

Solved my own problem researching this issue. From the pystan docs, max_treedepth is specified in the control dict:

p.fit(df, control={'max_treedepth': 12})

Hope this helps anyone else searching for this.

control = {}
control['max_treedepth'] = 15
control['adapt_delta'] = 0.99
prophetModel.fit(df_train, control = control)

Hope this helps!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahash52 picture ahash52  路  3Comments

datafool picture datafool  路  3Comments

maxwell873 picture maxwell873  路  3Comments

teramonagi picture teramonagi  路  3Comments

ChaymaeHarfoush picture ChaymaeHarfoush  路  3Comments