CmdStanPy
CmdStanPy is a lightweight interface to Stan for Python users which provides the necessary objects and functions to compile a Stan program and run Stan's samplers.
Goals
-
Clean interface to Stan services so that CmdStanPy can keep up with Stan releases.
-
Provides complete control - all sampler arguments have corresponding named argument for CmdStanPy sampler function.
-
Easy to install,
- minimal Python library dependencies: numpy, pandas
- Python code doesn't interface directly with c++, only calls compiled executables
-
Modular - CmdStanPy produces a sample from the posterior, downstream modules do the analysis.
Docs
See https://cmdstanpy.readthedocs.io/en/latest/index.html
Source Repository
CmdStan's source-code repository is hosted here on GitHub.
Licensing
The CmdStanPy, CmdStan, and the core Stan C++ code are licensed under new BSD.
Example
::
import os
from cmdstanpy import CmdStanModel, cmdstan_path
# specify Stan file, create, compile CmdStanModel object
bernoulli_path = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
bernoulli_model = CmdStanModel(stan_file=bernoulli_path)
bernoulli_model.compile()
# specify data, fit the model
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)
# summarize the results (wraps CmdStan `bin/stansummary`):
bernoulli_fit.summary()
Release files for cmdstanpy 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cmdstanpy-0.6.0.tar.gz | 39.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cmdstanpy-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.1 kB
Release files / cmdstanpy-0.6.0.tar.gz
| Download URL | cmdstanpy-0.6.0.tar.gz |
|---|---|
| Size | 39.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69b2e343a7f1cdaff5c6efe3f9df68680845a7096402993a8f40030dde09cb9f
|
|
BLAKE2b-256 checksum How to use checksums |
4fe73ecfaa22ce8c417f128bdb38716244bfadd8f657025b7d15226d9ce8377a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.0
|
Release files / cmdstanpy-0.6.0-py3-none-any.whl
| Download URL | cmdstanpy-0.6.0-py3-none-any.whl |
|---|---|
| Size | 33.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17bcddecab826e6a6c29c2c255cdc378733da4c4fa485c0cd31a83c7fea918ed
|
|
BLAKE2b-256 checksum How to use checksums |
60f532f7b4844a0f4e3794f3456ab3ba73fe869ce7043977fcd39c7b75d06c1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.0
|