Bundled Datasets

Example datasets shipped with the package (load_example).

Bundled example datasets for a zero-effort first run.

>>> from mmm_framework.datasets import load_example
>>> panel = load_example("national")

load_example and list_examples are also re-exported from the top-level package (from mmm_framework import load_example).

class mmm_framework.datasets.ExampleSpec(key, csv, kpi, media, controls, geo, truth, description)[source]

Bases: object

Declarative description of a bundled example dataset.

key: str
csv: str
kpi: str
media: tuple[str, ...]
controls: tuple[str, ...]
geo: bool
truth: str | None
description: str
__init__(key, csv, kpi, media, controls, geo, truth, description)
mmm_framework.datasets.list_examples()[source]

Return {name: one-line description} for every bundled example.

Return type:

dict[str, str]

mmm_framework.datasets.load_example(name='national', *, as_frame=False)[source]

Load a bundled example dataset, ready to model.

Return type:

PanelDataset | DataFrame

Parameters

name:

Which example to load — "national" (default) or "geo". See list_examples().

as_frame:

If True, return the raw long-format MFF pandas.DataFrame instead of a built PanelDataset (useful for building your own config).

Returns

PanelDataset or pandas.DataFrame

A ready-to-fit panel (default), or the raw MFF frame when as_frame=True.

Examples

>>> from mmm_framework import load_example, BayesianMMM, ModelConfigBuilder, TrendConfig
>>> panel = load_example("national")
>>> panel.n_channels
7
mmm_framework.datasets.load_example_answer_key(name='national')[source]

Load the sealed ground-truth answer key for an example, if one ships.

Returns the parsed JSON (channels, true_contribution, true_roas, and DGP notes) or None when the example has no bundled key.

Return type:

dict | None