pymc_forecast.features#
Seasonal feature builders: Fourier design matrices and periodic tiling.
- pymc_forecast.features.fourier_features(time, *, period, num_terms)[source]#
Build a labeled Fourier seasonality design matrix.
- Parameters:
time – Either an integer duration (phases
0..duration-1) or an array of numeric time positions (e.g.np.arange(len(index))or fractional day-of-week positions). The positions set the phase; the returned"time"coord carries them.period – Seasonal period, in the same units as
time.num_terms – Number of harmonics; the output has
2 * num_termscolumns.
- Returns:
xarray.DataArray– Dims("time", "fourier")with coords labeling each harmonic (sin_1 .. sin_k, cos_1 .. cos_k).
- pymc_forecast.features.periodic_repeat(pattern, duration, *, axis=0, period=None)[source]#
Tile a seasonal pattern to cover
durationtime steps.Works on numpy arrays and on PyTensor variables (e.g. a sampled seasonal latent inside a model). For symbolic tensors whose length along
axisis not statically known, passperiodexplicitly.- Parameters:
pattern – The seasonal pattern; its length along
axisis the period.duration – Target length along
axis.axis – Axis to repeat along (defaults to
0, the package’s time axis).period – Explicit period, required only when it cannot be read from
pattern’s static shape.