linear_predictor#

pymc_marketing.mmm.spend_reach.linear_predictor(model)[source]#

Find the node the increment is assembled to reproduce.

The MMM registers its linear predictor as the Deterministic mu under both links, so the named_vars lookup below finds it. The graph search is kept for models that do not register it, such as anything fitted before mu was registered under the identity link.

Parameters:
modelMMM

The fitted model to search.

Returns:
Variable or None

The linear predictor, or None if this model does not expose one – in which case SpendProbe.assert_increment_is_complete() has nothing to check against and says so.

Raises:
ValueError

If the graph carries more than one node named mu, which leaves the predictor impossible to identify by name. This only applies to models that reach the graph search: where mu is registered, the named_vars lookup below settles it first and PyMC has already enforced that the name is unique.