A deep learning project for predicting regional and metropolitan electricity consumption in France for 2022, using historical weather data and electricity consumption from 2017-2021.
This project uses neural networks to forecast electricity demand across 13 French regions and 12 metropolitan areas. The models are trained on:
- Historical electricity consumption data (2017-2021)
- Weather measurements from multiple meteorological stations
- Temporal features (holidays, time of day, day of week, seasonality)
- Population-weighted regional aggregations
- MLP Model: A custom Multi-Layer Perceptron architecture optimized for electricity demand forecasting
- DRAGON AutoML: Neural Architecture Search (NAS) using the DRAGON library for automated model optimization
- Weather Processing: Sophisticated weather data aggregation and interpolation at 30-minute intervals
- Regional & Metropolitan Coverage: Predictions for 25 geographic entities across France
ElectricDemandForecast/
├── README.md # This file
├── requirements.txt # Python dependencies
├── prepare_data.py # Data initialization script
├── traitement_meteo.py # Weather data processing
├── model.py # Neural network architectures
├── train.py # Model training pipeline
├── predict.py # Prediction generation
├── dragon_model.py # DRAGON AutoML implementation
├── .gitignore # Git ignore rules
│
├── Data/ # Dataset files (created after setup)
│ ├── jours_feries_metropole.csv
│ ├── population_region.csv
│ ├── meteo.parquet
│ ├── X_train_final.csv
│ ├── X_2022_final.csv
│ └── y_train.csv
│
├── Model/ # Trained model artifacts
│ ├── pred_model.pth
│ ├── model_params.pt
│ ├── scaler_x.pt
│ ├── scaler_y.pt
│ ├── total_columns.pt
│ └── X_2022_prepared.csv
│
├── save/ # DRAGON model checkpoints
│ └── test_mutant/
│ └── best_model/
│ ├── x.pkl
│ └── best_model.pth
│
└── Solutions/ # Prediction outputs
└── pred.csv
- Python 3.8+
- Git LFS (for large data files)
- CUDA-compatible GPU (optional, but recommended for faster training)
-
Clone the repository
git clone https://github.com/EpsilonFO/ElectricDemandForecast.git cd ElectricDemandForecast -
Install dependencies
pip install -r requirements.txt
-
Initialize the project
python prepare_data.py
This script will:
- Pull large files using Git LFS
- Create necessary directories (
Model/,Solutions/,save/) - Move data files to their appropriate locations
Step 1: Train the model
python train.pyThis will:
- Load and preprocess training data
- Train the MLP model for 50 epochs
- Save the trained model to
Model/pred_model.pth - Save scalers and metadata for prediction
- Display training progress and final loss
Expected training time: 5-15 minutes (depending on hardware)
Step 2: Generate predictions
python predict.pyThis will:
- Load the trained model
- Generate predictions for 2022
- Save results to
Solutions/pred.csv
For automated neural architecture search:
python dragon_model.pyWarning: This approach is computationally intensive and can take several hours to complete. Pre-trained DRAGON models are included in save/test_mutant/best_model/ for convenience.
The DRAGON approach:
- Performs 200 iterations of architecture search
- Evaluates multiple neural network configurations
- Automatically selects the best performing architecture
- Saves the optimal model for inference
The custom MLP uses:
- Input layer: Scaled weather and temporal features
- Hidden layers with ELU, GELU, and Tanh activations
- Output layer: 25 neurons (13 regions + 12 metropolitan areas)
- Loss function: Region-wise RMSE with NaN handling
The DRAGON model implements:
- Dynamic neural architecture search
- DAG-based architecture encoding
- Mutant-UCB search algorithm
- Automatic hyperparameter optimization
The weather processing pipeline:
- Aggregates meteorological stations by region (averaging)
- Pivots data to create region-specific columns
- Resamples to 30-minute intervals with linear interpolation
- Adds holiday indicators
- Creates population-weighted national aggregates
- Removes daylight saving time anomalies
- Splits into training (2017-2021) and test (2022) sets
Processed features include:
- Temperature (
t), humidity (u), wind speed (ff) - Atmospheric pressure (
pres), precipitation (rr1,rr3,rr6) - Cloud coverage (
nnuage1,hnuage1) - And 10 additional meteorological variables
Temporal features:
- One-hot encoded: month, hour, weekday
- Binary: holiday indicator
- Continuous: minute, day
The model optimizes for regional RMSE (Root Mean Square Error), with special handling for:
- Missing values in consumption data
- Different consumption patterns across regions
- Seasonal and weekly variations
- Holiday effects
| File | Purpose |
|---|---|
prepare_data.py |
Initializes project structure and moves data files |
traitement_meteo.py |
Processes raw weather data into ML-ready format |
model.py |
Defines MLP and MetaArchi neural network classes |
train.py |
Training pipeline with data loading and model optimization |
predict.py |
Loads trained model and generates 2022 predictions |
dragon_model.py |
Implements Neural Architecture Search with DRAGON |
Issue: FileNotFoundError for data files
- Solution: Ensure you've run
prepare_data.pyand have Git LFS installed
Issue: CUDA out of memory
- Solution: Reduce
batch_sizeintrain.pyordragon_model.py
Issue: Slow training on CPU
- Solution: Consider using a GPU or reducing
num_epochs
Issue: DRAGON model takes too long
- Solution: Use the pre-trained DRAGON model in
save/test_mutant/best_model/
Core libraries:
- PyTorch: Deep learning framework
- pandas: Data manipulation
- numpy: Numerical computations
- scikit-learn: Data preprocessing and scaling
- dragon-autodl: Neural architecture search
- graphviz: Model visualization
See requirements.txt for complete list.