mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-07-30 20:18:11 +00:00
sampling iters arg name, logic changes (#1389)
* sampling iters arg name, logic changes * Bump cmdstanpy version in requirements to 0.9.5 * Change Model to CmdStanModel Co-authored-by: Ben Letham <bletham@gmail.com>
This commit is contained in:
parent
e9771c862d
commit
d22922d08c
2 changed files with 7 additions and 6 deletions
|
|
@ -57,7 +57,7 @@ class CmdStanPyBackend(IStanBackend):
|
|||
model_name = 'prophet.stan'
|
||||
target_name = 'prophet_model.bin'
|
||||
|
||||
sm = cmdstanpy.Model(stan_file=os.path.join(model_dir, model_name))
|
||||
sm = cmdstanpy.CmdStanModel(stan_file=os.path.join(model_dir, model_name))
|
||||
sm.compile()
|
||||
copy(sm.exe_file, os.path.join(target_dir, target_name))
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class CmdStanPyBackend(IStanBackend):
|
|||
'fbprophet',
|
||||
'stan_model/prophet_model.bin',
|
||||
)
|
||||
return cmdstanpy.Model(exe_file=model_file)
|
||||
return cmdstanpy.CmdStanModel(exe_file=model_file)
|
||||
|
||||
def fit(self, stan_init, stan_data, **kwargs):
|
||||
(stan_init, stan_data) = self.prepare_data(stan_init, stan_data)
|
||||
|
|
@ -103,12 +103,13 @@ class CmdStanPyBackend(IStanBackend):
|
|||
|
||||
if 'chains' not in kwargs:
|
||||
kwargs['chains'] = 4
|
||||
if 'warmup_iters' not in kwargs:
|
||||
kwargs['warmup_iters'] = samples // 2
|
||||
iter_half = samples // 2
|
||||
if 'iter_warmup' not in kwargs:
|
||||
kwargs['iter_warmup'] = iter_half
|
||||
|
||||
self.stan_fit = self.model.sample(data=stan_data,
|
||||
inits=stan_init,
|
||||
sampling_iters=samples,
|
||||
iter_sampling=iter_half,
|
||||
**kwargs)
|
||||
res = self.stan_fit.sample
|
||||
(samples, c, columns) = res.shape
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
Cython>=0.22
|
||||
cmdstanpy==0.4
|
||||
cmdstanpy==0.9.5
|
||||
pystan>=2.14
|
||||
numpy>=1.10.0
|
||||
pandas>=0.23.4
|
||||
|
|
|
|||
Loading…
Reference in a new issue