RootSaturation#

class pymc_marketing.mmm.components.saturation.RootSaturation(priors=None, prefix=None)[source]#

Wrapper around Root saturation function.

Multiplies pymc_marketing.mmm.transformers.root_saturation() by an extra scaling parameter beta.

Parameters:
alphatensor

Exponent applied to the input by root_saturation(). Default prior: Prior("Beta", alpha=1, beta=2).

betatensor

Scaling factor applied to the root-transformed input. Default prior: Prior("Gamma", mu=1, sigma=1).

.. plot::
context:

close-figs

import matplotlib.pyplot as plt import numpy as np from pymc_marketing.mmm import RootSaturation

rng = np.random.default_rng(0)

saturation = RootSaturation() prior = saturation.sample_prior(random_seed=rng) curve = saturation.sample_curve(prior) saturation.plot_curve(curve, random_seed=rng) plt.show()

Methods

RootSaturation.__init__([priors, prefix])

RootSaturation.apply(x, *[, dims, core_dim, idx])

Call within a model context.

RootSaturation.from_dict(data)

Reconstruct a saturation transformation from a dict.

RootSaturation.function(x, alpha, beta, *[, dim])

Root saturation function.

RootSaturation.plot_curve(curve[, ...])

Plot curve HDI and samples.

RootSaturation.plot_curve_hdi(curve[, ...])

Plot the HDI of the curve.

RootSaturation.plot_curve_samples(curve[, ...])

Plot samples from the curve.

RootSaturation.sample_curve([parameters, ...])

Sample the curve of the saturation transformation given parameters.

RootSaturation.sample_prior([coords])

Sample the priors for the transformation.

RootSaturation.set_dims_for_all_priors(dims)

Set the dims for all priors.

RootSaturation.to_dict([_orig])

Convert the transformation to a dictionary.

RootSaturation.update_priors(priors)

Update the priors for a function after initialization.

RootSaturation.with_default_prior_dims(dims)

Return a copy with default prior dims (dims=None) set to dims instead.

RootSaturation.with_updated_priors(priors)

Return a copy with updated priors.

Attributes

combined_dims

Get the combined dims for all the parameters.

default_priors

function_priors

Get the priors for the function.

model_config

Mapping from variable name to prior for the model.

prefix

priors

Get the priors for the function.

variable_mapping

Mapping from parameter name to variable name in the model.