Temporal Hierarchical Forecasting with TimeGPT
Learn how to combine forecasts at different time frequencies to improve accuracy.
This tutorial demonstrates how to use TimeGPT for temporal hierarchical forecasting. We will forecast at hourly and aggregated 2-hourly frequency levels, then apply temporal reconciliation techniques to improve overall precision.
1. Load and Process Data
Here, we prepare our dataset by reading it into a pandas DataFrame, splitting it into training and testing subsets, and initializing the NixtlaClient.
The below output shows the number of rows and columns for our training and testing data, respectively.
Plot the training and test data:
Visualization of the last 200 observations in the training dataset and 48 observations in the test dataset.
2. Temporal Aggregation
In this step, we define and apply temporal aggregation to create separate frequency levels (1-hour and 2-hour periods).
3. Computing Base Forecasts (TimeGPT)
TimeGPT can produce forecasts at multiple frequencies with minimal configuration. We forecast for each temporal aggregation, then concatenate the predictions.
4. Forecast Reconciliation
By default, forecasts at multiple frequencies may not align. Use a reconciliation method to ensure consistent predictions across all hierarchies.
5. Evaluation
We use MAE to measure accuracy of the reconciled forecasts. This process can be extended to other metrics or used for hyperparameter tuning.
6. Forecast Visualization
Visualize reconciled forecasts to verify alignment at each frequency. This is especially helpful for spotting inconsistencies or anomalies.
Key Takeaways
- TimeGPT can efficiently handle multiple frequency levels.
- Temporal reconciliation ensures consistent forecasts across hierarchies.
- Evaluating forecasts at each frequency level helps refine models.
Conclusion
In this tutorial, we demonstrated:
- Creating multi-frequency forecasts with TimeGPT.
- Temporal reconciliation to improve forecast accuracy and ensure coherence across different time aggregations.
For further exploration, consider experimenting with different metrics, applying alternative reconciliation methods, or extending the forecasting horizon for more complex forecasting needs.