Multiple Series Forecasting

TimeGPT provides straightforward multi-series forecasting. This approach enables you to forecast several time series concurrently rather than focusing on just one.

• Forecasts are univariate: TimeGPT does not directly account for interactions between target variables in different series.
• Exogenous Features: You can still include additional explanatory (exogenous) variables like categories, numeric columns, holidays, or special events to enrich the model.

Given these capabilities, TimeGPT can be fine-tuned to your own datasets for precise and efficient forecasting. Below, let’s see how to use multiple series forecasting in practice:

Key Concept

Global models like TimeGPT can handle multiple series in a single training session and produce a separate forecast for each.

Benefit

Multi-series learning improves efficiency, leveraging shared patterns across series that often lead to better forecasts.

1

1. Install and import packages

Install and import the required libraries, then initialize the Nixtla client.

Nixtla Client Initialization
import pandas as pd
from nixtla import NixtlaClient

nixtla_client = NixtlaClient(
    api_key='my_api_key_provided_by_nixtla'
)
2

2. Load the data

You can now load the electricity prices dataset from various European markets. TimeGPT automatically treats it as multiple series based on the unique_id column.

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

Now, let’s visualize the data using the NixtlaClient.plot() method.

Plot Electricity Series
nixtla_client.plot(df)

Electricity Markets Series Plot

3

3. Forecast multiple series

Pass the DataFrame to the forecast() method. TimeGPT automatically handles each unique series based on unique_id.

Forecast Multiple Series
timegpt_fcst_multiseries_df = nixtla_client.forecast(
    df=df,
    h=24,
    level=[80, 90]
)
timegpt_fcst_multiseries_df.head()

When using Azure endpoints, specify model="azureai". By default, the timegpt-1 model is used. See the details here for available models.

Visualize the forecasts:

Plot Forecasts
nixtla_client.plot(
    df,
    timegpt_fcst_multiseries_df,
    max_insample_length=365,
    level=[80, 90]
)

Multiple Series Forecast Plot

4

4. Generate historical forecasts

You can also produce historical forecasts (including prediction intervals) by setting add_history=True. This allows you to compare previously observed values with model predictions.

Historical Forecasts with Prediction Intervals
historical_fcst_df = nixtla_client.forecast(
    df=df,
    h=24,
    level=[80, 90],
    add_history=True
)
historical_fcst_df.head()

Congratulations! You have successfully performed multi-series forecasting with TimeGPT, taking advantage of its global modeling approach.