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:
- name
str Variable name
- requiredbool, default
True Whether this variable must be present
- dims
tupleofstror “*” Expected dimension names. Use “*” to accept any dimensions.
- dtype
str,tupleofstr, orNone Expected numpy dtype(s) (e.g., “float64”, “int64”, or (“float64”, “int64”)). Use None to skip dtype validation.
- description
str, default “” Human-readable description of this variable
- name
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.