This project implements a Transformer architecture using PyTorch to perform multivariate time-series forecasting on the Electricity Load Diagrams dataset (UCI, 2011–2014). The goal is to predict future energy consumption based on past patterns across multiple clients.
| Feature | Description |
|---|---|
| Data | Electricity usage from 370 clients (15-min intervals) |
| Model | Transformer (PyTorch, custom positional encoding) |
| Input Window | 24 hours of hourly consumption data |
| Prediction Horizon | Next 6 hours for all 10 clients |
| Metrics | MAE, RMSE, Visual Plots |
| Training Time | ~45 minutes on Colab GPU |
| File | Description |
|---|---|
load_data.py |
Loads and parses the .txt dataset |
preprocess_data.py |
Resamples, normalizes, and builds sequences |
model.py |
Transformer model with positional encoding |
train.py |
Training loop and validation logic |
evaluate.py |
Evaluation metrics and forecast visualizations |
best_transformer_model.pth |
Trained model checkpoint |
sample1.png sample2.png sample3.png |
True vs predicted plots |
requirements.txt |
Dependencies |
README.md |
This file |
The following plots show true vs predicted consumption for one client (Feature 0) across a 6-hour forecast.
| Sample 0 | Sample 1 | Sample 2 |
|---|---|---|
![]() |
![]() |
![]() |
- MAE:
0.0019 - RMSE:
0.0020
The model accurately captures patterns on real energy data, with very low error, even when trained on a subset of clients.
git clone https://github.com/your-username/transformer-time-series-forecasting.git
cd transformer-time-series-forecasting

