Skip to main content

CmdStanPy with OpenCL and Multitreading Command

codecov Donate with PayPal

CmdStanPy is a lightweight pure-Python interface to CmdStan which provides access to the Stan compiler and all inference algorithms. It supports both development and production workflows. Because model development and testing may require many iterations, the defaults favor development mode and therefore output files are stored on a temporary filesystem. Non-default options allow all aspects of a run to be specified so that scripts can be used to distributed analysis jobs across nodes and machines.

CmdStanPy is distributed via PyPi: https://pypi.org/project/cmdstanpy/

or Conda Forge: https://anaconda.org/conda-forge/cmdstanpy

Goals

  • Clean interface to Stan services so that CmdStanPy can keep up with Stan releases.

  • Provide access to all CmdStan inference methods.

  • 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 MCMC sample (or point estimate) from the posterior; other packages do analysis and visualization.

  • Low memory overhead - by default, minimal memory used above that required by CmdStanPy; objects run CmdStan programs and track CmdStan input and output files.

Source Repository

CmdStanPy and CmdStan are available from GitHub: https://github.com/stan-dev/cmdstanpy and https://github.com/stan-dev/cmdstan

Docs

The latest release documentation is hosted on https://mc-stan.org/cmdstanpy, older release versions are available from readthedocs: https://cmdstanpy.readthedocs.io

Licensing

The CmdStanPy, CmdStan, and the core Stan C++ code are licensed under new BSD.

Example

import os
from cmdstanpy import cmdstan_path, CmdStanModel

# specify locations of Stan program file and data
stan_file = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
data_file = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.data.json')

# instantiate a model; compiles the Stan program by default
model = CmdStanModel(stan_file=stan_file)

# obtain a posterior sample from the model conditioned on the data
fit = model.sample(chains=4, data=data_file)

# summarize the results (wraps CmdStan `bin/stansummary`):
fit.summary()

Metadata

Release files for cmdstanpy-opencl 0.9.70

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmdstanpy-opencl 0.9.70
File Size Uploaded
cmdstanpy_opencl-0.9.70.tar.gz 76.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmdstanpy-opencl 0.9.70
File Interpreter ABI Platform
cmdstanpy_opencl-0.9.70-py3-none-any.whl Python 3 none any Details

Total release size: 169.1 kB

Release files / cmdstanpy_opencl-0.9.70.tar.gz

Download URL cmdstanpy_opencl-0.9.70.tar.gz
Size 76.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e9d6a74005095ffc296b0038e58c4f878dab59632f3fdf8b27f3a0fa33909a55
BLAKE2b-256 checksum
How to use checksums
4d3b89e6cfeac01eac454e42513dff15ef3b9a73c892ac491626e2359a2a1201
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.8

Release files / cmdstanpy_opencl-0.9.70-py3-none-any.whl

Download URL cmdstanpy_opencl-0.9.70-py3-none-any.whl
Size 93.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6e117b74a6efd92294cbe38dec6583db8d10daa594c5bd67f6f6fa44322756e
BLAKE2b-256 checksum
How to use checksums
fa139af8a1be41db883423b92d37933f06b78fe602df00a2c504d3882b290fa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.8

Release history Release notifications | RSS feed

This release

0.9.70 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page