Views
No views yet
| 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 |
1Power
2📊 Dataset
3
4The model uses a wind-energy dataset stored in:
5
6Wind.csv
7
8The dataset contains weather-related measurements and power generation information.
9
10The data includes features such as:
11
12temperature_2m
13windspeed_10m
14windgusts_10m
15City
16Date
17Time
18Power
19🔧 Data Preprocessing
20
21The notebook performs several preprocessing steps.
22
23Date & Time Processing
24
25The separate Date and Time columns are combined into a single datetime representation.
26
27Temporal features are then extracted:
28
29Year
30Month
31Day
32Hour
33DayOfWeek
34
35The original date/time columns are removed after feature extraction.
36
37🔍 Exploratory Data Analysis
38
39The notebook includes several visualizations to understand the dataset:
40
41Power Distribution
42
43A histogram with KDE is used to analyze the distribution of generated power.
44
45Correlation Heatmap
46
47A correlation matrix is generated to investigate relationships between numerical variables.
48
49Feature Relationships
50
51Pair plots are used to visualize the relationship between:
52
53temperature_2m
54windspeed_10m
55windgusts_10m
56Power
57🧠 Model
58
59The main model is:
60
61RandomForestRegressor
62
63Configuration:
64
65n_estimators = 200
66max_depth = 10
67random_state = 42
68n_jobs = -1
69
70Random Forest was selected because it can model nonlinear relationships between weather conditions and power generation.
71
72⚙️ Feature Scaling
73
74StandardScaler is applied to the input features before training.
75
76The data is split into:
77
7880% Training
7920% Testing
80📏 Evaluation Metrics
81
82The model is evaluated using:
83
84RMSE
85
86Root Mean Squared Error measures the average magnitude of prediction errors.
87
88MAE
89
90Mean Absolute Error measures the average absolute difference between actual and predicted values.
91
92R² Score
93
94Measures how well the model explains the variance in the target variable.
95
96📈 Visualizations
97
98The notebook generates:
99
100Actual vs Predicted Power plot
101Random Forest Feature Importance plot
102Power distribution
103Correlation heatmap
104Feature relationship plots
1052. ☀️ Solar Irradiance Prediction — Random Forest & XGBoost
106🎯 Objective
107
108The second notebook focuses on predicting solar irradiance using weather, geographic, temporal, and city-level information.
109
110The target variable is:
111
112G(i)
113
114The goal is to estimate solar irradiance using machine learning models and compare the performance of:
115
116Random Forest
117XGBoost
118📊 Dataset
119
120The notebook uses a PVGIS-based dataset containing European city solar data.
121
122Example filename:
123
124europe_cities_pvgis_data_slope_45_azimuth_180(in).csv
125
126The dataset includes information related to:
127
128City
129Time
130Solar irradiance
131Weather/environmental measurements
132Geographic/solar system characteristics
133🕒 Temporal Feature Engineering
134
135The original time information is converted into a datetime representation.
136
137The following features are extracted:
138
139Month
140Day
141Hour
142Minute
143
144To better represent the cyclical nature of time, sinusoidal encoding is applied.
145
146Hour Encoding
147Hour_sin
148Hour_cos
149Month Encoding
150Month_sin
151Month_cos
152
153This allows the model to understand that:
154
15523:00
156
157and
158
15900:00
160
161are close in time rather than being completely different numerical values.
162
163🏙️ City Encoding
164
165The dataset contains a categorical City feature.
166
167Instead of one-hot encoding potentially large numbers of categories, the notebook uses:
168
169TargetEncoder
170
171from:
172
173category_encoders
174
175This converts city information into numerical representations based on the target variable.
176
177🔄 Preprocessing Pipeline
178
179A Scikit-learn ColumnTransformer is used to create a preprocessing pipeline.
180
181Categorical Features
182City → TargetEncoder
183Numerical Features
184Numerical features → StandardScaler
185
186This preprocessing is integrated directly into the model pipeline.
187
188🌲 Random Forest Optimization
189
190The Random Forest model is optimized using:
191
192RandomizedSearchCV
193
194The search explores parameters such as:
195
196n_estimators
197max_depth
198min_samples_split
199min_samples_leaf
200
201To reduce computational requirements, a training sample of:
202
20330,000 samples
204
205is used during hyperparameter optimization.
206
207The best estimator is then evaluated against the complete test set.
208
209🚀 XGBoost Optimization
210
211The second model is:
212
213XGBRegressor
214
215Hyperparameter optimization is also performed using:
216
217RandomizedSearchCV
218
219The search explores:
220
221n_estimators
222max_depth
223learning_rate
224subsample
225
226The optimized model is then evaluated on the test dataset.
227
228📏 Evaluation
229
230Both models are evaluated using:
231
232MAE
233RMSE
234R²
235
236A performance summary is generated to compare the two approaches.
237
238Example structure:
239
240Model MAE RMSE R²
241Random Forest ... ... ...
242XGBoost ... ... ...
243
244The actual values depend on the dataset and execution environment.
245
246🔍 Feature Importance
247
248Feature importance is extracted from both:
249
250Random Forest
251XGBoost
252
253The notebook visualizes the top features contributing to solar irradiance prediction.
254
255This helps identify which environmental and temporal variables have the strongest influence on the prediction.
256
257📊 Error Analysis
258
259Prediction errors are calculated as:
260
261True Value - Predicted Value
262
263The error distributions of Random Forest and XGBoost are visualized using histograms and KDE curves.
264
265This provides additional insight into:
266
267Prediction bias
268Error distribution
269Model stability
270Differences between the two algorithms
2713. 🌞 SUNSET Solar PV Nowcasting — CNN
272🎯 Objective
273
274The third notebook implements a deep learning-based solar photovoltaic (PV) nowcasting model.
275
276Unlike the previous models, which primarily use tabular weather and temporal data, this model works with image-based solar observations.
277
278The goal is to predict near-term PV power output from image sequences and related PV data.
279
280The implementation is based on the SUNSET nowcasting approach, using a Convolutional Neural Network (CNN).
281
282📊 Dataset
283
284The model works with an HDF5 dataset:
285
286nowcast_dataset.hdf5
287
288The data contains separate training/validation and testing groups.
289
290The main inputs include:
291
292images_log
293pv_log
294
295The image data is processed as:
296
29764 × 64 × 24
298
299where the 24 channels represent the image information available to the model.
300
301The corresponding PV output is used as the regression target.
302
303🧠 CNN Architecture
304
305The model is implemented using:
306
307TensorFlow
308Keras
309
310The architecture contains:
311
312Input
31364 × 64 × 24
314Convolution Block 1
315Conv2D
316BatchNormalization
317MaxPooling2D
318
319with:
320
32124 filters
3223 × 3 kernel
323Convolution Block 2
324Conv2D
325BatchNormalization
326MaxPooling2D
327
328with:
329
33048 filters
3313 × 3 kernel
332Fully Connected Layers
333
334After convolution and pooling:
335
336Flatten
337↓
338Dense(1024)
339↓
340Dropout(0.4)
341↓
342Dense(1024)
343↓
344Dropout(0.4)
345↓
346Dense(1)
347
348The final neuron produces the predicted PV output.
349
350⚙️ Training Configuration
351
352The model uses:
353
354Optimizer: Adam
355Learning Rate: 3e-6
356Loss Function: Mean Squared Error
357Batch Size: 256
358Maximum Epochs: 200
359
360Early stopping is used to prevent unnecessary training when validation performance stops improving.
361
362🔄 10-Fold Cross-Validation
363
364The notebook uses:
365
36610-Fold Cross-Validation
367
368However, instead of randomly splitting individual timestamps, the data is shuffled in day blocks.
369
370This is particularly important for time-dependent solar forecasting because samples from the same day can be highly correlated.
371
372The workflow is:
373
374Timestamp Data
375 ↓
376Day-Based Blocks
377 ↓
378Shuffle Blocks
379 ↓
38010-Fold Cross Validation
381 ↓
382Training / Validation
383💾 Model Checkpoints
384
385The best model from every fold is saved separately.
386
387The structure is approximately:
388
389model_output/
390└── SUNSET_nowcast_2017_2019_data/
391 ├── repetition_1/
392 │ └── best_model_repitition_1.h5
393 ├── repetition_2/
394 │ └── best_model_repitition_2.h5
395 ├── ...
396 └── repetition_10/
397 └── best_model_repitition_10.h5
398
399Training and validation histories are also stored for later analysis.
400
401🤝 Ensemble Prediction
402
403After training 10 models, predictions from all models are combined.
404
405The final prediction is calculated using the mean:
406
407Ensemble Prediction =
408Mean(Prediction Model 1 ... Prediction Model 10)
409
410This ensemble approach helps reduce the variance of individual models and provides a more stable final prediction.
411
412☀️ Sunny vs Cloudy Evaluation
413
414The test dataset is further divided into:
415
416Sunny Days
417Cloudy Days
418
419The model is evaluated separately on both conditions.
420
421The notebook calculates:
422
423Sunny RMSE
424Cloudy RMSE
425Overall RMSE
426
427Sunny MAE
428Cloudy MAE
429Overall MAE
430
431This is particularly useful because cloud conditions can introduce significant uncertainty into solar PV forecasting.
432
433📈 Visualization
434
435The notebook compares:
436
437Ground Truth PV Output
438vs
439SUNSET Nowcast Prediction
440
441for both sunny and cloudy days.
442
443Each visualization includes:
444
445Actual PV output
446Predicted PV output
447RMSE
448MAE
449Hour of the day
450
451This allows the performance of the model to be analyzed throughout the day.
452
453🧰 Technologies & Libraries
454Machine Learning
455Python
456NumPy
457Pandas
458Scikit-learn
459Random Forest
460XGBoost
461SciPy
462Deep Learning
463TensorFlow
464Keras
465CNN
466Adam Optimizer
467Data Processing
468HDF5
469h5py
470category_encoders
471StandardScaler
472Target Encoding
473Visualization
474Matplotlib
475Seaborn
476🏗️ Overall Architecture
477 Renewable Energy Data
478 │
479 ┌──────────────┼──────────────┐
480 │ │ │
481 ▼ ▼ ▼
482 Wind Data Solar Data Image Data
483 │ │ │
484 ▼ ▼ ▼
485 Feature Engineering Time Encoding Image Processing
486 │ │ │
487 ▼ ▼ ▼
488 Random Forest RF + XGBoost CNN
489 │ │ │
490 ▼ ▼ ▼
491 Power Output Solar Irradiance PV Nowcasting
492 │ │ │
493 └──────────────┼──────────────┘
494 ▼
495 Performance Analysis
496 │
497 ┌──────┴──────┐
498 ▼ ▼
499 MAE RMSE
500 │
501 ▼
502 R²
503📁 Suggested Repository Structure
504Renewable-Energy-Forecasting/
505│
506├── notebooks/
507│ ├── wind_power_random_forest.ipynb
508│ ├── solar_irradiance_rf_xgboost.ipynb
509│ └── sunset_pv_nowcasting_cnn.ipynb
510│
511├── data/
512│ ├── Wind.csv
513│ ├── europe_cities_pvgis_data_slope_45_azimuth_180(in).csv
514│ └── data_nowcast/
515│ ├── nowcast_dataset.hdf5
516│ ├── times_trainval.npy
517│ └── times_test.npy
518│
519├── model_output/
520│ └── SUNSET_nowcast_2017_2019_data/
521│
522└── README.md
523🚀 How to Run
5241. Clone the repository
525git clone <YOUR_REPOSITORY_URL>
526cd Renewable-Energy-Forecasting
5272. Install dependencies
528pip install numpy pandas matplotlib seaborn scikit-learn scipy
529pip install xgboost category_encoders
530pip install tensorflow h5py
5313. Prepare the datasets
532
533Place the required datasets inside the appropriate data/ directories.
534
535Update the dataset paths in the notebooks if necessary.
536
537For example:
538
539df = pd.read_csv("path/to/Wind.csv")
540⚠️ Notes
541
542The notebooks were originally developed for specific datasets and directory structures.
543
544Therefore, dataset paths may need to be modified depending on the local environment.
545
546The third model, in particular, requires:
547
548HDF5 dataset
549Timestamp files
550Sufficient RAM
551TensorFlow-compatible environment
552GPU recommended for faster training
553📌 Model Comparison
554Aspect Wind RF Solar RF/XGBoost SUNSET CNN
555Data Type Tabular Tabular Image + PV
556Task Regression Regression Nowcasting
557Main Target Wind Power Solar Irradiance PV Output
558Main Models Random Forest RF + XGBoost CNN
559Feature Engineering Temporal Temporal + City Image Processing
560Hyperparameter Search No RandomizedSearchCV Manual Configuration
561Cross Validation Standard Split Standard Split 10-Fold Day-Based
562Ensemble No No Yes
563Error Analysis Yes Yes Yes
564Sunny/Cloudy Analysis No No Yes
565🎯 Project Goals
566
567The main goals of these implementations are:
568
569Apply machine learning to renewable energy forecasting.
570Predict wind power generation from meteorological data.
571Predict solar irradiance using environmental and temporal features.
572Compare Random Forest and XGBoost regression models.
573Apply hyperparameter optimization using RandomizedSearchCV.
574Apply deep learning to image-based solar PV nowcasting.
575Use CNNs to extract spatial features from solar imagery.
576Use day-based cross-validation for time-dependent data.
577Improve prediction robustness through ensemble learning.
578Analyze model errors under different weather conditions.
579👨💻 Author & Modifications
580
581Author: Momen
582
583The notebooks in this repository were reviewed, modified, organized, and adapted by Momen.
584
585The modifications focus on improving:
586
587Data preprocessing
588Feature engineering
589Model configuration
590Hyperparameter optimization
591Training workflows
592Model evaluation
593Error analysis
594Visualization
595Ensemble prediction
596Code organization
597
598The implementations are intended for educational, experimental, and research purposes in the field of renewable energy forecasting and AI-based energy systems.
599
600📜 License
601
602This project is intended for educational and research purposes.