linear_predictor#

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

Find the node the increment is assembled to reproduce.

Under a log link the MMM registers its linear predictor as the Deterministic mu. Under an identity link the same quantity is an anonymous intermediate that only carries the name mu, so it has to be recovered from the graph of the observed variable.

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. See find_named_node() for the one collision that escapes the check: a user-registered Deterministic named mu is found by the named_vars lookup below before any graph search happens.