HSGPPeriodicTerm#
- class pymc_marketing.terms_gp.HSGPPeriodicTerm(*, var_name='date', name='hsgp_periodic', X_mid=None, dims=None, demeaned_basis=False, time_resolution=None, scale, ls, period, m)[source]#
Periodic HSGP term.
A one-dimensional periodic GP over the time reference
var_name, for seasonality with a fixedperiod. Mirrorspymc_marketing.mmm.hsgp.HSGPPeriodic:m,scale,ls, andperiodare required (there is no data-driven recommendation for the periodic basis).- Parameters:
var_name (
str) – Name of the time reference in the dataset, read withds[var_name](works for both coordinates and data variables). Datetimes are converted to days since the first date, divided bytime_resolution, and registered aspmd.Dataunder{name}_index. Defaults to"date".name (
str) – Prefix for the variables and the output deterministic. Defaults to"hsgp_periodic".scale (
VariableFactory|float) – Prior for the scale of the periodic GP.ls (
VariableFactory|float) – Prior for the lengthscale of the periodic GP.period (
float) – The period of the function, in units of the time index.m (
int) – Number of basis functions.dims (
str|tuple[str,...] |None) – Extra dims for the coefficients beyond the time dim.demeaned_basis (
bool) – Whether each basis has its mean subtracted. DefaultFalse.
Examples
from pymc_extras.prior import Prior from pymc_marketing.terms_gp import HSGPPeriodicTerm seasonality = HSGPPeriodicTerm( var_name="time", name="seasonality", scale=Prior("HalfNormal", sigma=1), ls=Prior("InverseGamma", alpha=2, beta=1), period=52, m=20, )
Methods
HSGPPeriodicTerm.__init__(*[, var_name, ...])Resolve the centering value from the data.
Build the GP curve through the wrapped HSGP class.
Reconstruct a term from its serialized form.
Collect coordinates from the time reference and extra dims.
HSGPPeriodicTerm.named(name[, dims])Record this expression as a named deterministic model variable.
Register the numeric time index as
pmd.Dataand freezeX_mid.HSGPPeriodicTerm.set_data(ds[, model])Update the shared time index for out-of-sample prediction.
HSGPPeriodicTerm.sum(dim)Sum this expression over one named dimension.
HSGPPeriodicTerm.to_dict([_orig])Attributes
Dataset variables this term reads as shared data.
Dims beyond the time dimension.
Deterministics this term freezes for out-of-sample evaluation.
Name of this term's registered numeric index data variable.