Prediction Intervals
Learn how to create robust prediction intervals to quantify uncertainty in forecasts.
Prediction Intervals
In forecasting, we are often interested in the distribution of predictions rather than just point predictions, because we need a clear notion of forecast uncertainty.
Prediction intervals present a specific range within which the actual forecast values are expected to fall. For example, a 95% prediction interval means that we expect the future true value to lie within this range 95 times out of 100. Wider intervals correspond to greater uncertainty, while narrower intervals indicate higher forecast confidence.
Using TimeGPT, you can easily produce forecast distributions and derive prediction intervals at customized confidence levels. TimeGPT leverages conformal prediction to generate these intervals.
Key Concepts
Forecast Uncertainty
Prediction intervals quantify the uncertainty of a forecast. They help you assess the risk of under- or over-estimating future values.
Conformal Prediction
TimeGPT uses conformal prediction techniques to generate meaningful prediction intervals. This allows valid coverage under minimal assumptions.
Step 1: Import Packages
Import the required packages and initialize the Nixtla client.
If you want to use an Azure AI endpoint, set the base_url
as shown below.
Step 2: Load Data
Load the dataset:
timestamp | value | |
---|---|---|
0 | 1949-01-01 | 112 |
1 | 1949-02-01 | 118 |
2 | 1949-03-01 | 132 |
3 | 1949-04-01 | 129 |
4 | 1949-05-01 | 121 |
Step 3: Forecast with Prediction Intervals
To forecast using TimeGPT with customized prediction intervals, specify level
as a list of desired confidence levels:
Below is sample log output indicating the process steps (input validation, preprocessing, endpoint calls, etc.).
Forecast with predicted intervals at multiple levels
To use an Azure AI endpoint, set model="azureai"
.
For the public API, supported models include:
-
timegpt-1
(default) -
timegpt-1-long-horizon
See the Long Horizon Forecasting Tutorial.
Use wider intervals for critical predictions to handle uncertainty carefully, and narrower intervals if exact predictions are less critical.
Step 4: Historical Forecast
Prediction intervals are a powerful tool for understanding the uncertainty inherent in forecasting. Adjust the confidence levels (e.g., 80%, 90%, 95%, 99.7%) based on how conservative or liberal you want your estimates.