deserialize#
- pymc_marketing.deserialize.deserialize(data)[source]#
Deserialize a dictionary into a Python object.
Use the
register_deserialization()function to add custom deserializations.Deserialization is a two step process due to the dynamic nature of the data:
Determine if the data is of the correct type.
Deserialize the data into a Python object.
Each registered deserialization is checked in order until one is found that can deserialize the data. If no deserialization is found, a
DeserializableErroris raised.A
DeserializableErroris raised when the data fails to be deserialized by any of the registered deserializers.- Parameters:
- data
Any The data to deserialize.
- data
- Returns:
AnyThe deserialized object.
- Raises:
DeserializableErrorRaised when the data doesn’t match any registered deserializations or fails to be deserialized.
Examples
Deserialize a
pymc_marketing.prior.Priorobject:from pymc_marketing.deserialize import deserialize data = {"dist": "Normal", "kwargs": {"mu": 0, "sigma": 1}} prior = deserialize(data) # Prior("Normal", mu=0, sigma=1)