pymc
Use PyMC for Bayesian probabilistic programming, model construction, distributions, MCMC/NUTS inference, predictive checks, diagnostics, and advanced GP/ODE/VI workflows.
Files29
View on GitHubSKILL.mdskills/repositories/repo-skills/pymc/SKILL.md
GitHubPyMC repo skill
Use this skill when a task needs PyMC-specific operating knowledge: Bayesian model graphs, coordinates and dimensions, pm.Data, distribution/log-probability design, CustomDist, MCMC/NUTS, prior or posterior predictive sampling, DataTree/ArviZ outputs, diagnostics, Gaussian processes, ODE likelihoods, or variational inference.
Start here
- Read references/repo-provenance.md before relying on this skill for a different PyMC checkout or when deciding whether to refresh it.
- Read references/installation-and-environment.md when installing PyMC, checking optional samplers, or choosing
nutpie, JAX/NumPyro/BlackJAX, Zarr,mcbackend, Graphviz, or CPU/GPU routes. - Read references/troubleshooting.md for cross-cutting install/import, PyTensor compiler, optional backend, DataTree/ArviZ, and Graphviz failures.
- Run scripts/check_pymc_env.py to check PyMC importability, versions, optional modules, and an optional tiny model smoke.
- Run scripts/pymc_quick_smoke.py for a tiny end-to-end CPU model,
pm.sample, predictions, andpm.dointervention check.
Minimal public install and import check:
python -m pip install pymc
python -c "import pymc as pm; print(pm.__version__)"
For faster optional NUTS support, install pymc[nutpie]. Install numpyro, blackjax, and JAX packages only when a task actually needs JAX-backed samplers.
Route by task
| If the user asks about... | Use |
|---|---|
Building a model with with pm.Model, named variables, observed data, missing values, coords/dims, pm.Data, pm.set_data, Deterministic, Potential, compile_logp, model debugging, graph visualization, pm.do, or pm.observe |
sub-skills/modeling-data/SKILL.md |
Choosing distributions, .dist() components, shapes/support dimensions, transforms, CustomDist, DensityDist, mixtures, truncation/censoring, or pm.logp/pm.logcdf |
sub-skills/distributions-logprob/SKILL.md |
Running pm.sample, NUTS/MCMC, step methods, external samplers (nutpie, numpyro, blackjax), prior/posterior predictive sampling, pm.draw, SMC, diagnostics, log-likelihood, DataTree/ArviZ outputs, Zarr, or mcbackend |
sub-skills/inference-predictive/SKILL.md |
Gaussian processes, pm.ode.DifferentialEquation, ADVI/FullRankADVI/SVGD/ASVGD, pm.fit, approximation sampling, minibatches, or advanced pymc.dims interactions |
sub-skills/advanced-workflows/SKILL.md |
Operating defaults
- Build models in a
with pm.Model(coords=...) as model:context. Usepm.Dataonly for values you intend to replace later. - Use regular
coords/dimsfor stable output labels and shape metadata. Treatpymc.dimsas experimental and read the modeling/advanced sub-skill before using it. - Use
.dist()for unregistered component distributions in mixtures, truncation, censoring, and symbolic custom distributions. - For deterministic smokes, pin
nuts_sampler="pymc",chains=1,cores=1, tiny draws/tune, andcompute_convergence_checks=False. Do not treat tiny-draw smokes as statistical convergence evidence. - For real inference, increase
draws,tune, andchains; inspect divergences, tree depth, ESS, R-hat, and log-likelihood/model-comparison readiness. - Prefer default DataTree outputs (
return_inferencedata=True). Usepm.compute_log_likelihoodwhen model comparison needs alog_likelihoodgroup. - When changing data length for prediction, update both
pm.Datavalues and matchingcoords, then use posterior predictive guidance frominference-predictive.
Common task chains
- Out-of-sample predictions with changed covariates: read
modeling-dataforpm.Data/coords mutation, theninference-predictiveforsample_posterior_predictive(predictions=True)and output validation. - Custom likelihood or mixture model: read
distributions-logprobfor.dist(), support, signature, and logp checks; theninference-predictivefor sampling and diagnostics. - Scientific GP or ODE model: read
advanced-workflowsfor GP/ODE construction; thenmodeling-datafor shared coordinates/data andinference-predictivefor posterior/predictive execution. - Approximate large-data workflow: read
advanced-workflowsfor VI/minibatches, then useinference-predictiveonly for final posterior predictive and diagnostic output handling.
Self-contained runtime helpers
These helpers are safe, tiny, and CPU-first:
python scripts/check_pymc_env.py --run-smoke --json
python scripts/pymc_quick_smoke.py --draws 10 --tune 10 --json
python sub-skills/modeling-data/scripts/model_data_smoke.py --posterior-predictive --draws 5 --tune 5 --quiet
python sub-skills/distributions-logprob/scripts/distribution_logp_smoke.py --json
python sub-skills/inference-predictive/scripts/inference_smoke.py --draws 5 --tune 5 --json
python sub-skills/advanced-workflows/scripts/advanced_workflows_smoke.py --all --vi-iterations 3 --vi-draws 3 --json
Do not link future work to PyMC source docs, notebooks, tests, or scripts as runtime dependencies. Use this skill's bundled references and scripts, and refresh the skill if a newer checkout changes public APIs or optional backend behavior.