FixedScaling#
- pydantic model pymc_marketing.mmm.scaling.FixedScaling[source]#
Use a user-supplied constant that stays the same across model refreshes.
Examples
Fixed scalar scaling for production stability:
FixedScaling(dims=(), value=10_000.0)
Per-dimension fixed scaling (multidimensional MMM):
FixedScaling( dims=("country",), value={"US": 50_000, "UK": 30_000}, )
Multi-dimensional fixed scale (e.g. country × channel) with xarray:
import xarray as xr FixedScaling( dims=(), value=xr.DataArray( [[1e3, 2e3], [3e3, 4e3]], dims=("country", "channel"), coords={"country": ["US", "UK"], "channel": ["tv", "search"]}, ), )
Long-format table via
from_long_dataframe():FixedScaling.from_long_dataframe( dims=(), df=long_df, value_col="scale", dim_cols=["country", "channel"], )
Methods
FixedScaling.__init__(**data)Create a new model by parsing and validating input data from keyword arguments.
FixedScaling.from_dict(data)Deserialize; restores encoded
xarray.DataArrayvalues.FixedScaling.from_long_dataframe(dims, df, ...)Build fixed scaling from a long table (one row per coordinate combination).
Human-readable summary of the scaling strategy.
FixedScaling.to_dict([_orig])Serialize to a dict via Pydantic model_dump.
- field dims: str | tuple[str, ...] [Required][source]#
The dimensions to perform the operation through (
"date"is always included implicitly).
- field value: float | dict[str, float] | xr.DataArray [Required][source]#
Fixed scaling constant(s). A single
floatapplies uniformly. Adictmaps coordinate labels along the single remaining dimension after reducing overdateanddims(see the multidimensional MMM). If more than one non-reduced dimension remains, use anxarray.DataArraywhose dimensions broadcast to that grid (e.g. a vector overcountrywhen the media grid iscountry×channel). All values must be positive; NaNs are not allowed.