TBATS for Time Series Forecasting

1.1.3 · active · verified Sun Apr 12

tbats is a Python library implementing BATS and TBATS models for time series forecasting, known for handling complex seasonality and Box-Cox transformations. The current version is 1.1.3, and it receives updates primarily for bug fixes, dependency upgrades, and occasional feature enhancements, with an irregular release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize, fit, and forecast with a TBATS model. It generates a sample time series with trend and seasonality, then applies TBATS with Box-Cox transformation and ARMA errors to predict future values. `n_jobs=1` is used to prevent parallel processing in simple examples.

import numpy as np
from tbats import TBATS

# Generate some example time series data with seasonality
np.random.seed(42)
n_points = 100
seasonal_period = 24 # Daily seasonality
t = np.arange(n_points)
y = 50 + 2 * t + 10 * np.sin(2 * np.pi * t / seasonal_period) + np.random.normal(0, 5, n_points)

# Create and fit the TBATS model
estimator = TBATS(seasonal_periods=[seasonal_period],
                  use_box_cox=True,
                  use_trend=True,
                  use_damped_trend=False,
                  use_arma_errors=True,
                  n_jobs=1)
model = estimator.fit(y)

# Make a forecast
forecast = model.forecast(steps=10)

print("Original series (last 5 points):", y[-5:])
print("Forecasted values (next 10 steps):", forecast)

view raw JSON →