Skip to content

TBATS

TBATS

class TBATS(use_box_cox=None, box_cox_bounds=(0, 1), use_trend=None, use_damped_trend=None, sp=None, use_arma_errors=True, show_warnings=True, n_jobs=None, multiprocessing_start_method='spawn', context=None)[source]

TBATS forecaster for time series with multiple seasonality.

Wrapping implementation in [1] of method proposed in [2]. See [3] for blogpost by a creator of [1] giving brief explanation of the TBATS model. See [4] for discussion on multiple seasonalities and discussion of how TBATS compares with some other approaches.

TBATS is acronym for:

  • Trigonometric seasonality

  • Box-Cox transformation

  • ARMA errors

  • Trend

  • Seasonal components

TBATS was designed to forecast time series with multiple seasonal periods. For example, daily data may have a weekly pattern as well as an annual pattern. Or hourly data can have three seasonal periods: a daily pattern, a weekly pattern, and an annual pattern.

In TBATS, a Box-Cox transformation is applied to the original time series, and then this is modelled as a linear combination of an exponentially smoothed trend, a seasonal component and an ARMA component. The seasonal components are modelled by trigonometric functions via Fourier series. TBATS conducts some hyper-parameter tuning (e.g. which of these components to keep and which to discard) using AIC.

Parameters:
use_box_cox: bool or None, optional (default=None)

If Box-Cox transformation of original series should be applied. When None both cases shall be considered and better is selected by AIC.

box_cox_bounds: tuple, shape=(2,), optional (default=(0, 1))

Minimal and maximal Box-Cox parameter values.

use_trend: bool or None, optional (default=None)

Indicates whether to include a trend or not. When None both cases shall be considered and better is selected by AIC.

use_damped_trend: bool or None, optional (default=None)

Indicates whether to include a damping parameter in the trend or not. Applies only when trend is used. When None both cases shall be considered and better is selected by AIC.

sp: Iterable or array-like of floats, optional (default=None)

Abbreviation of “seasonal periods”. The length of each of the periods (amount of observations in each period). Accepts int and float values here. When None or empty array, non-seasonal model shall be fitted.

use_arma_errors: bool, optional (default=True)

When True BATS will try to improve the model by modelling residuals with ARMA. Best model will be selected by AIC. If False, ARMA residuals modeling will not be considered.

show_warnings: bool, optional (default=True)

If warnings should be shown or not. Also see Model.warnings variable that contains all model related warnings.

n_jobs: int, optional (default=None)

How many jobs to run in parallel when fitting BATS model. When not provided BATS shall try to utilize all available cpu cores.

multiprocessing_start_method: str, optional (default=’spawn’)

How threads should be started. See also:

https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

context: abstract.ContextInterface, optional (default=None)

For advanced users only. Provide this to override default behaviors

Attributes:
cutoff

Cut-off = “present time” state of forecaster.

fh

Forecasting horizon that was passed.

is_fitted

Whether fit has been called.

state

State of the estimator.

See also

BATS
StatsForecastAutoTBATS

References

[2]

De Livera, A.M., Hyndman, R.J., & Snyder, R. D. (2011), Forecasting time series with complex seasonal patterns using exponential smoothing, Journal of the American Statistical Association, 106(496), 1513-1527. DOI: https://doi.org/10.1198/jasa.2011.tm09771

[4]

R.J. Hyndman, G. Athanasopoulos. Forecasting: Principles and Practice. https://otexts.com/fpp2/complexseasonality.html

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.tbats import TBATS
>>> y = load_airline()
>>> forecaster = TBATS(
...     use_box_cox=False,
...     use_trend=False,
...     use_damped_trend=False,
...     sp=12,
...     use_arma_errors=False,
...     n_jobs=1)
>>> forecaster.fit(y)
TBATS(...)
>>> y_pred = forecaster.predict(fh=[1,2,3])

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(y[, X, fh])

Fit forecaster to training data.

fit_predict(y[, X, fh, X_pred])

Fit and forecast time series at future horizon.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_pretrained_params([deep])

Get pretrained parameters of this estimator.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

predict([fh, X])

Forecast time series at future horizon.

predict_interval([fh, X, coverage])

Compute/return prediction interval forecasts.

predict_proba([fh, X, marginal])

Compute/return fully probabilistic forecasts.

predict_quantiles([fh, X, alpha])

Compute/return quantile forecasts.

predict_residuals([y, X])

Return residuals of time series forecasts.

predict_var([fh, X, cov])

Compute/return variance forecasts.

pretrain(y[, X, fh])

Pre-train forecaster on panel (global) data.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

score(y[, X, fh])

Scores forecast against ground truth, using MAPE (non-symmetric).

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

update(y[, X, update_params])

Update cutoff value and, optionally, fitted parameters.

update_predict(y[, cv, X, update_params, ...])

Make predictions and update model iteratively over the test set.

update_predict_single([y, fh, X, update_params])

Update model with new data and make forecasts.