Python interface to CmdStan
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cmdstanpy-0.6.0.tar.gz
.
File metadata
- Download URL: cmdstanpy-0.6.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
69b2e343a7f1cdaff5c6efe3f9df68680845a7096402993a8f40030dde09cb9f
|
|
MD5 |
6b176b1c6d915f46df6500f75838262c
|
|
BLAKE2b-256 |
4fe73ecfaa22ce8c417f128bdb38716244bfadd8f657025b7d15226d9ce8377a
|
File details
Details for the file cmdstanpy-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: cmdstanpy-0.6.0-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
17bcddecab826e6a6c29c2c255cdc378733da4c4fa485c0cd31a83c7fea918ed
|
|
MD5 |
394576f132f7601e29362de1b899a210
|
|
BLAKE2b-256 |
60f532f7b4844a0f4e3794f3456ab3ba73fe869ce7043977fcd39c7b75d06c1c
|