Long-horizon forecasting
Learn how to use the TimeGPT long-horizon model for forecasting far into the future with Nixtla client.
Long-horizon forecasting refers to predictions far into the future, typically exceeding two seasonal periods.
The exact threshold depends on data frequency. The further you forecast, the more uncertainty you face.
To tackle these extended prediction windows, Nixtla provides the specialized
timegpt-1-long-horizon
model in TimeGPT.
What is Long-Horizon Forecasting?
Long-horizon forecasting refers to predictions far into the future—typically exceeding two seasonal periods—where uncertainty grows significantly. For instance, forecasting 72 hours ahead is long-horizon for hourly data, two years ahead for monthly data, and over two weeks for daily data.
Key Challenge
Because these forecasts extend far into the future, they may be influenced by unforeseen factors not present in the initial dataset. Hence, long-horizon forecasts generally involve greater risk and uncertainty.
Solution: TimeGPT Model
To address unique challenges, Nixtla provides the specialized timegpt-1-long-horizon
model. Simply specify model="timegpt-1-long-horizon"
when calling nixtla_client.forecast
.
For Interactive Tutorials
Check out our Google Colab notebook to run all code cells interactively.
1. Import Packages
Start by installing and importing the required packages, then initialize the Nixtla client:
Use an Azure AI Endpoint
To use an Azure AI endpoint, specify the base_url
parameter as well:
nixtla_client = NixtlaClient(base_url="your azure ai endpoint", api_key="your api_key")
2. Load the Data
We’ll demonstrate long-horizon forecasting using the ETTh1 dataset, which measures oil temperatures and load variations on an electricity transformer in China. Here, we only forecast oil temperatures (y
):
We’ll set our horizon to 96 timestamps (4 days) for testing and use the previous 42 days as input to the model:
3. Forecasting with the Long-Horizon Model
TimeGPT’s timegpt-1-long-horizon
model is optimized for predictions far into the future. Specify it like so:
Models Available in Azure AI
If you access Azure AI services, set model="azureai"
:
nixtla_client.forecast(..., model="azureai")
Next, plot the forecast along with 90% confidence intervals:
TimeGPT Long-Horizon Forecast with 90% Confidence Intervals
4. Evaluation
Finally, assess forecast performance using Mean Absolute Error (MAE):
The model achieves a MAE of approximately 0.146
, indicating strong performance for these longer-range forecasts.
Congratulations!
You’ve successfully set up a long-horizon forecasting pipeline using TimeGPT. Continue exploring to optimize model parameters, add additional covariates, or integrate Azure AI endpoints.