Welcome to the Meridian end-to-end demo using the JAX backend. This simplified demo showcases the fundamental functionalities and basic usage of the library using JAX for faster and more efficient modeling. It includes working examples of the major modeling steps:
- Install and Environment Configuration
- Load the data
- Configure the model
- Run post-modeling quality checks
- Run model diagnostics
- Generate model results & two-page output
- Run budget optimization & two-page output
- Save the model object
- Interactive Scenario Planning
Note that this notebook skips all of the exploratory data analysis and preprocessing steps. It assumes that you have completed these tasks before reaching this point in the demo.
This notebook utilizes sample data. As a result, the numbers and results obtained might not accurately reflect what you encounter when working with a real dataset.
Step 0: Install and Enviroment Configuration
1. Make sure you are using one of the available GPU Colab runtimes which is requiredto run Meridian. You can change your notebook's runtime in Runtime > Change runtime type
in the menu. All users can use the T4 GPU runtime which is sufficient to run the demo colab, free of charge. Users who have purchased one of Colab's paid plans have access to premium GPUs (such as V100, A100 or L4 Nvidia GPU).
2. Install the latest version of Meridian, and verify that GPU is available.
# Uninstall TensorFlow, it is not needed when running Meridian with JAX.pip uninstall tensorflow -y -q
# Install meridian: from PyPI @ latest releasepip install --upgrade google-meridian [ colab,and-cuda,schema ]# Install meridian: from PyPI @ specific version# !pip install google-meridian[colab,and-cuda,schema]==1.3.1# Install meridian: from GitHub @HEAD# !pip install --upgrade "google-meridian[colab,and-cuda,schema] @ git+https://github.com/google/meridian.git@main"
Requirement already satisfied: google-meridian[and-cuda,colab,schema] in /usr/local/lib/python3.12/dist-packages (1.5.3) Requirement already satisfied: arviz<0.20.0 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (0.19.0) Requirement already satisfied: altair>=5 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (5.5.0) Requirement already satisfied: bidict in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (0.23.1) Requirement already satisfied: immutabledict in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (4.3.1) Requirement already satisfied: joblib in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (1.5.3) Requirement already satisfied: natsort<8,>=7.1.1 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (7.1.1) Requirement already satisfied: numpy<2.4.0,>=2.0.2 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (2.0.2) Requirement already satisfied: pandas<3,>=2.2.2 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (2.2.2) Requirement already satisfied: scipy<2,>=1.13.1 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (1.16.3) Requirement already satisfied: statsmodels>=0.14.5 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (0.14.6) Collecting tensorflow<2.21,>=2.19.0 (from google-meridian[and-cuda,colab,schema]) Using cached tensorflow-2.20.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.5 kB) Requirement already satisfied: tfp-nightly==0.26.0.dev20260130 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (0.26.0.dev20260130) Requirement already satisfied: tf-keras<2.21,>=2.18 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (2.20.1) Requirement already satisfied: xarray in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (2025.12.0) Requirement already satisfied: psutil in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (5.9.5) Requirement already satisfied: python-calamine in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (0.6.2) Requirement already satisfied: mmm-proto-schema>=1.1.2 in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (1.1.2) Requirement already satisfied: semver in /usr/local/lib/python3.12/dist-packages (from google-meridian[and-cuda,colab,schema]) (3.0.4) Requirement already satisfied: absl-py in /usr/local/lib/python3.12/dist-packages (from tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (1.4.0) Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.12/dist-packages (from tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (1.17.0) Requirement already satisfied: decorator in /usr/local/lib/python3.12/dist-packages (from tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (4.4.2) Requirement already satisfied: cloudpickle>=1.3 in /usr/local/lib/python3.12/dist-packages (from tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (3.1.2) Requirement already satisfied: gast>=0.3.2 in /usr/local/lib/python3.12/dist-packages (from tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (0.7.0) Requirement already satisfied: dm-tree in /usr/local/lib/python3.12/dist-packages (from tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (0.1.10) Requirement already satisfied: jinja2 in /usr/local/lib/python3.12/dist-packages (from altair>=5->google-meridian[and-cuda,colab,schema]) (3.1.6) Requirement already satisfied: jsonschema>=3.0 in /usr/local/lib/python3.12/dist-packages (from altair>=5->google-meridian[and-cuda,colab,schema]) (4.26.0) Requirement already satisfied: narwhals>=1.14.2 in /usr/local/lib/python3.12/dist-packages (from altair>=5->google-meridian[and-cuda,colab,schema]) (2.19.0) Requirement already satisfied: packaging in /usr/local/lib/python3.12/dist-packages (from altair>=5->google-meridian[and-cuda,colab,schema]) (26.1) Requirement already satisfied: typing-extensions>=4.10.0 in /usr/local/lib/python3.12/dist-packages (from altair>=5->google-meridian[and-cuda,colab,schema]) (4.15.0) Requirement already satisfied: setuptools>=60.0.0 in /usr/local/lib/python3.12/dist-packages (from arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (75.2.0) Requirement already satisfied: matplotlib>=3.5 in /usr/local/lib/python3.12/dist-packages (from arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (3.10.0) Requirement already satisfied: h5netcdf>=1.0.2 in /usr/local/lib/python3.12/dist-packages (from arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (1.8.1) Requirement already satisfied: xarray-einstats>=0.3 in /usr/local/lib/python3.12/dist-packages (from arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (0.10.0) Requirement already satisfied: googleapis-common-protos in /usr/local/lib/python3.12/dist-packages (from mmm-proto-schema>=1.1.2->google-meridian[and-cuda,colab,schema]) (1.74.0) Requirement already satisfied: protobuf in /usr/local/lib/python3.12/dist-packages (from mmm-proto-schema>=1.1.2->google-meridian[and-cuda,colab,schema]) (5.29.6) Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas<3,>=2.2.2->google-meridian[and-cuda,colab,schema]) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas<3,>=2.2.2->google-meridian[and-cuda,colab,schema]) (2025.2) Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas<3,>=2.2.2->google-meridian[and-cuda,colab,schema]) (2026.1) Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.12/dist-packages (from statsmodels>=0.14.5->google-meridian[and-cuda,colab,schema]) (1.0.2) Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (1.6.3) Requirement already satisfied: flatbuffers>=24.3.25 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (25.12.19) Requirement already satisfied: google_pasta>=0.1.1 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.2.0) Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (18.1.1) Requirement already satisfied: opt_einsum>=2.3.2 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.4.0) Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (2.32.4) Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.3.0) Requirement already satisfied: wrapt>=1.11.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (2.1.2) Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (1.80.0) Requirement already satisfied: tensorboard~=2.20.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (2.20.0) Requirement already satisfied: keras>=3.10.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.13.2) Requirement already satisfied: h5py>=3.11.0 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.16.0) Requirement already satisfied: ml_dtypes<1.0.0,>=0.5.1 in /usr/local/lib/python3.12/dist-packages (from tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.5.4) Requirement already satisfied: nvidia-cublas-cu12<13.0,>=12.5.3.2 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.8.4.1) Requirement already satisfied: nvidia-cuda-cupti-cu12<13.0,>=12.5.82 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.8.90) Requirement already satisfied: nvidia-cuda-nvcc-cu12<13.0,>=12.5.82 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.5.82) Requirement already satisfied: nvidia-cuda-nvrtc-cu12<13.0,>=12.5.82 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.8.93) Requirement already satisfied: nvidia-cuda-runtime-cu12<13.0,>=12.5.82 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.8.90) Requirement already satisfied: nvidia-cudnn-cu12<10.0,>=9.3.0.75 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (9.10.2.21) Requirement already satisfied: nvidia-cufft-cu12<12.0,>=11.2.3.61 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (11.3.3.83) Requirement already satisfied: nvidia-curand-cu12<11.0,>=10.3.6.82 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (10.3.9.90) Requirement already satisfied: nvidia-cusolver-cu12<12.0,>=11.6.3.83 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (11.7.3.90) Requirement already satisfied: nvidia-cusparse-cu12<13.0,>=12.5.1.3 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.5.8.93) Requirement already satisfied: nvidia-nccl-cu12<3.0,>=2.25.1 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (2.27.5) Requirement already satisfied: nvidia-nvjitlink-cu12<13.0,>=12.5.82 in /usr/local/lib/python3.12/dist-packages (from tensorflow[and-cuda]<2.21,>=2.19.0; extra == "and-cuda"->google-meridian[and-cuda,colab,schema]) (12.8.93) Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.12/dist-packages (from astunparse>=1.6.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.46.3) Requirement already satisfied: attrs>=18.2.0 in /usr/local/lib/python3.12/dist-packages (from dm-tree->tfp-nightly==0.26.0.dev20260130->google-meridian[and-cuda,colab,schema]) (26.1.0) Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.12/dist-packages (from jsonschema>=3.0->altair>=5->google-meridian[and-cuda,colab,schema]) (2025.9.1) Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.12/dist-packages (from jsonschema>=3.0->altair>=5->google-meridian[and-cuda,colab,schema]) (0.37.0) Requirement already satisfied: rpds-py>=0.25.0 in /usr/local/lib/python3.12/dist-packages (from jsonschema>=3.0->altair>=5->google-meridian[and-cuda,colab,schema]) (0.30.0) Requirement already satisfied: rich in /usr/local/lib/python3.12/dist-packages (from keras>=3.10.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (13.9.4) Requirement already satisfied: namex in /usr/local/lib/python3.12/dist-packages (from keras>=3.10.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.1.0) Requirement already satisfied: optree in /usr/local/lib/python3.12/dist-packages (from keras>=3.10.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.19.0) Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.5->arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (1.3.3) Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.5->arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.5->arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (4.62.1) Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.5->arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (1.5.0) Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.5->arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (11.3.0) Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib>=3.5->arviz<0.20.0->google-meridian[and-cuda,colab,schema]) (3.3.2) Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests<3,>=2.21.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.4.7) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests<3,>=2.21.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.11) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests<3,>=2.21.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (2.5.0) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests<3,>=2.21.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (2026.2.25) Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.12/dist-packages (from tensorboard~=2.20.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.10.2) Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /usr/local/lib/python3.12/dist-packages (from tensorboard~=2.20.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.7.2) Requirement already satisfied: werkzeug>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from tensorboard~=2.20.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (3.1.8) Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.12/dist-packages (from jinja2->altair>=5->google-meridian[and-cuda,colab,schema]) (3.0.3) Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.12/dist-packages (from rich->keras>=3.10.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (4.0.0) Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.12/dist-packages (from rich->keras>=3.10.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (2.20.0) Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.12/dist-packages (from markdown-it-py>=2.2.0->rich->keras>=3.10.0->tensorflow<2.21,>=2.19.0->google-meridian[and-cuda,colab,schema]) (0.1.2) Using cached tensorflow-2.20.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (620.7 MB) Installing collected packages: tensorflow ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tensorflow-decision-forests 1.12.0 requires tensorflow==2.19.0, but you have tensorflow 2.20.0 which is incompatible. tensorflow-text 2.19.0 requires tensorflow<2.20,>=2.19.0, but you have tensorflow 2.20.0 which is incompatible. Successfully installed tensorflow-2.20.0
import
os
# This needs to be set prior to meridian import.
os
.
environ
[
'MERIDIAN_BACKEND'
]
=
'jax'
import
IPython
from
meridian
import
constants
from
meridian.analysis
import
analyzer
from
meridian.analysis
import
optimizer
from
meridian.analysis
import
summarizer
from
meridian.analysis
import
visualizer
from
meridian.analysis.review
import
reviewer
from
meridian.data
import
data_frame_input_data_builder
from
meridian.model
import
model
from
meridian.model
import
prior_distribution
from
meridian.model
import
spec
from
meridian.schema.serde
import
meridian_serde
import
numpy
as
np
import
pandas
as
pd
# check if GPU is available
from
psutil
import
virtual_memory
import
jax
import
jax.numpy
as
jnp
# Use jax.numpy instead of tensorflow
import
tensorflow_probability
as
tfp
tfp_jax
=
tfp
.
substrates
.
jax
ram_gb
=
virtual_memory
()
.
total
/
1e9
print
(
'Your runtime has
{:.1f}
gigabytes of available RAM
\n
'
.
format
(
ram_gb
))
print
(
'Num GPUs Available: '
,
len
([
d
for
d
in
jax
.
devices
()
if
d
.
platform
==
'gpu'
]),
)
print
(
'Num CPUs Available: '
,
len
([
d
for
d
in
jax
.
devices
()
if
d
.
platform
==
'cpu'
]),
)
/usr/local/lib/python3.12/dist-packages/meridian/backend/config.py:68: UserWarning: The JAX backend is currently under development and is not yet functional. It is intended for internal testing only and should not be used. Please use the TensorFlow backend. _warn_jax_experimental() Your runtime has 13.6 gigabytes of available RAM Num GPUs Available: 1 Num CPUs Available: 0
3. Mount a storage. Use meridian_root
to refer the mounted root. The mounted root will be used to save trained model
, stage two-pager output
and generate scenario planning dashboard
.
For Colab Free/Pro user, we will use the MyDrive
folder in Google Drive as the external storage. For Colab Enterprise user, we will use Cloud FUSE
to mount a GCS bucket.
# @markdown If you are using Colab Free, Colab Pro, run this cell to mount your Google Drive.
from
google.colab
import
drive
drive_mount
=
'/content/drive'
drive
.
mount
(
drive_mount
,
force_remount
=
True
)
subfolder
=
''
# @param {"type":"string","placeholder": "Optional, specifying a subfolder is recommended for organizing distinct execution runs."}
# Change this "MyDrive" to other share folders name if you would like to use a different drive.
meridian_root
=
f
'
{
drive_mount
}
/MyDrive/
{
subfolder
}
'
is_enterprise_user
=
False




