src.model.model

Module Contents

src.model.model.logger[source]
src.model.model.det_dot(a, b)[source]

Dot product for Theano.

The theano dot product and NUTS sampler don’t work with large matrices. Copyright (c) 2021. Ritchie Vink source: https://www.ritchievink.com/blog/2018/10/09/ … build-facebooks-prophet-in-pymc3-bayesian-time-series-analyis-with-generalized-additive-models/

Parameters
anp.array
btt.vector
Returns
np.array

dot product of the two.

src.model.model.fourier_series(t, p=52.1775, n=5)[source]

Calculate fourier representation of t for a period and order.

Copyright (c) 2021. Ritchie Vink Based on source: https://www.ritchievink.com/blog/2018/10/09/ … build-facebooks-prophet-in-pymc3-bayesian-time-series-analyis-with-generalized-additive-models/

Parameters
trange

range to be used as input variable

pfloat

period to use for the fourier orders

nint

order of fourier series

Returns
np.array

matrix fourier representation of t

src.model.model.seasonality_model(t, p=52.1775, n=5, seasonality_prior_scale=1)[source]

Create seasonality model with fourier series.

Copyright (c) 2021. Ritchie Vink Based on source: https://www.ritchievink.com/blog/2018/10/09/ … build-facebooks-prophet-in-pymc3-bayesian-time-series-analyis-with-generalized-additive-models/

Parameters
trange

range to be used as input variable

pfloat

period to use for the fourier orders

nint

order of fourier series

seasonality_prior_scale: float
Returns
pm.var

PYMC3 variable

src.model.model.polynomial(t, n=4)[source]

Calculate polynomial representation of t for an order.

Parameters
trange

range to be used as input variable

nint

order of polynomial

Returns
np.array

matrix polynomial representation of t

src.model.model.drift_model(t, n=4)[source]

Polynomal drift/trend function for additive model.

Parameters
trange

range to be used as input variable

nint

order of polynomal.

Returns
pm.var

PYMC3 variable

src.model.model.create_model(t, y, p_fourier, n_fourier=5, n_polynomial=2)[source]

Create a PYMC3 GAM model with a trend/drift and a seasonal/yearly component.

Parameters
ttimestamps

input series of scaled timestamps

yfloat

observed values

p_fourier: float

scaled period of the timestamps to take for the fourier component (a year)

n_fourierint

order of the fourier component

n_polynomial: inbt

order of the polynomial component

Returns
PYMC3 model context