Tabular Regression
Scikit-learn
English
solar-energy
time-series
regression
random-forest
energy-forecasting
photovoltaic
Instructions to use nakedved/genai-capstone with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use nakedved/genai-capstone with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("nakedved/genai-capstone", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Add model card
Browse files
README.md
CHANGED
|
@@ -1,28 +1,164 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
- sklearn
|
| 5 |
- solar-energy
|
| 6 |
- time-series
|
| 7 |
- regression
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
# Solar Power Forecast Model
|
| 11 |
|
| 12 |
-
RandomForestRegressor trained
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
## Usage
|
| 21 |
|
| 22 |
```python
|
| 23 |
import joblib
|
|
|
|
|
|
|
| 24 |
from huggingface_hub import hf_hub_download
|
| 25 |
|
|
|
|
| 26 |
path = hf_hub_download(repo_id="nakedved/genai-capstone", filename="solar_forecast_model.pkl")
|
| 27 |
model = joblib.load(path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
tags:
|
| 6 |
- sklearn
|
| 7 |
- solar-energy
|
| 8 |
- time-series
|
| 9 |
- regression
|
| 10 |
+
- random-forest
|
| 11 |
+
- energy-forecasting
|
| 12 |
+
- photovoltaic
|
| 13 |
+
library_name: sklearn
|
| 14 |
+
pipeline_tag: tabular-regression
|
| 15 |
+
metrics:
|
| 16 |
+
- r2
|
| 17 |
+
- mae
|
| 18 |
+
- rmse
|
| 19 |
---
|
| 20 |
|
| 21 |
+
# Solar Power Generation Forecast Model
|
| 22 |
|
| 23 |
+
A `RandomForestRegressor` (scikit-learn) trained on real solar plant operational data
|
| 24 |
+
to predict **plant-level DC power output 15 minutes into the future**. Part of a
|
| 25 |
+
GenAI capstone project that extends this forecasting model with an agentic grid
|
| 26 |
+
optimisation assistant built on LangGraph, FAISS RAG, and Llama 3.1 via Groq.
|
| 27 |
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## Model Details
|
| 31 |
+
|
| 32 |
+
| Property | Value |
|
| 33 |
+
|---|---|
|
| 34 |
+
| **Model type** | RandomForestRegressor (scikit-learn 1.8.0) |
|
| 35 |
+
| **Task** | Tabular regression — 15-minute ahead solar power forecasting |
|
| 36 |
+
| **n_estimators** | 200 |
|
| 37 |
+
| **max_depth** | 12 |
|
| 38 |
+
| **random_state** | 42 |
|
| 39 |
+
| **n_jobs** | -1 (parallelised) |
|
| 40 |
+
| **Input features** | 9 |
|
| 41 |
+
| **Target** | DC_POWER at t+1 (Watts, plant-level aggregate) |
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## Dataset
|
| 46 |
+
|
| 47 |
+
- **Source**: [Kaggle Solar Power Generation Data](https://www.kaggle.com/datasets/anikannal/solar-power-generation-data)
|
| 48 |
+
- **Plant**: Plant 1 — two 15-minute aligned CSV files (generation + weather sensor)
|
| 49 |
+
- **Period**: 34 days (May–June 2020), 15-minute intervals
|
| 50 |
+
- **Raw records**: 68,778 inverter-level rows → 3,157 plant-level timestamps after aggregation
|
| 51 |
+
- **Train/test split**: 80/20 chronological (2,521 train / 631 test) — no shuffling to prevent leakage
|
| 52 |
+
|
| 53 |
+
### Data Preprocessing
|
| 54 |
+
|
| 55 |
+
1. Inverter-level `DC_POWER` summed per timestamp to plant-level aggregate
|
| 56 |
+
2. Merged with weather sensor table on `DATE_TIME`
|
| 57 |
+
3. Chronological sort, null rows dropped after feature construction
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## Features
|
| 62 |
+
|
| 63 |
+
| Feature | Type | Construction |
|
| 64 |
+
|---|---|---|
|
| 65 |
+
| `AMBIENT_TEMPERATURE` | Weather | Raw sensor reading (°C) |
|
| 66 |
+
| `MODULE_TEMPERATURE` | Weather | Raw sensor reading (°C) |
|
| 67 |
+
| `IRRADIATION` | Weather | Raw sensor reading (kW/m²) |
|
| 68 |
+
| `hour` | Time | `DATE_TIME.dt.hour` |
|
| 69 |
+
| `day_of_year` | Time | `DATE_TIME.dt.dayofyear` |
|
| 70 |
+
| `month` | Time | `DATE_TIME.dt.month` |
|
| 71 |
+
| `lag_1` | Autoregressive | `DC_POWER` at t−1 (15 min prior) |
|
| 72 |
+
| `lag_4` | Autoregressive | `DC_POWER` at t−4 (1 hour prior) |
|
| 73 |
+
| `rolling_mean_4` | Autoregressive | Rolling mean of `DC_POWER` over 4 intervals |
|
| 74 |
+
|
| 75 |
+
**Feature importances** (mean decrease in impurity, approximate):
|
| 76 |
+
|
| 77 |
+
| Feature | Importance |
|
| 78 |
+
|---|---|
|
| 79 |
+
| `IRRADIATION` | ~0.88 |
|
| 80 |
+
| `hour` | ~0.04 |
|
| 81 |
+
| `rolling_mean_4` | ~0.03 |
|
| 82 |
+
| `lag_4` | ~0.02 |
|
| 83 |
+
| `lag_1` | ~0.01 |
|
| 84 |
+
| Others | < 0.01 each |
|
| 85 |
+
|
| 86 |
+
Irradiation dominates by a wide margin. Temporal lag features carry independent predictive
|
| 87 |
+
signal for transition periods where irradiance changes rapidly.
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## Performance
|
| 92 |
+
|
| 93 |
+
| Evaluation Split | MAE (W) | RMSE (W) | R² |
|
| 94 |
+
|---|---|---|---|
|
| 95 |
+
| **Daytime only** (irradiation > 0) | 4,646.83 | 7,397.92 | **0.9905** |
|
| 96 |
+
| **Full dataset** (24-hour) | 10,573.81 | 21,207.71 | **0.9323** |
|
| 97 |
+
|
| 98 |
+
The gap between splits reflects sunrise/sunset transition periods where steep power ramps
|
| 99 |
+
are structurally harder to predict with autoregressive lag features calibrated on
|
| 100 |
+
steady-state production.
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
|
| 104 |
## Usage
|
| 105 |
|
| 106 |
```python
|
| 107 |
import joblib
|
| 108 |
+
import numpy as np
|
| 109 |
+
import pandas as pd
|
| 110 |
from huggingface_hub import hf_hub_download
|
| 111 |
|
| 112 |
+
# Load model
|
| 113 |
path = hf_hub_download(repo_id="nakedved/genai-capstone", filename="solar_forecast_model.pkl")
|
| 114 |
model = joblib.load(path)
|
| 115 |
+
|
| 116 |
+
# Input must have exactly these 9 columns in this order:
|
| 117 |
+
# AMBIENT_TEMPERATURE, MODULE_TEMPERATURE, IRRADIATION,
|
| 118 |
+
# hour, dayofyear, month, lag_1, lag_4, rolling_mean_4
|
| 119 |
+
|
| 120 |
+
sample = pd.DataFrame([{
|
| 121 |
+
"AMBIENT_TEMPERATURE": 28.5,
|
| 122 |
+
"MODULE_TEMPERATURE": 42.1,
|
| 123 |
+
"IRRADIATION": 0.65,
|
| 124 |
+
"hour": 12,
|
| 125 |
+
"dayofyear": 155,
|
| 126 |
+
"month": 6,
|
| 127 |
+
"lag_1": 85000.0,
|
| 128 |
+
"lag_4": 78000.0,
|
| 129 |
+
"rolling_mean_4": 81500.0,
|
| 130 |
+
}])
|
| 131 |
+
|
| 132 |
+
prediction = model.predict(sample)
|
| 133 |
+
print(f"Predicted DC Power (next 15 min): {prediction[0]:,.0f} W")
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
---
|
| 137 |
+
|
| 138 |
+
## Limitations
|
| 139 |
+
|
| 140 |
+
- Trained on a single plant (Plant 1) over 34 days. Performance on other plants or
|
| 141 |
+
seasonal conditions outside May–June may degrade.
|
| 142 |
+
- Batch inference only — not designed for streaming real-time input.
|
| 143 |
+
- RandomForest has no explicit temporal memory; long-range dependencies (multi-hour
|
| 144 |
+
trends, weather fronts) are not captured.
|
| 145 |
+
- Sunrise/sunset RMSE is significantly higher than daytime-only RMSE due to steep
|
| 146 |
+
power ramps that lag features partially miss.
|
| 147 |
+
|
| 148 |
+
---
|
| 149 |
+
|
| 150 |
+
## Citation
|
| 151 |
+
|
| 152 |
+
If you use this model, please reference the source dataset:
|
| 153 |
+
|
| 154 |
```
|
| 155 |
+
Anikannal (2020). Solar Power Generation Data.
|
| 156 |
+
Kaggle. https://www.kaggle.com/datasets/anikannal/solar-power-generation-data
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
---
|
| 160 |
+
|
| 161 |
+
## Related
|
| 162 |
+
|
| 163 |
+
- **Deployed app**: https://solarpowerpredictionmodel.streamlit.app/
|
| 164 |
+
- **GitHub**: https://github.com/Aviral02git/Solar-power-prediction
|