Add categorical variables
Learn how to create and use custom categorical variables with SpecialDates in TimeGPT forecasting.
TimeGPT supports categorical variables to enhance your forecasts. This document shows you how to create and use custom categorical variables with SpecialDates
.
Key Concept: Categorical Variables
Categorical variables are non-numeric data points that help distinguish different groups or conditions in your dataset. For example, holiday labels or season markers can be treated as categorical variables in time series forecasting.
Key Concept: SpecialDates
SpecialDates
is a utility in Nixtla that allows you to define specific date-based labels (e.g., holiday periods, special events).
These labels can then be merged into your main dataset as additional columns for forecasting.
Step 1: Import the Libraries
Step 2: Set Up the Nixtla Client
You can either use the default endpoint or an Azure AI endpoint. Select the appropriate tab below:
Use an Azure AI endpoint
When using an Azure AI endpoint, set the base_url
argument as shown below.
Step 3: Read the Data
Step 4: Create Categorical Variables
Use SpecialDates
to define holiday or seasonal periods you want to label in your time series.
Step 5: Forecast with Categorical Variables
Below is an example of the forecast process logs. These messages show up when you run the forecast, including any warnings about exogenous variables or horizon lengths.
Available models in Azure AI
If you use an Azure AI endpoint, set model="azureai"
explicitly:
The public API supports two models: timegpt-1
and timegpt-1-long-horizon
.
By default, timegpt-1
is used. See this tutorial for more details on using the timegpt-1-long-horizon
model.