Multiple Series Forecasting with TimeGPT

TimeGPT can concurrently forecast multiple series at once. To do this, you must provide a DataFrame with multiple unique values defined under the unique_id column.

TimeGPT is a powerful forecasting solution that supports simultaneous predictions for multiple time series. This guide will walk you through setting up your Nixtla Client, loading data, and generating forecasts.

How It Works

Key Concept

Forecasting multiple series requires each observation to have a unique identifier under the unique_id column. TimeGPT automatically handles each series individually and returns forecasts for every unique series in your dataset.

1

1. Import Required Libraries

import pandas as pd
from nixtla import NixtlaClient
2

2. Initialize the Nixtla Client

Choose between the default Nixtla endpoint or an Azure AI endpoint.

nixtla_client = NixtlaClient(
    # defaults to os.environ.get("NIXTLA_API_KEY")
    api_key='my_api_key_provided_by_nixtla'
)
3

3. Prepare Your Data

# Load data
df = pd.read_csv(
    'https://raw.githubusercontent.com/Nixtla/transfer-learning-time-series/main/datasets/electricity-short.csv'
)
4

4. Forecast Multiple Series

# Forecast multiple series
forecast_df = nixtla_client.forecast(
    df=df,
    h=24
)

Available models in Azure AI
If using an Azure AI endpoint, set the model parameter explicitly to "azureai":

nixtla_client.forecast(
    ...,
    model="azureai"
)

Choosing the Right Model

If you’re using the public API, two models are supported: timegpt-1 and timegpt-1-long-horizon.
The default is timegpt-1. Check out the long horizon tutorial to learn when and how to apply timegpt-1-long-horizon.

For further details, visit the detailed tutorial:
Multiple series forecasting.