DataDerivedScaling#
- class pymc_marketing.mmm.scaling.DataDerivedScaling(**data)[source]#
Scale by a statistic of the data, computed at fit time.
Both reductions are signed:
method="max"isdata.max(...)andmethod="mean"isdata.mean(...), not the maximum or mean of the absolute values. UnlikeFixedScaling, which requires positive values, nothing constrains the sign or magnitude of a computed scale, so two cases are reachable and neither is reported:A slice whose reduction is negative gives a scale that flips the sign of the scaled data. The round trip still closes, because
original_scale_transformmultiplies by the same scale again, but the flip is invisible.A slice whose reduction is exactly zero gives a scale of zero, so every scaled value is NaN or infinite.
MMM.build_modelrewrites those to0.0, which replaces that slice’s data with zeros rather than scaling it. Under a likelihood with positive support this raises at build time; underNormalit fits on the zeros silently.
An all-zero target reaches the second case, which is what
sample_prior_predictiveandfitproduce when noyis given.- Parameters:
Examples
Max scaling (default behaviour):
DataDerivedScaling(method="max", dims=())
Mean scaling across a custom dimension:
DataDerivedScaling(method="mean", dims=("country",))
Methods
DataDerivedScaling.__init__(**data)Create a new model by parsing and validating input data from keyword arguments.
DataDerivedScaling.construct([_fields_set])DataDerivedScaling.copy(*[, include, ...])Returns a copy of the model.
DataDerivedScaling.dict(*[, include, ...])Reconstruct from a dict via Pydantic model_validate.
DataDerivedScaling.json(*[, include, ...])Compute the class name for parametrizations of generic classes.
DataDerivedScaling.parse_file(path, *[, ...])DataDerivedScaling.parse_raw(b, *[, ...])Human-readable summary of the scaling strategy.
DataDerivedScaling.schema([by_alias, ...])DataDerivedScaling.schema_json(*[, ...])DataDerivedScaling.to_dict([_orig])Serialize to a dict via Pydantic model_dump.
DataDerivedScaling.update_forward_refs(**localns)DataDerivedScaling.validate(value)Attributes
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].