| title | Weather Forecasting API |
|---|---|
| emoji | ๐ค๏ธ |
| colorFrom | blue |
| colorTo | indigo |
| sdk | docker |
| pinned | false |
Uncertainty-Aware Weather Forecasting System
Live Data Anchored, 7-Day Forecasting with Machine Learning & React
๐ Project Overview
This project is a machine learningโbased weather forecasting system designed to predict the next 7 days of temperature using:
Historical learning Live weather anchoring Uncertainty estimation
Unlike traditional student projects that rely on static datasets or single-point predictions, this system:
Anchors forecasts to real-time weather data via Open-Meteo Uses recursive multi-step forecasting to predict future days Explicitly models prediction uncertainty using residual error analysis Presents results through a decoupled FastAPI backend and a modern, glassmorphic React/Tailwind UI
The project is suitable for academic research, capstone evaluation, and demonstrating applied ML system design.
๐ฏ Problem Statement
Most beginner weather forecasting projects suffer from:
Reliance on static datasets that do not reflect real-world conditions Providing single deterministic predictions without communicating reliability Exposing internal ML features (e.g., lag variables) directly to users Lack of system-level design (monolithic scripts instead of separated API and UI layers)
This project addresses these issues by building a realistic, interpretable, and modular forecasting system that combines machine learning with live data integration and uncertainty-aware predictions.
๐ง Key Concepts & Methodology 1๏ธโฃ Historical Learning with Machine Learning Core model: XGBoost Regressor Trained on historical weather data Uses lag-based features (previous 7 daysโ temperatures) to capture temporal dependencies 2๏ธโฃ Live Weather Anchoring (Open-Meteo API) Backend fetches: Temperature Wind speed Humidity Cloud cover These values act as Day 0 input for forecasting Ensures predictions reflect current real-world conditions
3๏ธโฃ Recursive Multi-Step Forecasting (7-Day Prediction) Predict Day 1 Feed prediction back to predict Day 2 Repeat recursively for 7 days
This is a standard and academically valid time-series approach.
4๏ธโฃ Uncertainty-Aware Forecasting & Expanded Metrics
Instead of single-point predictions:
Residual errors are analyzed Standard deviation is computed A 95% confidence interval is generated Uncertainty is dynamically calibrated based on deviation from current conditions
Additionally:
ML predictions are merged with 8-day API forecasts Provides:
- Wind Speed
- Cloud Cover
- Precipitation
๐๏ธ System Architecture Open-Meteo API โ โผ Live Weather Anchoring โ โผ XGBoost ML Model (Historical) โ โผ Recursive 7-Day Forecast โ โผ Uncertainty Estimation โ โผ FastAPI Backend โโโบ React / Tailwind Frontend
๐งฉ Project Structure
weather-forecasting/
โ
โโโ app/
โ โโโ main.py # FastAPI backend (prediction API & Data Merging)
โ
โโโ frontend/ # React / Vite application
โ โโโ src/
โ โ โโโ App.jsx # Main UI Component with Expandable Accordions
โ โ โโโ index.css # Tailwind v4 Configuration
โ โ โโโ main.jsx
โ โโโ package.json
โ
โโโ scripts/
โ โโโ train_model.py # Model training + uncertainty computation
โ โโโ fetch_current_weather.py
โ
โโโ data/
โ โโโ weather.csv # Historical training dataset
โ
โโโ models/
โ โโโ xgb_model.pkl # Trained ML model
โ โโโ scaler.pkl # Feature scaler
โ โโโ uncertainty.pkl # Residual-based uncertainty value
โ
โโโ results/
โ โโโ metrics.txt
โ โโโ actual_vs_pred.csv
โ
โโโ requirements.txt # Python dependencies
โโโ README.md
๐ How to Run the Project 1๏ธโฃ Python Backend Setup pip install -r requirements.txt pip install fastapi uvicorn pydantic requests python scripts/train_model.py uvicorn app.main:app --reload API: http://localhost:8000 Docs: http://localhost:8000/docs
2๏ธโฃ React Frontend Setup cd frontend npm install npm run dev
UI: http://localhost:5173 ๐ Output Example Day 3 (Wednesday)
Predicted Temperature: 14.8 ยฐC Uncertainty: ยฑ2.1 ยฐC Confidence Range: 12.7 โ 16.9 ยฐC
Expanded view:
Wind: 12 km/h Clouds: 45% Precipitation: 0.0 mm
๐ Evaluation Metrics Mean Absolute Error (MAE) Root Mean Square Error (RMSE)
Stored in: results/metrics.txt
- Model does not retrain automatically
- Uncertainty reflects model confidence, not real-world guarantees
- Recursive forecasting may accumulate error
๐ฎ Future Enhancements
- Multi-variable forecasting (humidity, wind via ML)
- Deep learning models (LSTM / GRU)
- Automated retraining (CI/CD pipelines)
- Cloud deployment (AWS / GCP / Vercel)