View source on GitHub
|
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:
- Marketing data: This includes the KPI, media, and control data present in
the input data. They are structured into an MMM-agnostic
MarketingDataproto message. - Meridian model: A
MeridianModelproto 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.
View source on GitHub