Module: schema.serde.meridian_serde

Serialization and deserialization of Meridian models into/from proto format.

The meridian_serde.MeridianSerde class provides an interface for serializing and deserializing Meridian models into and from an MmmKernel proto message.

The Meridian model--when serialized into an MmmKernel proto--is internally represented as the sum of the following components:

  1. Marketing data: This includes the KPI, media, and control data present in the input data. They are structured into an MMM-agnostic MarketingData proto message.
  2. Meridian model: A MeridianModel proto message encapsulates Meridian-specific model parameters, including hyperparameters, prior distributions, and sampled inference data.

Sample usage:

from schema.serde import meridian_serde

serde = meridian_serde.MeridianSerde()
mmm = model.Meridian(...)
serialized_mmm = serde.serialize(mmm)  # An `MmmKernel` proto
deserialized_mmm = serde.deserialize(serialized_mmm)  # A `Meridian` object

Classes

class FunctionRegistry: A dictionary-like container for custom functions used in serialization.

class MeridianSerde: Serializes and deserializes a Meridian model into an MmmKernel proto.

Functions

load_meridian(...): Load the model object from an MmmKernel proto file path.

save_meridian(...): Save the model object as an MmmKernel proto in the given filepath.