Skip to main content
# BATS and TBATS time series forecasting

Package provides BATS and TBATS time series forecasting methods described in:

> 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.


## Installation

From pypi:

```bash
pip install --index-url https://test.pypi.org/simple/ tbats
#pip install tbats
```

Import via:

```python
from tbats import BATS, TBATS
```

## Minimal working example:

```python
from tbats import TBATS
import numpy as np

np.random.seed(2342)
t = np.array(range(0, 160))
y = 5 * np.sin(t * 2 * np.pi / 7) + 2 * np.cos(t * 2 * np.pi / 30.5) + \
((t / 20) ** 1.5 + np.random.normal(size=160) * t / 50) + 10

# Create estimator
estimator = TBATS(seasonal_periods=[14, 30.5])

# Fit model
fitted_model = estimator.fit(y)

# Forecast 14 steps ahead
y_forecasted = fitted_model.forecast(steps=14)

# Summarize fitted model
print(fitted_model.summary())
```

Reading model details

```python
# Time series analysis
print(fitted_model.y_hat) # in sample prediction
print(fitted_model.resid) # in sample residuals
print(fitted_model.aic)

# Reading model parameters
print(fitted_model.params.alpha)
print(fitted_model.params.beta)
print(fitted_model.params.x0)
print(fitted_model.params.components.use_box_cox)
print(fitted_model.params.components.seasonal_harmonics)
```

See **examples** directory for more details

## For Contributors

Building package:

```bash
pip install -e .[dev]
```

Unit and integration tests:

```bash
python setup.py test
```

R forecast package comparison tests. Those DO NOT RUN with default test command, you need R forecast package installed:
```bash
python setup.py test_r
```

## Comparison to R implementation

Python implementation is meant to be as much as possible equivalent to R implementation in forecast package.

- BATS in R https://www.rdocumentation.org/packages/forecast/versions/8.4/topics/bats
- TBATS in R: https://www.rdocumentation.org/packages/forecast/versions/8.4/topics/tbats








Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tbats-1.0.1.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tbats-1.0.1-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file tbats-1.0.1.tar.gz.

File metadata

  • Download URL: tbats-1.0.1.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for tbats-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f356c1364486196d7e2d3133d415ce80532e14011a056e3826ddbf919bed823c
MD5 dcd673307eafeb2af16bef93fa8ce5f7
BLAKE2b-256 c1e38f9d0279a24d7b4dee2610a890a3dfa32c2ce524c40623d949109d4cec13

See more details on using hashes here.

File details

Details for the file tbats-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tbats-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for tbats-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8515716285bc8a5bccfc7b4e818706a5b5fe0e9ff1964966bc2be782ea97cbe
MD5 0534d4c13adf5aa9888769012095e27e
BLAKE2b-256 c23c7f80ea0781b49e78915fa734c260225bbc5904ce66791836f0d42c003286

See more details on using hashes here.

Release history Release notifications | RSS feed

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

This release

1.0.1 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page