Dot#

class pymc_marketing.terms.Dot(*, var_name, prior, name=None)[source]#

Linear predictor term: data @ beta.

Registers the data variable as pmd.Data for out-of-sample prediction.

Parameters:
var_namestr

Name of the data variable in the dataset.

priorVariableFactory

Prior for the beta coefficients. Any VariableFactory is accepted. Must have dims matching the last dimension of the data variable.

namestr, optional

Name for the coefficient variable. Defaults to {var_name}_beta. Provide a distinct name to reference the same var_name from multiple terms (e.g. separate alpha and beta coefficient branches) without colliding on the coefficient variable name.

Examples

from pymc_extras.prior import Prior
from pymc_marketing.terms import (
    Dot,
    Intercept,
    collect_coords,
    register_data,
    build_param,
)

# basic
mu = Intercept("mu") + Dot(var_name="x", prior=Prior("Normal", dims="feature"))

# two branches on the same data, distinct coefficient names
alpha_branch = Dot(
    var_name="x", name="alpha_coef", prior=Prior("Normal", dims="feature")
)
beta_branch = Dot(
    var_name="x", name="beta_coef", prior=Prior("Normal", dims="feature")
)

Methods

Dot.__init__(*, var_name, prior[, name])

Dot.add_coords(ds)

Add coordinates to the model during register_data.

Dot.create_variable()

Build data @ beta tensor.

Dot.from_dict(data)

Reconstruct a dot term from its serialized form.

Dot.get_coords(ds)

Extract coordinates from the data variable.

Dot.register_data(ds)

Register the data variable as pmd.Data.

Dot.set_data(ds[, model])

Update pmd.Data for prediction.

Dot.to_dict([_orig])

Attributes