orbit.models package

Submodules

orbit.models.ets module

class orbit.models.ets.BaseETS(seasonality=None, seasonality_sm_input=None, level_sm_input=None, **kwargs)

Bases: orbit.models.template.BaseTemplate

Base abstract class for univariate time-series model creation BaseTemplate will instantiate an estimator class of estimator_type. Each model defines its own _supported_estimator_types to determine if the provided estimator_type is supported for that particular model.

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

class orbit.models.ets.ETSAggregated(**kwargs)

Bases: orbit.models.template.AggregatedPosteriorTemplate, orbit.models.ets.BaseETS

Concrete ETS model for aggregated posterior prediction

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • aggregate_method ({ 'mean', 'median' }) – Method used to reduce parameter posterior samples

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

class orbit.models.ets.ETSFull(**kwargs)

Bases: orbit.models.template.FullBayesianTemplate, orbit.models.ets.BaseETS

Concrete ETS model for full Bayesian prediction

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the initial MCMC or VI posterior samples. If -1, use the original posterior draws.

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

class orbit.models.ets.ETSMAP(estimator_type=<class 'orbit.estimators.stan_estimator.StanEstimatorMAP'>, **kwargs)

Bases: orbit.models.template.MAPTemplate, orbit.models.ets.BaseETS

Concrete ETS model for MAP (Maximum a Posteriori) prediction

Similar to ETSAggregated but prediction is based on Maximum a Posteriori (aka Mode) of the posterior.

This model only supports MAP estimating `estimator_type`s

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If set to be -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

orbit.models.lgt module

class orbit.models.lgt.BaseLGT(regressor_col=None, regressor_sign=None, regressor_beta_prior=None, regressor_sigma_prior=None, regression_penalty='fixed_ridge', lasso_scale=0.5, auto_ridge_scale=0.5, slope_sm_input=None, **kwargs)

Bases: orbit.models.ets.BaseETS

Base LGT model object with shared functionality for Full, Aggregated, and MAP methods

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

class orbit.models.lgt.LGTAggregated(**kwargs)

Bases: orbit.models.ets.ETSAggregated, orbit.models.lgt.BaseLGT

Concrete LGT model for aggregated posterior prediction

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • aggregate_method ({ 'mean', 'median' }) – Method used to reduce parameter posterior samples

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • seasonality – Length of seasonality

  • seasonality_sm_input – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • aggregate_method – Method used to reduce parameter posterior samples

  • n_bootstrap_draws – Number of bootstrap samples to draw from the error part to generate the uncertainty. If -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_regression_coefs()
class orbit.models.lgt.LGTFull(**kwargs)

Bases: orbit.models.ets.ETSFull, orbit.models.lgt.BaseLGT

Concrete LGT model for full Bayesian prediction

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the initial MCMC or VI posterior samples. If -1, use the original posterior draws.

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • seasonality – Length of seasonality

  • seasonality_sm_input – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • n_bootstrap_draws – Number of bootstrap samples to draw from the initial MCMC or VI posterior samples. If -1, use the original posterior draws.

  • prediction_percentiles – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_regression_coefs(aggregate_method='mean')
class orbit.models.lgt.LGTMAP(estimator_type=<class 'orbit.estimators.stan_estimator.StanEstimatorMAP'>, **kwargs)

Bases: orbit.models.ets.ETSMAP, orbit.models.lgt.BaseLGT

Concrete LGT model for MAP (Maximum a Posteriori) prediction

Similar to :class: ~orbit.models.LGTAggregated but prediction is based on Maximum a Posteriori (aka Mode) of the posterior.

This model only supports MAP estimating `estimator_type`s

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If set to be -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • seasonality – Length of seasonality

  • seasonality_sm_input – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • n_bootstrap_draws – Number of bootstrap samples to draw from the error part to generate the uncertainty. If set to be -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_regression_coefs()

orbit.models.dlt module

class orbit.models.dlt.BaseDLT(regressor_col=None, regressor_sign=None, regressor_beta_prior=None, regressor_sigma_prior=None, regression_penalty='fixed_ridge', lasso_scale=0.5, auto_ridge_scale=0.5, slope_sm_input=None, period=1, damped_factor=0.8, global_trend_option='linear', **kwargs)

Bases: orbit.models.ets.BaseETS

Base DLT model object with shared functionality for Full, Aggregated, and MAP methods

The model arguments are the same as BaseLGT with some additional arguments

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • period (int) – Used to set time_delta as 1 / max(period, seasonality). If None and no seasonality, then time_delta == 1

  • damped_factor (float) – Hyperparameter float value between [0, 1]. A smaller value further dampens the previous global trend value. Default, 0.8

  • global_trend_option ({ 'flat', 'linear', 'loglinear', 'logistic' }) – Transformation function for the shape of the forecasted global trend.

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

class orbit.models.dlt.DLTAggregated(**kwargs)

Bases: orbit.models.ets.ETSAggregated, orbit.models.dlt.BaseDLT

Concrete DLT model for aggregated posterior prediction

The model arguments are the same as ETSAggregated with some additional arguments

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • period (int) – Used to set time_delta as 1 / max(period, seasonality). If None and no seasonality, then time_delta == 1

  • damped_factor (float) – Hyperparameter float value between [0, 1]. A smaller value further dampens the previous global trend value. Default, 0.8

  • global_trend_option ({ 'flat', 'linear', 'loglinear', 'logistic' }) – Transformation function for the shape of the forecasted global trend.

  • aggregate_method ({ 'mean', 'median' }) – Method used to reduce parameter posterior samples

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • seasonality – Length of seasonality

  • seasonality_sm_input – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • aggregate_method – Method used to reduce parameter posterior samples

  • n_bootstrap_draws – Number of bootstrap samples to draw from the error part to generate the uncertainty. If -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

See also

class

~orbit.model.ets.BaseETS

orbit.models.ets.ETSAggregated

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_regression_coefs()
class orbit.models.dlt.DLTFull(**kwargs)

Bases: orbit.models.ets.ETSFull, orbit.models.dlt.BaseDLT

Concrete DLT model for full prediction

The model arguments are the same as ETSFull with some additional arguments

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • period (int) – Used to set time_delta as 1 / max(period, seasonality). If None and no seasonality, then time_delta == 1

  • damped_factor (float) – Hyperparameter float value between [0, 1]. A smaller value further dampens the previous global trend value. Default, 0.8

  • global_trend_option ({ 'flat', 'linear', 'loglinear', 'logistic' }) – Transformation function for the shape of the forecasted global trend.

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the initial MCMC or VI posterior samples. If -1, use the original posterior draws.

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • seasonality – Length of seasonality

  • seasonality_sm_input – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • n_bootstrap_draws – Number of bootstrap samples to draw from the initial MCMC or VI posterior samples. If -1, use the original posterior draws.

  • prediction_percentiles – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

See also

class

~orbit.model.ets.BaseETS

orbit.models.ets.ETSFull

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_regression_coefs(aggregate_method='mean')
class orbit.models.dlt.DLTMAP(estimator_type=<class 'orbit.estimators.stan_estimator.StanEstimatorMAP'>, **kwargs)

Bases: orbit.models.ets.ETSMAP, orbit.models.dlt.BaseDLT

Concrete DLT model for MAP (Maximum a Posteriori) prediction

The model arguments are the same as ETSMAP with some additional arguments

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int) – Length of seasonality

  • seasonality_sm_input (float) – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input (float) – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • regressor_col (list) – Names of regressor columns, if any

  • regressor_sign (list) – list with values { ‘+’, ‘-‘, ‘=’ } such that ‘+’ indicates regressor coefficient estimates are constrained to [0, inf). ‘-‘ indicates regressor coefficient estimates are constrained to (-inf, 0]. ‘=’ indicates regressor coefficient estimates can be any value between (-inf, inf). The length of regressor_sign must be the same length as regressor_col. If None, all elements of list will be set to ‘=’.

  • regressor_beta_prior (list) – list of prior float values for regressor coefficient betas. The length of regressor_beta_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regressor_sigma_prior (list) – list of prior float values for regressor coefficient sigmas. The length of regressor_sigma_prior must be the same length as regressor_col. If None, use non-informative priors.

  • regression_penalty ({ 'fixed_ridge', 'lasso', 'auto_ridge' }) – regression penalty method

  • lasso_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘lasso’

  • auto_ridge_scale (float) – float value between [0, 1], applicable only if regression_penalty == ‘auto_ridge’

  • slope_sm_input (float) – float value between [0, 1]. A larger value puts more weight on the current slope. If None, the model will estimate this value.

  • period (int) – Used to set time_delta as 1 / max(period, seasonality). If None and no seasonality, then time_delta == 1

  • damped_factor (float) – Hyperparameter float value between [0, 1]. A smaller value further dampens the previous global trend value. Default, 0.8

  • global_trend_option ({ 'flat', 'linear', 'loglinear', 'logistic' }) – Transformation function for the shape of the forecasted global trend.

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If set to be -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • seasonality – Length of seasonality

  • seasonality_sm_input – float value between [0, 1], applicable only if seasonality > 1. A larger value puts more weight on the current seasonality. If None, the model will estimate this value.

  • level_sm_input – float value between [0.0001, 1]. A larger value puts more weight on the current level. If None, the model will estimate this value.

  • n_bootstrap_draws – Number of bootstrap samples to draw from the error part to generate the uncertainty. If set to be -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

  • **kwargs (additional arguments passed into orbit.estimators.stan_estimator or orbit.estimators.pyro_estimator) –

See also

class

~orbit.model.ets.BaseETS

orbit.models.ets.ETSMAP

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_regression_coefs()

orbit.models.ktrlite module

class orbit.models.ktrlite.BaseKTRLite(seasonality=None, seasonality_fs_order=None, level_knot_scale=0.5, seasonal_initial_knot_scale=1.0, seasonal_knot_scale=0.1, span_level=0.1, span_coefficients=0.3, degree_of_freedom=30, level_knot_dates=None, level_knot_length=None, coefficients_knot_length=None, knot_location='mid_point', date_freq=None, **kwargs)

Bases: orbit.models.template.BaseTemplate

Base KTRLite model object with shared functionality for MAP method

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int, or list of int) – multiple seasonality

  • seasonality_fs_order (int, or list of int) – fourier series order for seasonality

  • level_knot_scale (float) – sigma for level; default to be .5

  • seasonal_initial_knot_scale (float) – scale parameter for seasonal regressors initial coefficient knots; default to be 1

  • seasonal_knot_scale (float) – scale parameter for seasonal regressors drift of coefficient knots; default to be 0.1.

  • span_level (float between (0, 1)) – window width to decide the number of windows for the level (trend) term. e.g., span 0.1 will produce 10 windows.

  • span_coefficients (float between (0, 1)) – window width to decide the number of windows for the regression term

  • of freedom (degree) – degree of freedom for error t-distribution

  • level_knot_dates (array like) – list of pre-specified dates for the level knots

  • level_knot_length (int) – the distance between every two knots for level

  • coefficients_knot_length (int) – the distance between every two knots for coefficients

  • knot_location ({'mid_point', 'end_point'}; default 'mid_point') – knot locations. When level_knot_dates is specified, this is ignored for level knots.

  • date_freq (str) – date frequency; if not supplied, pd.infer_freq will be used to imply the date frequency.

  • kwargs – To specify estimator_type or additional args for the specified estimator_type

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

static get_gap_between_dates(start_date, end_date, freq)
class orbit.models.ktrlite.KTRLiteMAP(estimator_type=<class 'orbit.estimators.stan_estimator.StanEstimatorMAP'>, **kwargs)

Bases: orbit.models.template.MAPTemplate, orbit.models.ktrlite.BaseKTRLite

Concrete KTRLite model for MAP (Maximum a Posteriori) prediction

This model only supports MAP estimator type

Parameters
  • response_col (str) – Name of response variable column, default ‘y’

  • date_col (str) – Name of date variable column, default ‘ds’

  • estimator_type (orbit.BaseEstimator) – Any subclass of orbit.BaseEstimator

  • seasonality (int, or list of int) – multiple seasonality

  • seasonality_fs_order (int, or list of int) – fourier series order for seasonality

  • level_knot_scale (float) – sigma for level; default to be .5

  • seasonal_initial_knot_scale (float) – scale parameter for seasonal regressors initial coefficient knots; default to be 1

  • seasonal_knot_scale (float) – scale parameter for seasonal regressors drift of coefficient knots; default to be 0.1.

  • span_level (float between (0, 1)) – window width to decide the number of windows for the level (trend) term. e.g., span 0.1 will produce 10 windows.

  • span_coefficients (float between (0, 1)) – window width to decide the number of windows for the regression term

  • of freedom (degree) – degree of freedom for error t-distribution

  • level_knot_dates (array like) – list of pre-specified dates for the level knots

  • level_knot_length (int) – the distance between every two knots for level

  • coefficients_knot_length (int) – the distance between every two knots for coefficients

  • knot_location ({'mid_point', 'end_point'}; default 'mid_point') – knot locations. When level_knot_dates is specified, this is ignored for level knots.

  • date_freq (str) – date frequency; if not supplied, pd.infer_freq will be used to imply the date frequency.

  • kwargs – To specify estimator_type or additional args for the specified estimator_type

  • n_bootstrap_draws (int) – Number of bootstrap samples to draw from the error part to generate the uncertainty. If set to be -1, will use the original posterior draw (no uncertainty).

  • prediction_percentiles (list) – List of integers of prediction percentiles that should be returned on prediction. To avoid reporting any confident intervals, pass an empty list

Notes

For attributes which are input by users and needed to mutate further downstream, we will introduce a new internal attribute with identical name except a prefix “_”. e.g. If x appear in the arg default as None and we need to impute by 0. we will have self._x = 0 downstream.

get_level_knots()
get_levels()
plot_lev_knots(path=None, is_visible=True, title='', fontsize=16, markersize=250, figsize=(16, 8))
Plot the fitted level knots along with the actual time series.
pathstr; optional

path to save the figure

is_visibleboolean

whether we want to show the plot. If called from unittest, is_visible might = False.

titlestr; optional

title of the plot

fontsizeint; optional

fontsize of the title

markersizeint; optional

knot marker size

figsizetuple; optional

figsize pass through to matplotlib.pyplot.figure()

Returns

Return type

matplotlib axes object

Module contents