Quickstart: YAML Builder
Use the YAML builder to create an in-memory PanelMMM from a model
specification. It builds the PyMC graph; you then fit and predict in Python.
For staged outputs and manifests, use the
Pipeline Runner.
Complete Installation first. The example below uses small synthetic data and short chains to check execution. It does not establish convergence, parameter recovery or a suitable model for real data.
Create a builder configuration
Work in a new scratch directory, such as sandbox/yaml-quickstart/ within your
checkout. Save this as model.yml in that directory:
This configuration accepts X and y from Python. The bundled
data/demo/timeseries/config.yml is a runner configuration: it also
contains diagnostics, validation, prior_sensitivity and ai_advisor.
The public builder rejects those runner-only blocks. Use the runner for that
file; do not pass it directly to build_mmm_from_yaml(...).
Build from synthetic data
Run these Python blocks in order from the directory containing model.yml:
The result is a PanelMMM with a built graph. Keep the same training data for
fitting; changing it after construction raises a data-identity error.
Fit and predict
fit(...) uses the sampler defaults in the YAML fit block:
With this configuration, the returned dataset has 24 dates and 100 combined posterior samples (two chains of 50 draws). Sampling warnings and divergences can occur with such short chains. Do not interpret these smoke-run estimates. Before interpreting a real model, choose adequate sampling settings and assess Diagnostics.
Override configuration from Python
model_kwargs takes precedence over the translated YAML constructor arguments.
For sampler_config, provide the complete mapping you want to use: it replaces
the YAML sampler mapping at this boundary.
This second fit only checks the override path. It is not a sensitivity or convergence assessment.
Load your own data
| Pattern | What you provide |
|---|---|
| In-memory data | Both X and y, as above |
| Combined CSV | data.dataset_path; the file must contain the target column |
| Separate CSVs | data.x_path and data.y_path |
Configured relative paths resolve from the YAML file’s directory. The builder
normalises the configured date column. To fit after loading a CSV, load and
split that data in Python too, then pass matching X and y to fit(...).
See Input Data Requirements
for index, missing-data and panel rules.
Optional builder blocks
| Key | Purpose |
|---|---|
estimator |
Select a named estimator preset |
dimensions |
Legacy panel-dimension configuration; do not combine with estimator |
scaling |
Target and channel scaling rules |
effects |
Additive effects attached before graph construction |
priors |
Model-level prior overrides |
fit |
Sampler defaults |
holidays |
Holiday/event configuration |
original_scale_vars |
Original-scale deterministic variables added after build |
inference_data |
Attach saved inference data |
calibration |
Calibration steps after build, subject to estimator support |
optimization |
Optimisation settings accepted by the shared schema; the builder does not run optimisation |
Check Choose an Estimator before adapting this example to a panel. For the Python interfaces, see Builders and Pipeline.