Adding Exogenous Variables to Your Forecasts

Exogenous variables are additional features external to your target time series. They can significantly improve forecasting accuracy when historical and/or future values are available.

Example visualization of exogenous data trends.

1

1. Set up your environment

Install and import the required libraries:

Setup Environment
import pandas as pd
from nixtla import NixtlaClient

nixtla_client = NixtlaClient(
    api_key='my_api_key_provided_by_nixtla'
)
2

2. (Optional) Configure Azure AI endpoint

Use an Azure AI endpoint by setting the base_url argument:

Azure AI Endpoint Configuration
nixtla_client = NixtlaClient(
    base_url="your azure ai endpoint",
    api_key="your api_key"
)
3

3. Choose your exogenous variable approach

Depending on your use case, you can include only historical variables, only future variables, or both.

Historical Exogenous

Use past exogenous data for your forecast by including it in df.

Future Exogenous

Supply future values of exogenous variables to the X_df parameter to forecast beyond the historical period.

Historical + Future

Combine both historical and future exogenous data for maximum flexibility and accuracy.

Run on Azure AI Models
When using an Azure AI endpoint, set model="azureai":

Azure AI Model Example
nixtla_client.detect_anomalies(
    ...,
    model="azureai"
)

The public API supports two models: timegpt-1 and timegpt-1-long-horizon.
By default, timegpt-1 is used.

For more details on exogenous features and long-horizon forecasting, see: