Upload 5 files
Browse files- Readme.md +103 -0
- app.py +47 -0
- linear_regression_model.pkl +3 -0
- linear_regression_standard_scaler.pkl +3 -0
- requirements.txt +5 -0
Readme.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# GHI Prediction — Solar Radiation Forecasting System
|
| 2 |
+
|
| 3 |
+
This interactive demo presents a production-grade **machine learning system** for predicting **Global Horizontal Irradiance (GHI)** using real-world weather data collected from weather stations across **Saudi Arabia**.
|
| 4 |
+
|
| 5 |
+
The model enables fast and accurate solar radiation forecasting, supporting applications in **solar energy planning, grid optimization, and sustainable infrastructure development**.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Input Features & Valid Ranges
|
| 10 |
+
|
| 11 |
+
All inputs are validated using real data bounds to ensure reliable predictions:
|
| 12 |
+
|
| 13 |
+
| Feature | Valid Range |
|
| 14 |
+
|-------|------------|
|
| 15 |
+
Air Temperature (°C) | 8.10 – 39.70 |
|
| 16 |
+
Air Temperature Uncertainty (°C) | 0.50 – 0.60 |
|
| 17 |
+
Wind Direction (°N) | 0 – 359 |
|
| 18 |
+
Wind Direction Uncertainty (°N) | 0.0 – 4.80 |
|
| 19 |
+
Wind Speed at 3m (m/s) | 0.0 – 7.80 |
|
| 20 |
+
Wind Speed Uncertainty (m/s) | 0.0 – 0.10 |
|
| 21 |
+
Wind Speed Std Dev (m/s) | 0.0 – 4.50 |
|
| 22 |
+
DHI (Wh/m²) | 865.8 – 6394.6 |
|
| 23 |
+
DHI Uncertainty (Wh/m²) | 37.3 – 1344.8 |
|
| 24 |
+
Standard Deviation DHI (Wh/m²) | 148.3 – 1649.6 |
|
| 25 |
+
DNI (Wh/m²) | 0.3 – 9517.0 |
|
| 26 |
+
DNI Uncertainty (Wh/m²) | 0.2 – 2115.8 |
|
| 27 |
+
Standard Deviation DNI (Wh/m²) | 0.4 – 3282.2 |
|
| 28 |
+
GHI Uncertainty (Wh/m²) | 98.4 – 5249.6 |
|
| 29 |
+
Standard Deviation GHI (Wh/m²) | 117.6 – 1720.7 |
|
| 30 |
+
Peak Wind Speed at 3m (m/s) | 0.0 – 40.5 |
|
| 31 |
+
Peak Wind Speed Uncertainty (m/s) | 0.0 – 0.20 |
|
| 32 |
+
Relative Humidity (%) | 8.3 – 95.9 |
|
| 33 |
+
Relative Humidity Uncertainty (%) | 2.8 – 3.7 |
|
| 34 |
+
Barometric Pressure (hPa) | 831.3 – 1019.7 |
|
| 35 |
+
Barometric Pressure Uncertainty (hPa) | 4.1 – 6.2 |
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## Model & Training Summary
|
| 40 |
+
|
| 41 |
+
Multiple machine learning models were trained and evaluated:
|
| 42 |
+
|
| 43 |
+
- Linear Regression **(Deployed Model)**
|
| 44 |
+
- Random Forest
|
| 45 |
+
- Decision Tree
|
| 46 |
+
- KNN
|
| 47 |
+
- SVR
|
| 48 |
+
- XGBoost
|
| 49 |
+
- Artificial Neural Network
|
| 50 |
+
- Histogram Gradient Boosting
|
| 51 |
+
|
| 52 |
+
### Final Model Selection Strategy
|
| 53 |
+
|
| 54 |
+
The final deployed model — **Linear Regression** — was selected using an automated ranking system that balances:
|
| 55 |
+
|
| 56 |
+
- **Prediction accuracy** (RMSE, R²)
|
| 57 |
+
- **Inference latency** (real-time performance)
|
| 58 |
+
|
| 59 |
+
This approach ensures both **high accuracy and fast response** for real-world deployment.
|
| 60 |
+
|
| 61 |
+
### Best Model Performance
|
| 62 |
+
|
| 63 |
+
| Model | MAE | RMSE | R² | Training Time |
|
| 64 |
+
|------|------|------|------|------|
|
| 65 |
+
Linear Regression | 135.94 | 193.74 | 0.97 | 0.01s |
|
| 66 |
+
Histogram Gradient Boosting | 140.58 | 192.11 | 0.98 | 0.83s |
|
| 67 |
+
XGBoost | 148.37 | 198.05 | 0.97 | 2.73s |
|
| 68 |
+
ANN | 154.4 | 241.22 | 0.96 | 10.6s |
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
|
| 72 |
+
## Experiment Tracking
|
| 73 |
+
|
| 74 |
+
All experiments, comparisons, and model selection were tracked using **Weights & Biases** with full reproducibility and visualization.
|
| 75 |
+
|
| 76 |
+
🔗 W&B Dashboard:
|
| 77 |
+
https://wandb.ai/nishnarudkar-d-y-patil-university/solar-radiation-prediction
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## Full Project Ecosystem
|
| 82 |
+
|
| 83 |
+
- 🖥️ **Live Web Application:**
|
| 84 |
+
https://solar-radiation-prediction-using-saudi.onrender.com
|
| 85 |
+
- 💻 **Source Code (GitHub):**
|
| 86 |
+
https://github.com/nishnarudkar/Solar-Radiation-Prediction-using-Saudi-Arabia-Dataset
|
| 87 |
+
- 🧑🔬 **AWS Builder Center Article:**
|
| 88 |
+
https://builder.aws.com/content/36qXvwTipuNwbZMUPf3hQ7n2IS0/from-experiment-tracking-to-automated-model-selection-a-solar-radiation-prediction-pipeline
|
| 89 |
+
- 📰 **Medium Article:**
|
| 90 |
+
https://medium.com/@nishnarudkar/from-experiment-tracking-to-automated-model-selection-a-practical-ml-workflow-cf193d1b1098
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
## Team
|
| 95 |
+
|
| 96 |
+
- **Nishant Narudkar**
|
| 97 |
+
- Maitreya Pawar
|
| 98 |
+
- Vatsal Parmar
|
| 99 |
+
- Aamir Sarang
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
This Hugging Face Space demonstrates the final trained model with validated real-world constraints and a clean interactive interface for public experimentation.
|
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Load trained artifacts
|
| 6 |
+
model = joblib.load("linear_regression_model.pkl")
|
| 7 |
+
scaler = joblib.load("linear_regression_standard_scaler.pkl") # remove if you didn't use scaling
|
| 8 |
+
|
| 9 |
+
def predict(*inputs):
|
| 10 |
+
X = np.array(inputs).reshape(1, -1)
|
| 11 |
+
X = scaler.transform(X) # remove if no scaling
|
| 12 |
+
prediction = model.predict(X)
|
| 13 |
+
return round(float(prediction[0]), 3)
|
| 14 |
+
|
| 15 |
+
inputs = [
|
| 16 |
+
gr.Number(label="Air Temperature (°C)", minimum=8.10, maximum=39.70, value=25, info="Range: 8.10 - 39.70 °C"),
|
| 17 |
+
gr.Number(label="Air Temp Uncertainty (°C)", minimum=0.50, maximum=0.60, value=0.55, info="Range: 0.50 - 0.60 °C"),
|
| 18 |
+
gr.Number(label="Wind Direction (°N)", minimum=0.0, maximum=359.0, value=180, info="Range: 0 - 359 °N"),
|
| 19 |
+
gr.Number(label="Wind Direction Uncertainty (°N)", minimum=0.0, maximum=4.80, value=1, info="Range: 0.0 - 4.80 °N"),
|
| 20 |
+
gr.Number(label="Wind Speed at 3m (m/s)", minimum=0.0, maximum=7.80, value=2, info="Range: 0.0 - 7.80 m/s"),
|
| 21 |
+
gr.Number(label="Wind Speed Uncertainty (m/s)", minimum=0.0, maximum=0.10, value=0.05, info="Range: 0.0 - 0.10 m/s"),
|
| 22 |
+
gr.Number(label="Wind Speed Std Dev (m/s)", minimum=0.0, maximum=4.50, value=1, info="Range: 0.0 - 4.50 m/s"),
|
| 23 |
+
gr.Number(label="DHI (Wh/m²)", minimum=865.8, maximum=6394.6, value=2000, info="Range: 865.8 - 6394.6 Wh/m²"),
|
| 24 |
+
gr.Number(label="DHI Uncertainty (Wh/m²)", minimum=37.3, maximum=1344.8, value=200, info="Range: 37.3 - 1344.8 Wh/m²"),
|
| 25 |
+
gr.Number(label="Standard Deviation DHI (Wh/m²)", minimum=148.3, maximum=1649.6, value=300, info="Range: 148.3 - 1649.6 Wh/m²"),
|
| 26 |
+
gr.Number(label="DNI (Wh/m²)", minimum=0.3, maximum=9517.0, value=3000, info="Range: 0.3 - 9517.0 Wh/m²"),
|
| 27 |
+
gr.Number(label="DNI Uncertainty (Wh/m²)", minimum=0.2, maximum=2115.8, value=300, info="Range: 0.2 - 2115.8 Wh/m²"),
|
| 28 |
+
gr.Number(label="Standard Deviation DNI (Wh/m²)", minimum=0.4, maximum=3282.2, value=400, info="Range: 0.4 - 3282.2 Wh/m²"),
|
| 29 |
+
gr.Number(label="GHI Uncertainty (Wh/m²)", minimum=98.4, maximum=5249.6, value=500, info="Range: 98.4 - 5249.6 Wh/m²"),
|
| 30 |
+
gr.Number(label="Standard Deviation GHI (Wh/m²)", minimum=117.6, maximum=1720.7, value=300, info="Range: 117.6 - 1720.7 Wh/m²"),
|
| 31 |
+
gr.Number(label="Peak Wind Speed at 3m (m/s)", minimum=0.0, maximum=40.5, value=5, info="Range: 0.0 - 40.5 m/s"),
|
| 32 |
+
gr.Number(label="Peak Wind Speed Uncertainty (m/s)", minimum=0.0, maximum=0.20, value=0.05, info="Range: 0.0 - 0.20 m/s"),
|
| 33 |
+
gr.Number(label="Relative Humidity (%)", minimum=8.3, maximum=95.9, value=50, info="Range: 8.3 - 95.9 %"),
|
| 34 |
+
gr.Number(label="Relative Humidity Uncertainty (%)", minimum=2.8, maximum=3.7, value=3.2, info="Range: 2.8 - 3.7 %"),
|
| 35 |
+
gr.Number(label="Barometric Pressure (hPa)", minimum=831.3, maximum=1019.7, value=950, info="Range: 831.3 - 1019.7 hPa"),
|
| 36 |
+
gr.Number(label="Barometric Pressure Uncertainty (hPa)", minimum=4.1, maximum=6.2, value=5, info="Range: 4.1 - 6.2 hPa")
|
| 37 |
+
]
|
| 38 |
+
|
| 39 |
+
app = gr.Interface(
|
| 40 |
+
fn=predict,
|
| 41 |
+
inputs=inputs,
|
| 42 |
+
outputs=gr.Number(label="Predicted GHI (Wh/m²)"),
|
| 43 |
+
title="🌞 GHI Prediction System",
|
| 44 |
+
description="Real-time Global Horizontal Irradiance prediction using Saudi Arabia weather data."
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
app.launch()
|
linear_regression_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8908ce076ffa8fe0b3fbad4bc844915b8bca0b53d2246a562d4d366b29f81594
|
| 3 |
+
size 1905
|
linear_regression_standard_scaler.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:912e75055e8c50191fec7eced08e7585a28c1e99c012fa1e878c09c0a11c4ede
|
| 3 |
+
size 2143
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
scikit-learn
|
| 3 |
+
numpy
|
| 4 |
+
joblib
|
| 5 |
+
pandas
|