Closed wesbarnett closed 4 years ago
did you upgrade your Mac to Catalina?
No, I'm on Mojave (10.14.5). (Thanks for the quick response!)
complete_pool_fit = model_complete_pool.sample(data=data_dict)
I think what's going on is that this model has a really hard time fitting, given the parameterization. each sampler chain has its own random seed and it initializes the parameter values randomly between -2 and 2 in order to get warmup off the ground. a bad combination of random values will probably kill it. so, 2 things to try:
a) first, run the sample
command with csv_basename=
set to a pathname:
complete_pool_fit = model_complete_pool.sample(data=data_dict, csv_basename='./foo')
this will create both csv files and txt files - the latter should have interesting error messages. also, any thoughts on https://github.com/stan-dev/cmdstanpy/issues/133 would be appreciated.
b) run the sample
command setting adapt_delta
at 0.9 or higher:
complete_pool_fit = model_complete_pool.sample(data=data_dict, adapt_delta='0.99', csv_basename='./foo')
CmdStanPy needs to do a better job when the sampler process throws an error - cf https://github.com/stan-dev/cmdstanpy/issues/141
Unfortunately adding the csv output filename doesn't produce anything. It looks like it may be crashing before anything is output to the files. I also added adapt_delta
and still get the same behavior, also with no output file (as an aside I had to change the parameter to a float from a String).
In contrast, I also ran the command from cmdstan outside of python and it seems to succeed (output not shown here):
./simple_pool data file=efron-morris-75-data.json sample
(I converted the csv to a json file):
{"N": 18, "y": [18, 17, 16, 15, 14, 14, 13, 12, 11, 11, 10, 10, 10, 10, 10, 9, 8, 7], "K": [45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]}
Doh! sorry, so none of the models work - simple_pool, simple_no_pool - OK - and if you run from CmdStanPy and specify json file as input instead of Dict, does that work?
complete_pool_fit = model_complete_pool.sample(data='efron-morris-75-data.json')
Specifying the json file also does not work. None of the examples from the workshop work (in the Jupyter notebooks both for the women's soccer and baseball examples), but the basic example from the documentation does work:
import os
from cmdstanpy import CmdStanModel, cmdstan_path
bernoulli_path = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
bernoulli_model = CmdStanModel(stan_file=bernoulli_path)
bernoulli_model.compile()
bernoulli_data = { "N" : 10, "y" : [0,1,0,0,0,0,0,0,0,1] }
bernoulli_fit = bernoulli_model.sample(chains=5, cores=3, data=bernoulli_data)
bernoulli_fit.summary()
what does the model object report about itself? please try this:
model_complete_pool = CmdStanModel(stan_file='simple_pool.stan')
model_complete_pool.compile()
print(model_complete_pool)
BTW, thank you so much for your patience - you are a much valued beta tester!
OK, recreated bug on my machine - it's the fact that there's a space in the directory name -
here = os.path.dirname(os.path.abspath('.'))
>>> here
'/Users/mitzi/Test Space'
Oh wow, good catch! I can confirm, that was the case. After renaming my directory with spaces, it now runs. I would be willing to work on a fix. Would love to try to contribute.
@mitzimorris has something changed in Maybe...
class?
Main problem is probably the bug that we create a cmd string and split it with str.split()
. (Not a problem in Windows where we use shortpaths).
Main problem is probably the bug that we create a cmd string and split it with str.split().
exactly! @ahartikainen spotted this a while back - https://github.com/stan-dev/cmdstanpy/issues/91 @wesbarnett - good first issue?
Sure, I'll tackle #91.
This line is actually also an issue. I believe it needs to include the entire path.
Summary:
I was at the tutorial session at PyData NYC on Wednesday afternoon. I'm getting an error running some of the tutorial code on my Mac (but can run it fine on Linux).
Description:
Here is the python code, stan code, and data that are causing the error:
The error I am getting is the following:
Additional Information:
This error only occurs on MacOS. It does not seem to be a problem on my Linux machine. I've tried reinstalling both cmdstan and cmdstanpy.
Current Version:
cmdstanpy: 0.6.0 cmdstan: 2.21.0