Energy-UK - Time Series Models for Solar Energy Consumption and Generation Forecasting in the United Kingdom
Energy-UK is a comprehensive machine learning project that provides accurate forecasts of solar energy consumption and generation across the United Kingdom. The system utilizes advanced time series models (LSTM and GRU networks) trained on historical energy data and weather patterns to predict:
- National electricity demand (
nd
) - Solar energy generation (
solarenergy
)
The project includes complete ML pipelines from data preparation to model deployment on Azure ML, with integrated monitoring through MLflow.
- Dual Forecasting Models:
- LSTM network for energy consumption prediction
- GRU network for solar generation forecasting
- Multi-modal Data Integration:
- Energy grid operational data
- Meteorological measurements (solar radiation, cloud cover, etc.)
- Production-Ready Infrastructure:
- MLflow experiment tracking
- Azure ML deployment pipelines
- Scalable inference endpoints
- Automated feature engineering pipelines
- Dynamic windowing for time series data
- Hyperparameter tracking with MLflow
- Model versioning and registry
- CI/CD-ready deployment scripts
- GPU-enabled system recommended (CUDA 12.x compatible)
- Minimum 16GB RAM
- 10GB free disk space
Python 3.10+
TensorFlow 2.17.1
Azure ML SDK
MLflow 2.11.3
Complete dependency list available in:
requirements.txt
(1,200+ packages)- Conda environment specifications
- UK National Grid historical data (provided in
uk_electricity.csv
) - Meteorological records (provided in
uk_weather.csv
)
-
Clone repository:
git clone https://github.com/CarlosYazid/Energy-UK.git cd Energy-UK
-
Create Conda environment:
conda env create -f environment.yml conda activate uk-energy-env
-
Install remaining dependencies:
pip install -r requirements.txt
-
Set environment variables:
export AZURE_SUBSCRIPTION_ID=<your-subscription-id> export AZURE_RESOURCE_GROUP=<your-resource-group> export AZURE_WORKSPACE_NAME=<workspace-name>
-
Authenticate using Azure CLI:
az login az account set --subscription $AZURE_SUBSCRIPTION_ID
Energy Consumption Model:
jupyter nbconvert --to python "Training-Energy-Comsumption.ipynb" && python Training-Energy-Comsumption.py
Solar Generation Model:
jupyter nbconvert --to python "Training-Generation-Energy.ipynb" && python Training-Generation-Energy.py
-
Configure deployment settings in
Deploy.py
:model_deployment = ManagedOnlineDeployment( name="UKEnergyModelDeploy", endpoint_name="uk-energy-model-endpoint", instance_type="Standard_DS4_v2", instance_count=1 )
-
Execute deployment:
jupyter nbconvert --to python "Deploy.ipynb" && python Deploy.py
Sample request to deployed endpoint:
import requests
endpoint = "https://uk-energy-model-endpoint.azureml.net/score"
data = {"input_data": [...]} # Your time series window
response = requests.post(endpoint, json=data, headers={"Authorization": "Bearer API_KEY"})
print(response.json())
# Load saved model
model = mlflow.keras.load_model("models/tensorflow_series_UK_energy_v2")
# Make prediction
forecast = model.predict(X_test)
from scripts.inference_score import run
with open("batch_data.json") as f:
results = run(f.read())
Energy-UK/
├── .gitignore
├── requirements.txt # Full Python dependencies
├── scripts/
│ └── inference_score.py # Scoring script for deployment
├── Deploy.ipynb # Azure ML deployment configuration
├── Training-Energy-Comsumption.ipynb # LSTM model for energy demand
├── Training-Generation-Energy.ipynb # GRU model for solar generation
├── uk_electricity.csv # Grid operational data
├── uk_weather.csv # Meteorological records
├── training_validation_loss.png # Image of training validation
└── environment.yml # Conda environment spec
POST /score
- Input: JSON array of time series windows
- Output: Predicted values with confidence intervals
Consumption Model:
ModelSignature(
inputs=Schema([
TensorSpec(np.int16, (-1,), "settlement_period"),
TensorSpec(np.float16, (-1,), "period_hour"),
# ... additional features
]),
outputs=Schema([
TensorSpec(np.float32, (-1,), "nd")
])
)
- Fork the repository
- Create feature branch (
git checkout -b feature/your-feature
) - Commit changes (
git commit -m 'Add some feature'
) - Push to branch (
git push origin feature/your-feature
) - Open Pull Request
- PEP 8 compliance
- Type hints for all functions
- MLflow experiment tracking for all model changes
Issue | Solution |
---|---|
CUDA errors | Verify CUDA 12.x and cuDNN compatibility |
Azure auth failures | Run az login and check subscription |
Shape mismatches | Validate window_size parameter matches training |
- Initial release with LSTM and GRU models
- Azure ML deployment pipelines
- MLflow experiment tracking
This project is licensed under the MIT License - see the LICENSE file for details.
Project Maintainer: Carlos Yazid
Email: contact@carlospadilla.co
Issue Tracking: Issues