load_mmm_from_run#

pymc_marketing.mlflow.load_mmm_from_run(run_id, *, keep_idata=False, dst_path=None, artifact=None)[source]#

Download the inference data of an MLflow run and load the MMM from it.

Parameters:
  • run_id (str) – The MLflow run ID that holds the inference-data artifact.

  • keep_idata (bool) – If True, keep the downloaded inference data on disk.

  • dst_path (str | None) – Directory for the download. With keep_idata=True it defaults to idata_{run_id} in the working directory; otherwise to a temporary directory that is deleted after loading. A directory you pass is kept and only the downloaded artifact is removed; an existing copy of the artifact in it is replaced.

  • artifact (str | None) – Name of an artifact at the root of the run, not a local path. None detects idata.nc or idata.zarr; pass the file name given to log_inference_data(idata, save_file=...) to load data logged under another name.

Return type:

MMM

Returns:

The loaded model; the download is removed unless keep_idata is True, also when loading fails.

Raises:
  • FileNotFoundError – If artifact is None and the run holds neither idata.nc nor idata.zarr, or if the run has no artifact named artifact at its root.

  • ValueError – If artifact is None and the run holds both, or if artifact is not a plain name.

See also

load_mmm

Also loads the lighter PyFuncModel logged with log_mmm().

Examples

from pymc_marketing.mlflow import load_mmm_from_run

mmm = load_mmm_from_run("your_run_id")
mmm = load_mmm_from_run("your_run_id", artifact="my_model.nc", keep_idata=True)