Skip to main content

Introduction

Energy demand forecasting is critical for grid operations, resource allocation, and infrastructure planning. Despite advances in methods, predicting consumption remains challenging due to weather, economic activity, and consumer behavior. This tutorial demonstrates how TimeGPT simplifies in-zone electricity forecasting while delivering superior accuracy and speed. We will use the PJM Hourly Energy Consumption dataset covering five regions from October 2023 to September 2024.

What You’ll Learn

  • How to load and prepare energy consumption data
  • How to generate 4-day ahead forecasts with TimeGPT
  • How to evaluate forecast accuracy using MAE and sMAPE
  • How TimeGPT compares to deep learning models like N-HiTS
The procedures in this tutorial apply to many time series forecasting scenarios beyond energy demand.

How to Use TimeGPT to Forecast Energy Demand

Open In Colab

Step 1: Initial Setup

Install and import required packages, then create a NixtlaClient instance to interact with TimeGPT.

Step 2: Load Energy Consumption Data

Load the energy consumption dataset and convert datetime strings to timestamps.
unique_iddsy
0AP-AP2023-10-01 04:00:00+00:004042.513
1AP-AP2023-10-01 05:00:00+00:003850.067
Plot the data series to visualize seasonal patterns.
Seasonal patterns in energy consumption showing daily and weekly cycles in PJM electricity demand data

Step 3: Generate Energy Demand Forecasts with TimeGPT

We’ll split our dataset into:
  • A training/input set for model calibration
  • A testing set (last 4 days) to validate performance
TimeGPT energy demand forecast with 90% confidence intervals compared to actual electricity consumption

Step 4: Evaluate Forecast Accuracy

Compute accuracy metrics (MAE and sMAPE) for TimeGPT.

Step 5: Forecast with N-HiTS

For comparison, we train and forecast using the deep-learning model N-HiTS.

Step 6: Evaluate N-HiTS

Compute accuracy metrics (MAE and sMAPE) for N-HiTS.

Conclusion

TimeGPT demonstrates substantial performance improvements over N-HiTS across key metrics:
  • Accuracy: 18.6% lower MAE (882.6 vs 1084.7)
  • Error Rate: 31.1% lower sMAPE
  • Speed: 90% faster predictions (4.3 seconds vs 44 seconds)
These results make TimeGPT a powerful tool for forecasting energy consumption and other time-series tasks where both accuracy and speed are critical. Experiment with the parameters to further optimize performance for your specific use case. Ready to explore more forecasting applications? Check out these guides: Learn more about TimeGPT capabilities for time series prediction.