mcpField
P
pymc-modeling

pymc-modeling

github.com/pymc-labsData & databases93241 installsUpdated 3w ago
Repository

About pymc-modeling

A modeling skill for Python projects using PyMC, covering model formulation, construction, fitting, diagnostics, and prediction. It helps analysts and researchers choose relevant workflows while checking assumptions, computation, and uncertainty.

Key features

  1. 01Formulates estimands and prediction targets
  2. 02Guides likelihood and prior specification
  3. 03Checks prior and posterior predictions
  4. 04Covers fitting and sampling diagnostics
  5. 05Supports model revision and comparison
  6. 06Selects task-specific reference workflows

Use cases

  1. 01Build and fit a PyMC model
  2. 02Investigate sampling failures or warnings
  3. 03Check predictive behavior on new inputs

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pymc-labs/pymc-modeling --skill pymc-modeling

After installing, type/pymc-modelingin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

LICENSE
references/
approximate-inference.md
bart.md
custom-likelihoods.md
extras-distributions.md
extras-model-tools.md
extras-statespace.md
gaussian-processes.md
hierarchical.md
interface-boundaries.md
likelihoods.md
mixtures.md
model-data-dimensions.md
model-testing.md
predictive-checks.md
pymc-extras.md
sampling.md
splines-distributional.md
time-series.md
transformations.md
troubleshooting.md
workflow.md

Details

From the project README

PyMC modeling

Choose a useful starting point: a simple scaffold, an established subject-matter model, or a decomposition of a larger target model. Expand, simplify or branch as the question, data and checks warrant. Use the consuming project's data and Python environment; check installed APIs and package compatibility.

For pymc-extras tasks, start with feature selection and compatibility, then load only the relevant workflow reference. Prefer its supported algorithms to bespoke implementations; do not use an extension merely because it is installed.

Choose the primary task

  • Construct, fit or initialize a model: use pymc-modeling.
  • Elicit prior assumptions or check prior-predictive plausibility: use prior-elicitation when available.
  • Diagnose an existing completed fit or evaluate its predictions: use arviz-diagnostics when available.
  • Repair symbolic computation, broadcasting, gradients or compilation: use pytensor-workflows when available.
  • Track experiments, preserve MLflow artifacts or restore a logged MMM model: use pymc-mlflow when available.

Multipart requests can use more than one skill. The references below support modeling when specialist skills are not installed.

Workflow

  1. Formulate. State the estimand or prediction target, observation units, outcome support, grouping/time structure, selection and missingness, and what information is available at prediction time. Separate predictive, inferential and causal claims; respect data authorization and retain source identities.
  2. Specify and inspect. Match the likelihood to the observation process; choose identifiable parameterizations and priors in declared units. Check row alignment, shapes, support and finite initial log density. Ordinary dims label positional tensors; they do not join coordinates. Use known-parameter simulated cases to probe new implementations and their failure modes; use scoped SBC when repeated inference checks are warranted.
  3. Check prior predictions. Simulate before fitting and compare support, scales and decision-relevant features to domain knowledge. Do not tune priors solely to the realized extrema.
  4. Explore, then fit for inference. Prefer nutpie when compatible and installed. Short preliminary fits can reveal bugs, difficult geometry or gross misfit; label them exploratory, not reliable posterior inference. For reportable results, allocate warmup and draws from adaptation and required ESS/MCSE. Save results before diagnostics or plotting.
  5. Diagnose, then criticize. Inspect divergences, rank R-hat, bulk/tail ESS, MCSE and chain/rank plots. Diagnose every divergence. Unreliable computation leaves posterior conclusions unresolved; it does not disprove a likelihood. Use posterior predictive discrepancies to check the observation model. In-sample PPCs are not held-out validation.
  6. Predict, decide and revise. Preserve training identities and align new inputs; distinguish latent means from noisy observations. For recommendations, propagate uncertainty through stated consequences, utilities and constraints, or hand off the inference without inventing the decision maker's values. Retain relevant model variants and explain how changed assumptions affect estimands, predictions and decisions—not just which has the best score. Adaptive PPC/CV-driven search can overfit; do not present its winner as uniquely confirmed or change seeds/criteria merely to obtain a favorable result.

PyMC 6 returns xarray.DataTree: use idata["posterior"], not attribute group access. Call pm.compute_log_likelihood(idata, model=model) explicitly before LOO or other pointwise-likelihood workflows. ArviZ 1.0 uses LOO, not removed WAIC; state interval probability and type (the default is 89% ETI). Similar stacking weights do not imply model equivalence. Sampler preferences, warmup starting points and interval defaults are implementation conventions, not universal Bayesian workflow requirements. Choose them for the task.

Read only what the task needs

When working onReference
End-to-end fitting, diagnostics and scientific checksWorkflow
Model construction, data containers and dimensionsModel and data
Failed initialization, shape errors, stuck sampling or warningsTroubleshooting
Group effects, pooling and parameterizationHierarchical models
Outcome support, censoring, multivariate families and JacobiansLikelihoods
Algorithms, backends, budgets and persistenceSampling
pymc-extras feature selection, compatibility and validationPyMC Extras
Markov chains, specialized counts, extreme values and histogram likelihoodsExtras distributions
Kalman-marginalized models, structural components and forecastingExtras state-space workflows
Prior factories, model packaging, VIP and posterior-as-prior transferExtras model tools
Variational, Laplace and Pathfinder approximationsApproximate inference
Covariance models and finite-basis errorGaussian processes
Temporal dependence, differential equations and forecastingTime series
Label invariance and discrete eliminationMixtures
External densities, simulators and predictive callbacksCustom likelihoods
Conditioning, interventions and graph transformationsTransformations
In-sample criticism and new-input predictionPredictive checks
Tree ensembles and prediction stateBART
Basis penalties and distributional predictorsSplines
Simulated-data experiments, SBC, numerical oracles and mocksModel testing
Advanced numerical and extension interfacesInterface boundaries

For version-specific APIs, use help() or inspect.signature() on the installed object in the consuming environment, then consult version-matched official documentation or source.

Comments

Markdown supported