VariableSchema#

pydantic model pymc_marketing.data.idata.schema.VariableSchema[source]#

Schema for a single variable in InferenceData.

Validates the structure (dimensions and dtype) of xarray.DataArray variables within InferenceData groups.

Parameters:
namestr

Variable name

requiredbool, default True

Whether this variable must be present

dimstuple of str or “*”

Expected dimension names. Use “*” to accept any dimensions.

dtypestr, tuple of str, or None

Expected numpy dtype(s) (e.g., “float64”, “int64”, or (“float64”, “int64”)). Use None to skip dtype validation.

descriptionstr, default “”

Human-readable description of this variable

Examples

>>> schema = VariableSchema(
...     name="channel_contribution",
...     dims=("date", "channel"),
...     dtype="float64",
...     required=True,
... )
>>> data_array = xr.DataArray(...)
>>> errors = schema.validate_variable(data_array)
>>> if errors:
...     print("Validation errors:", errors)

Methods

VariableSchema.__init__(**data)

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

VariableSchema.validate_variable(data_array)

Validate variable structure.

field description: str = ''[source]#
field dims: tuple[str, ...] | Literal['*'] [Required][source]#
field dtype: str | tuple[str, ...] | None = None[source]#
field name: str [Required][source]#
field required: bool = True[source]#