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:
Mitzi Morris 2020-03-24 17:33:52 -04:00 committed by GitHub
parent e9771c862d
commit d22922d08c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -57,7 +57,7 @@ class CmdStanPyBackend(IStanBackend):
model_name = 'prophet.stan' model_name = 'prophet.stan'
target_name = 'prophet_model.bin' 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() sm.compile()
copy(sm.exe_file, os.path.join(target_dir, target_name)) copy(sm.exe_file, os.path.join(target_dir, target_name))
@ -67,7 +67,7 @@ class CmdStanPyBackend(IStanBackend):
'fbprophet', 'fbprophet',
'stan_model/prophet_model.bin', '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): def fit(self, stan_init, stan_data, **kwargs):
(stan_init, stan_data) = self.prepare_data(stan_init, stan_data) (stan_init, stan_data) = self.prepare_data(stan_init, stan_data)
@ -103,12 +103,13 @@ class CmdStanPyBackend(IStanBackend):
if 'chains' not in kwargs: if 'chains' not in kwargs:
kwargs['chains'] = 4 kwargs['chains'] = 4
if 'warmup_iters' not in kwargs: iter_half = samples // 2
kwargs['warmup_iters'] = samples // 2 if 'iter_warmup' not in kwargs:
kwargs['iter_warmup'] = iter_half
self.stan_fit = self.model.sample(data=stan_data, self.stan_fit = self.model.sample(data=stan_data,
inits=stan_init, inits=stan_init,
sampling_iters=samples, iter_sampling=iter_half,
**kwargs) **kwargs)
res = self.stan_fit.sample res = self.stan_fit.sample
(samples, c, columns) = res.shape (samples, c, columns) = res.shape

View file

@ -1,5 +1,5 @@
Cython>=0.22 Cython>=0.22
cmdstanpy==0.4 cmdstanpy==0.9.5
pystan>=2.14 pystan>=2.14
numpy>=1.10.0 numpy>=1.10.0
pandas>=0.23.4 pandas>=0.23.4