MMMIdataSchema#

class pymc_marketing.data.idata.schema.MMMIdataSchema(**data)[source]#

Complete schema for multidimensional MMM InferenceData.

Defines expected groups and variables for a fitted MMM model, with configuration based on model settings.

Parameters:
model_typeLiteral[“mmm”], default “mmm”

Model type (currently only MMM supported)

groupsdict of str to InferenceDataGroupSchema

Schema for each InferenceData group

custom_dimstuple of str, default ()

Custom dimensions beyond standard (date, channel)

Examples

>>> schema = MMMIdataSchema.from_model_config(
...     custom_dims=("country",),
...     has_controls=True,
...     has_seasonality=False,
...     time_varying=False,
... )
>>> errors = schema.validate(mmm.idata)
>>> if errors:
...     print("Validation errors:", errors)

Methods

MMMIdataSchema.__init__(**data)

Create a new model by parsing and validating input data from keyword arguments.

MMMIdataSchema.construct([_fields_set])

MMMIdataSchema.copy(*[, include, exclude, ...])

Returns a copy of the model.

MMMIdataSchema.dict(*[, include, exclude, ...])

MMMIdataSchema.from_model_config([...])

Create schema based on model configuration.

MMMIdataSchema.from_orm(obj)

MMMIdataSchema.json(*[, include, exclude, ...])

MMMIdataSchema.model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

MMMIdataSchema.model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

MMMIdataSchema.model_dump(*[, mode, ...])

!!! abstract "Usage Documentation"

MMMIdataSchema.model_dump_json(*[, indent, ...])

!!! abstract "Usage Documentation"

MMMIdataSchema.model_json_schema([by_alias, ...])

Generates a JSON schema for a model class.

MMMIdataSchema.model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

MMMIdataSchema.model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

MMMIdataSchema.model_rebuild(*[, force, ...])

Try to rebuild the pydantic-core schema for the model.

MMMIdataSchema.model_validate(obj, *[, ...])

Validate a pydantic model instance.

MMMIdataSchema.model_validate_json(json_data, *)

!!! abstract "Usage Documentation"

MMMIdataSchema.model_validate_strings(obj, *)

Validate the given object with string data against the Pydantic model.

MMMIdataSchema.parse_file(path, *[, ...])

MMMIdataSchema.parse_obj(obj)

MMMIdataSchema.parse_raw(b, *[, ...])

MMMIdataSchema.schema([by_alias, ref_template])

MMMIdataSchema.schema_json(*[, by_alias, ...])

MMMIdataSchema.update_forward_refs(**localns)

MMMIdataSchema.validate(idata)

Validate InferenceData against schema.

MMMIdataSchema.validate_or_raise(idata)

Validate InferenceData, raising detailed exception if invalid.

Attributes

model_computed_fields

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_extra

Get extra fields set during validation.

model_fields

model_fields_set

Returns the set of fields that have been explicitly set on this model instance.

model_type

groups

custom_dims