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