API#

Modules#

bass

Bass diffusion model for product adoption forecasting.

causal_utils

A moducle with utilities for causal reasoning and discovery.

clv

CLV models and utilities.

customer_choice

Customer Choice module.

data

Data adaptors for PyMC-Marketing.

experimental

Experimental APIs under active development.

hsgp_kwargs

Class to store and validate keyword argument for the Hilbert Space Gaussian Process (HSGP) components.

metrics

Evaluation Metrics.

mlflow

MLflow logging utilities for PyMC models.

mmm

Marketing Mix Models (MMM).

model_builder

Base classes containing primitives and high-level API for model building, fitting, saving, and loading.

model_config

Model configuration utilities.

model_graph

Functions to manipulate PyMC models as graphs.

paths

Paths for the project.

pie

Predicted Incrementality by Experimentation (PIE).

plot

Plot distributions stored in xarray.DataArray across coordinates.

pytensor_utils

PyTensor utility functions.

r2d2

R2D2 prior for variance decomposition in regression models.

serialization

Unified serialization infrastructure for pymc-marketing.

serialization_migration

Migration tool for old-format serialized models.

special_priors

Specialized priors that behave like the Prior class.

terms

Composable model terms for building pymc.dims subgraphs from xarray data.

terms_gp

Gaussian process model terms.

utils

Utility functions for PyMC-Marketing.

Experimental graph-first terms#

pymc_marketing.experimental.terms provides graph-first Structural Causal Models (SCMs) and term-first optimization. Shared primitives remain in pymc_marketing.terms, and MMM components remain in pymc_marketing.mmm. These APIs are under active development and do not replace the stable MMM optimizer. See the term-first optimization guide for the Problem → evaluate → solve workflow.

SCM(*equations)

Fit, forecast, and save a Bayesian Structural Causal Model (SCM).

Data(var_name)

Reference a raw, mutable named variable in the model dataset.

Equation(*[, mu, likelihood, name, ...])

Declare a stochastic equation without constructing any PyMC variables.

MediaTransform(media, transformation)

Apply one configured adstock or saturation along date.

OptimizationResult(allocation, objective, ...)

Original-unit solution and unmodified scaled-solver diagnostics.

Problem(*, model, terms, dates, objective, ...)

Bind a reusable original-unit decision problem to fitted deterministic terms.