YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Machine Learning & Deep Learning Models for Renewable Energy Forecasting

πŸ‘¨β€πŸ’» Author

Momen

This repository contains three machine learning and deep learning implementations for renewable energy prediction and forecasting.

The original approaches were studied and modified, organized, and adapted by Momen to improve the data preprocessing, model training workflow, evaluation, visualization, and overall experimentation process.


πŸ“Œ Project Overview

The project focuses on using Machine Learning and Deep Learning techniques to analyze and predict renewable energy generation.

The three notebooks cover different forecasting scenarios:

  1. Wind Power Prediction using Random Forest
  2. Solar Irradiance Prediction using Random Forest & XGBoost
  3. Solar PV Nowcasting using a CNN-based SUNSET Model

The project demonstrates a progression from traditional ensemble machine learning models to deep learning-based image forecasting.


πŸ“‚ Models

Model Task Algorithm Target
Model 1 Wind Power Prediction Random Forest Regressor Power
Model 2 Solar Irradiance Prediction Random Forest + XGBoost G(i)
Model 3 Solar PV Nowcasting CNN + Ensemble Learning PV Output

1. 🌬️ Wind Power Prediction β€” Random Forest

🎯 Objective

The first notebook predicts wind power generation using meteorological and temporal features.

The main goal is to learn the relationship between environmental conditions such as:

  • Temperature
  • Wind speed
  • Wind gusts
  • Time-related information

and the generated wind power.

The target variable is:

Power
πŸ“Š Dataset

The model uses a wind-energy dataset stored in:

Wind.csv

The dataset contains weather-related measurements and power generation information.

The data includes features such as:

temperature_2m
windspeed_10m
windgusts_10m
City
Date
Time
Power
πŸ”§ Data Preprocessing

The notebook performs several preprocessing steps.

Date & Time Processing

The separate Date and Time columns are combined into a single datetime representation.

Temporal features are then extracted:

Year
Month
Day
Hour
DayOfWeek

The original date/time columns are removed after feature extraction.

πŸ” Exploratory Data Analysis

The notebook includes several visualizations to understand the dataset:

Power Distribution

A histogram with KDE is used to analyze the distribution of generated power.

Correlation Heatmap

A correlation matrix is generated to investigate relationships between numerical variables.

Feature Relationships

Pair plots are used to visualize the relationship between:

temperature_2m
windspeed_10m
windgusts_10m
Power
🧠 Model

The main model is:

RandomForestRegressor

Configuration:

n_estimators = 200
max_depth = 10
random_state = 42
n_jobs = -1

Random Forest was selected because it can model nonlinear relationships between weather conditions and power generation.

βš™οΈ Feature Scaling

StandardScaler is applied to the input features before training.

The data is split into:

80% Training
20% Testing
πŸ“ Evaluation Metrics

The model is evaluated using:

RMSE

Root Mean Squared Error measures the average magnitude of prediction errors.

MAE

Mean Absolute Error measures the average absolute difference between actual and predicted values.

RΒ² Score

Measures how well the model explains the variance in the target variable.

πŸ“ˆ Visualizations

The notebook generates:

Actual vs Predicted Power plot
Random Forest Feature Importance plot
Power distribution
Correlation heatmap
Feature relationship plots
2. β˜€οΈ Solar Irradiance Prediction β€” Random Forest & XGBoost
🎯 Objective

The second notebook focuses on predicting solar irradiance using weather, geographic, temporal, and city-level information.

The target variable is:

G(i)

The goal is to estimate solar irradiance using machine learning models and compare the performance of:

Random Forest
XGBoost
πŸ“Š Dataset

The notebook uses a PVGIS-based dataset containing European city solar data.

Example filename:

europe_cities_pvgis_data_slope_45_azimuth_180(in).csv

The dataset includes information related to:

City
Time
Solar irradiance
Weather/environmental measurements
Geographic/solar system characteristics
πŸ•’ Temporal Feature Engineering

The original time information is converted into a datetime representation.

The following features are extracted:

Month
Day
Hour
Minute

To better represent the cyclical nature of time, sinusoidal encoding is applied.

Hour Encoding
Hour_sin
Hour_cos
Month Encoding
Month_sin
Month_cos

This allows the model to understand that:

23:00

and

00:00

are close in time rather than being completely different numerical values.

πŸ™οΈ City Encoding

The dataset contains a categorical City feature.

Instead of one-hot encoding potentially large numbers of categories, the notebook uses:

TargetEncoder

from:

category_encoders

This converts city information into numerical representations based on the target variable.

πŸ”„ Preprocessing Pipeline

A Scikit-learn ColumnTransformer is used to create a preprocessing pipeline.

Categorical Features
City β†’ TargetEncoder
Numerical Features
Numerical features β†’ StandardScaler

This preprocessing is integrated directly into the model pipeline.

🌲 Random Forest Optimization

The Random Forest model is optimized using:

RandomizedSearchCV

The search explores parameters such as:

n_estimators
max_depth
min_samples_split
min_samples_leaf

To reduce computational requirements, a training sample of:

30,000 samples

is used during hyperparameter optimization.

The best estimator is then evaluated against the complete test set.

πŸš€ XGBoost Optimization

The second model is:

XGBRegressor

Hyperparameter optimization is also performed using:

RandomizedSearchCV

The search explores:

n_estimators
max_depth
learning_rate
subsample

The optimized model is then evaluated on the test dataset.

πŸ“ Evaluation

Both models are evaluated using:

MAE
RMSE
RΒ²

A performance summary is generated to compare the two approaches.

Example structure:

Model	MAE	RMSE	RΒ²
Random Forest	...	...	...
XGBoost	...	...	...

The actual values depend on the dataset and execution environment.

πŸ” Feature Importance

Feature importance is extracted from both:

Random Forest
XGBoost

The notebook visualizes the top features contributing to solar irradiance prediction.

This helps identify which environmental and temporal variables have the strongest influence on the prediction.

πŸ“Š Error Analysis

Prediction errors are calculated as:

True Value - Predicted Value

The error distributions of Random Forest and XGBoost are visualized using histograms and KDE curves.

This provides additional insight into:

Prediction bias
Error distribution
Model stability
Differences between the two algorithms
3. 🌞 SUNSET Solar PV Nowcasting β€” CNN
🎯 Objective

The third notebook implements a deep learning-based solar photovoltaic (PV) nowcasting model.

Unlike the previous models, which primarily use tabular weather and temporal data, this model works with image-based solar observations.

The goal is to predict near-term PV power output from image sequences and related PV data.

The implementation is based on the SUNSET nowcasting approach, using a Convolutional Neural Network (CNN).

πŸ“Š Dataset

The model works with an HDF5 dataset:

nowcast_dataset.hdf5

The data contains separate training/validation and testing groups.

The main inputs include:

images_log
pv_log

The image data is processed as:

64 Γ— 64 Γ— 24

where the 24 channels represent the image information available to the model.

The corresponding PV output is used as the regression target.

🧠 CNN Architecture

The model is implemented using:

TensorFlow
Keras

The architecture contains:

Input
64 Γ— 64 Γ— 24
Convolution Block 1
Conv2D
BatchNormalization
MaxPooling2D

with:

24 filters
3 Γ— 3 kernel
Convolution Block 2
Conv2D
BatchNormalization
MaxPooling2D

with:

48 filters
3 Γ— 3 kernel
Fully Connected Layers

After convolution and pooling:

Flatten
↓
Dense(1024)
↓
Dropout(0.4)
↓
Dense(1024)
↓
Dropout(0.4)
↓
Dense(1)

The final neuron produces the predicted PV output.

βš™οΈ Training Configuration

The model uses:

Optimizer: Adam
Learning Rate: 3e-6
Loss Function: Mean Squared Error
Batch Size: 256
Maximum Epochs: 200

Early stopping is used to prevent unnecessary training when validation performance stops improving.

πŸ”„ 10-Fold Cross-Validation

The notebook uses:

10-Fold Cross-Validation

However, instead of randomly splitting individual timestamps, the data is shuffled in day blocks.

This is particularly important for time-dependent solar forecasting because samples from the same day can be highly correlated.

The workflow is:

Timestamp Data
      ↓
Day-Based Blocks
      ↓
Shuffle Blocks
      ↓
10-Fold Cross Validation
      ↓
Training / Validation
πŸ’Ύ Model Checkpoints

The best model from every fold is saved separately.

The structure is approximately:

model_output/
└── SUNSET_nowcast_2017_2019_data/
    β”œβ”€β”€ repetition_1/
    β”‚   └── best_model_repitition_1.h5
    β”œβ”€β”€ repetition_2/
    β”‚   └── best_model_repitition_2.h5
    β”œβ”€β”€ ...
    └── repetition_10/
        └── best_model_repitition_10.h5

Training and validation histories are also stored for later analysis.

🀝 Ensemble Prediction

After training 10 models, predictions from all models are combined.

The final prediction is calculated using the mean:

Ensemble Prediction =
Mean(Prediction Model 1 ... Prediction Model 10)

This ensemble approach helps reduce the variance of individual models and provides a more stable final prediction.

β˜€οΈ Sunny vs Cloudy Evaluation

The test dataset is further divided into:

Sunny Days
Cloudy Days

The model is evaluated separately on both conditions.

The notebook calculates:

Sunny RMSE
Cloudy RMSE
Overall RMSE

Sunny MAE
Cloudy MAE
Overall MAE

This is particularly useful because cloud conditions can introduce significant uncertainty into solar PV forecasting.

πŸ“ˆ Visualization

The notebook compares:

Ground Truth PV Output
vs
SUNSET Nowcast Prediction

for both sunny and cloudy days.

Each visualization includes:

Actual PV output
Predicted PV output
RMSE
MAE
Hour of the day

This allows the performance of the model to be analyzed throughout the day.

🧰 Technologies & Libraries
Machine Learning
Python
NumPy
Pandas
Scikit-learn
Random Forest
XGBoost
SciPy
Deep Learning
TensorFlow
Keras
CNN
Adam Optimizer
Data Processing
HDF5
h5py
category_encoders
StandardScaler
Target Encoding
Visualization
Matplotlib
Seaborn
πŸ—οΈ Overall Architecture
                 Renewable Energy Data
                         β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚              β”‚              β”‚
          β–Ό              β–Ό              β–Ό
      Wind Data     Solar Data      Image Data
          β”‚              β”‚              β”‚
          β–Ό              β–Ό              β–Ό
   Feature Engineering  Time Encoding  Image Processing
          β”‚              β”‚              β”‚
          β–Ό              β–Ό              β–Ό
   Random Forest     RF + XGBoost       CNN
          β”‚              β”‚              β”‚
          β–Ό              β–Ό              β–Ό
     Power Output   Solar Irradiance   PV Nowcasting
          β”‚              β”‚              β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
                 Performance Analysis
                         β”‚
                  β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
                  β–Ό             β–Ό
                 MAE           RMSE
                                β”‚
                                β–Ό
                                RΒ²
πŸ“ Suggested Repository Structure
Renewable-Energy-Forecasting/
β”‚
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ wind_power_random_forest.ipynb
β”‚   β”œβ”€β”€ solar_irradiance_rf_xgboost.ipynb
β”‚   └── sunset_pv_nowcasting_cnn.ipynb
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ Wind.csv
β”‚   β”œβ”€β”€ europe_cities_pvgis_data_slope_45_azimuth_180(in).csv
β”‚   └── data_nowcast/
β”‚       β”œβ”€β”€ nowcast_dataset.hdf5
β”‚       β”œβ”€β”€ times_trainval.npy
β”‚       └── times_test.npy
β”‚
β”œβ”€β”€ model_output/
β”‚   └── SUNSET_nowcast_2017_2019_data/
β”‚
└── README.md
πŸš€ How to Run
1. Clone the repository
git clone <YOUR_REPOSITORY_URL>
cd Renewable-Energy-Forecasting
2. Install dependencies
pip install numpy pandas matplotlib seaborn scikit-learn scipy
pip install xgboost category_encoders
pip install tensorflow h5py
3. Prepare the datasets

Place the required datasets inside the appropriate data/ directories.

Update the dataset paths in the notebooks if necessary.

For example:

df = pd.read_csv("path/to/Wind.csv")
⚠️ Notes

The notebooks were originally developed for specific datasets and directory structures.

Therefore, dataset paths may need to be modified depending on the local environment.

The third model, in particular, requires:

HDF5 dataset
Timestamp files
Sufficient RAM
TensorFlow-compatible environment
GPU recommended for faster training
πŸ“Œ Model Comparison
Aspect	Wind RF	Solar RF/XGBoost	SUNSET CNN
Data Type	Tabular	Tabular	Image + PV
Task	Regression	Regression	Nowcasting
Main Target	Wind Power	Solar Irradiance	PV Output
Main Models	Random Forest	RF + XGBoost	CNN
Feature Engineering	Temporal	Temporal + City	Image Processing
Hyperparameter Search	No	RandomizedSearchCV	Manual Configuration
Cross Validation	Standard Split	Standard Split	10-Fold Day-Based
Ensemble	No	No	Yes
Error Analysis	Yes	Yes	Yes
Sunny/Cloudy Analysis	No	No	Yes
🎯 Project Goals

The main goals of these implementations are:

Apply machine learning to renewable energy forecasting.
Predict wind power generation from meteorological data.
Predict solar irradiance using environmental and temporal features.
Compare Random Forest and XGBoost regression models.
Apply hyperparameter optimization using RandomizedSearchCV.
Apply deep learning to image-based solar PV nowcasting.
Use CNNs to extract spatial features from solar imagery.
Use day-based cross-validation for time-dependent data.
Improve prediction robustness through ensemble learning.
Analyze model errors under different weather conditions.
πŸ‘¨β€πŸ’» Author & Modifications

Author: Momen

The notebooks in this repository were reviewed, modified, organized, and adapted by Momen.

The modifications focus on improving:

Data preprocessing
Feature engineering
Model configuration
Hyperparameter optimization
Training workflows
Model evaluation
Error analysis
Visualization
Ensemble prediction
Code organization

The implementations are intended for educational, experimental, and research purposes in the field of renewable energy forecasting and AI-based energy systems.

πŸ“œ License

This project is intended for educational and research purposes.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support