Yash957/solar-energy-forecasting
Intelligent Solar Energy Generation Forecasting and Agentic Grid Optimization System
Project Overview
This project aims to design and implement an AI-driven solar energy forecasting and grid optimization system. The system predicts solar power generation using historical and weather-related data and extends this capability into an agentic AI assistant that generates structured, explainable recommendations for grid optimization and energy utilization.
The project is developed in two milestones:
- Milestone 1: Machine Learning–based Solar Energy Forecasting
- Milestone 2: Agentic AI Grid Optimization Assistant
The final application is publicly hosted, uses only free-tier/open-source tools, and provides a user-friendly web interface.
Project Demo
Demo Video: Demo video (Google Drive)
Problem Statement & Use Case
Solar energy generation is highly variable due to weather conditions and seasonal patterns. Grid operators require accurate forecasts and intelligent decision support to:
- Balance supply and demand
- Reduce energy wastage
- Improve renewable energy integration
- Plan storage and load shifting strategies
This project provides:
- Accurate short-term/long-term solar generation forecasts
- Automated analysis of variability and risk
- AI-generated, structured grid optimization recommendations
Overall System Architecture
High-Level Architecture
User (Browser)
│
▼
Streamlit Web UI
│
├── Data Upload & Selection
├── Forecast Horizon Selection
├── Visualization (Graphs & Metrics)
│
▼
Backend Analytics Layer (Python)
│
├── Data Preprocessing & Feature Engineering
├── ML / Time-Series Forecasting Models
├── Model Evaluation (MAE, RMSE)
│
▼
Forecast Outputs (Structured Data)
│
├── Visualization Module
└── Agentic AI System (Milestone 2)
│
├── Forecast Analysis Agent
├── Variability & Risk Detection Agent
├── Knowledge Retrieval Agent (RAG)
└── Optimization Recommendation Agent
│
▼
Structured Grid Optimization ReportNote: The agentic AI system provides decision-support recommendations only and does not directly control any grid infrastructure.
Milestone 1: ML-Based Solar Energy Forecasting (Mid-Sem)
Objective
Build a machine learning or time-series forecasting system to predict solar energy generation.
Inputs
- Historical solar power generation data
- Weather indicators (irradiance, temperature, cloud cover)
- Time-based features (hour, day, month, season)
Functional Requirements
- Data preprocessing and cleaning
- Feature engineering
- Solar energy forecasting
- Trend and seasonality analysis
- Visualization of predictions
Technical Requirements
- ML or time-series models such as:
- Linear Regression
- Random Forest Regressor
- ARIMA / SARIMA
- Prophet (optional)
- Evaluation metrics:
- MAE (Mean Absolute Error)
- RMSE (Root Mean Square Error)
UI Requirements
- Dataset upload or selection
- Forecast horizon selection
- Line plots (Actual vs Predicted)
- Trend and seasonality visualizations
Milestone 1 Deliverables
- Problem understanding & use-case description
- Input–output specification
- Forecasting pipeline architecture
- Working application with basic UI
- Forecast accuracy evaluation
Milestone 2: Agentic AI Grid Optimization Assistant (End-Sem)
Objective
Extend the forecasting system into an agentic AI assistant that reasons about forecast variability and generates structured grid optimization recommendations.
Functional Requirements
- Analyze forecast outputs and uncertainty
- Identify variability and risk periods
- Retrieve renewable energy and grid management guidelines
- Generate structured optimization recommendations
- Handle incomplete or uncertain data gracefully
Technical Requirements
- Open-source or free-tier LLM integration
- Agentic workflow with explicit state management (LangGraph)
- Retrieval-Augmented Generation (optional but recommended)
- Prompt strategies to avoid unsupported claims
Structured Output Report
The generated report includes:
- Solar generation forecast summary
- Identified variability and risk periods
- Grid balancing and storage recommendations
- Energy utilization optimization strategies
- Supporting references
Optional Extensions
- Battery storage optimization analysis
- Multi-site solar forecasting
- PDF export of optimization report
- Scenario-based energy planning
Dataset
- Solar Energy Power Generation Dataset
- Source: Kaggle
- Link: https://www.kaggle.com/datasets/stucom/solar-energy-power-generation-dataset
- File:
data/spg.csv - Records: 4,213 entries
- Features: 21 columns including:
- Weather indicators: temperature, humidity, pressure, precipitation, cloud cover
- Solar radiation: shortwave radiation backwards surface
- Wind data: speed and direction at multiple altitudes (10m, 80m, 900mb)
- Solar geometry: angle of incidence, zenith, azimuth
- Target variable:
generated_power_kw
Tech Stack & Tools
Core Technologies
No paid APIs are used in this project.
Project Setup Guide
1️⃣ Clone the Repository
git clone https://github.com/Yashsingh045/Intelligent-Solar-Energy-Generation-Forecasting.git
cd Intelligent-Solar-Energy-Generation-Forecasting2️⃣ Create Virtual Environment
python -m venv venv
source venv/bin/activate # Linux / Mac
venv\Scripts\activate # Windows3️⃣ Install Dependencies
pip install -r requirements.txtKey Dependencies:
streamlit- Web application frameworkpandas- Data manipulation and analysismatplotlib- Data visualizationnumpy- Numerical computingseaborn- Statistical data visualizationscikit-learn- Machine learning libraryjupyter- Interactive notebook environment
4️⃣ Run the Application (Local)
streamlit run app.pyThe application will open in your browser at http://localhost:8501
5️⃣ Explore the Data (Optional)
jupyter notebook notebooks/data.ipynbThis notebook contains exploratory data analysis including:
- Data quality checks
- Correlation analysis
- Feature visualization
- Statistical summaries
How to Use the Application
- Launch the App
streamlit run app.py- Upload Dataset
- Click "Browse files" or drag and drop your CSV file
- Maximum file size: 10MB
- Supported format: CSV with UTF-8 encoding
- Explore Your Data
- View dataset preview (first 20 rows)
- Check dataset shape and column names
- Select any numeric column from the dropdown
- View interactive line plots
- Analyze Patterns
- Use the notebook for deeper analysis
- Examine correlations between features
- Identify key predictors of power generation
Deployment
The application is deployed using Hugging Face Spaces (Streamlit):
- Free-tier hosting
- Publicly accessible URL
- Automatic build from repository
Deploying to Hugging Face Spaces
1. Handle the Large Model File with Git LFS
The trained model (models/random_forest_model.joblib, ~58MB) exceeds GitHub/HF's 25MB file limit. Use Git LFS:
# Install Git LFS (once)
git lfs install
# Track the large file
git lfs track "models/random_forest_model.joblib"
# Commit the .gitattributes file
git add .gitattributes
git add models/random_forest_model.joblib
git commit -m "Track large model file with Git LFS"
git push2. Set the GROQAPIKEY Secret
The AI Assistant tab requires a Groq API key (free at console.groq.com):
- Go to your HF Space → Settings → Variables and secrets
- Click New secret
- Name:
GROQ_API_KEY, Value: your key from Groq console - Save — the Space will restart automatically
3. Push to HF Spaces
# Add HF Spaces as a remote (replace <your-username> and <space-name>)
git remote add space https://huggingface.co/spaces/<your-username>/<space-name>
git push space mainFuture Improvements
- Integration of real-time weather data (free APIs)
- Advanced deep learning models (LSTM, Temporal CNNs)
- Enhanced uncertainty quantification
- Real-world grid simulation scenarios
✨ This project demonstrates the intersection of machine learning, renewable energy analytics, and agentic AI systems to support sustainable power grid operations.
