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. Withkeep_idata=Trueit defaults toidata_{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.Nonedetectsidata.ncoridata.zarr; pass the file name given tolog_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_idatais True, also when loading fails.- Raises:
FileNotFoundError – If
artifactisNoneand the run holds neitheridata.ncnoridata.zarr, or if the run has no artifact namedartifactat its root.ValueError – If
artifactisNoneand the run holds both, or ifartifactis not a plain name.
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)