I am writing a template for cmdstanpy analyses called cookiecutter-cmdstanpy and would be really grateful for any feedback on the work done so far.
The overall idea is to avoid repeating work - instead of manually creating a bunch of folders and writing the same code every time you start a new cmdstanpy project, you can start with the template. Ideally, you would only have to make changes that reflect the parts of your analysis that are genuinely unique.
The template is based on cookiecutter, so you should be able to use it with the following commands:
pip install cookiecutter cookiecutter https://github.com/teddygroves/cookiecutter-cmdstanpy
This should give you a file structure like this:
├── LICENSE ├── Makefile ├── README.md ├── bibliography.bib ├── data │ ├── fake │ │ └── readme.md │ ├── prepared │ │ └── readme.md │ └── raw │ ├── raw_measurements.csv │ └── readme.md ├── fit_fake_data.py ├── fit_real_data.py ├── prepare_data.py ├── report.md ├── requirements.txt ├── results │ ├── infd │ │ └── readme.md │ ├── input_data_json │ │ └── readme.md │ ├── loo │ │ └── readme.md │ ├── plots │ │ └── readme.md │ └── samples │ └── readme.md └── src ├── cmdstanpy_to_arviz.py ├── data_preparation.py ├── fake_data_generation.py ├── fitting.py ├── model_configuration.py ├── model_configurations_to_try.py ├── pandas_to_cmdstanpy.py ├── readme.md ├── stan │ ├── custom_functions.stan │ ├── model.stan │ └── readme.md └── util.py
The repository and in particular the scripts
fit_real_data.py should work straight away, based on the stan file at
src/stan/model.stan and the raw measurements at
data/raw/raw_measurements.csv. You should also be able to run
make clean_all to get rid of created files and (if pandoc is available)
make report.pdf to create a pdf report.
In order to implement a custom analysis you need to modify or replace
data/raw/raw_measurements.csv and then tweak the python files in the
I’d really like to know what some current or potential cmdstanpy users think of this project. In particular:
- Do you have a similar solution for avoiding repeated work when you start a new project?
- How well does the overall structure match how you use cmdstanpy?
- What do you think is the right balance between functionality and flexibility here? I tried to make the template as unopinionated as possible, but I don’t really know how other people tend to use cmdstanpy so I suspect it might be a bit too focused on my typical workflow.
- Are there specific choices you would have made differently?
- What is the biggest missing feature? I have listed a few here but I probably missed some.
Any help or opinions are very gratefully received!