An End-to-End Machine Learning System for Flood Risk Prediction using Hydrological, Meteorological, and Geospatial Data.
Built using XGBoost, deployed with FastAPI, and visualized through an interactive Streamlit Dashboard.
- π Overview
- β¨ Key Features
- π§ Model & Methodology
- π Results
- ποΈ Project Structure
- βοΈ Installation
- π Running the Project
- π API Reference
- π³ Docker Support
- π οΈ Tech Stack
- π Future Scope
- π License
- π¨βπ» Author
RiskRadar is a production-grade flood risk prediction system that analyzes hydrological, meteorological, and geospatial parameters to classify locations into flood risk categories.
The project leverages a high-performance XGBoost Machine Learning model trained on real-world flood datasets and provides predictions through:
- π FastAPI REST API
- π Interactive Streamlit Dashboard
- π³ Dockerized Deployment Pipeline
Unlike a traditional ML notebook project, RiskRadar focuses on a complete deployment-ready architecture suitable for real-world usage.
β
Trained on 45,932 global flood locations
β
Achieved 96.9% Accuracy
β
F1 Score: 0.984
β
Uses SMOTE for class imbalance handling
β
Real-time prediction dashboard with Plotly visualizations
β
FastAPI backend with input validation
β
Interactive flood-risk mapping
β
Docker-ready deployment
β
Production-oriented ML workflow
- Source: IIT Delhi Static Flood Database
- Dataset File:
kuntla_flooddatabase.csv - Raw Features: 93
- Final Engineered Features: 13
- Target: Flood Risk Classification
Raw Dataset (93 Parameters)
β
Missing Value Handling
β
Feature Engineering
β
Categorical Encoding
β
Train/Test Split
β
SMOTE Balancing
β
Hyperparameter Tuning
β
XGBoost Training
β
Evaluation & Model Export
β
FastAPI + Streamlit Deployment
- Dropped columns with more than 40% missing values
- Median imputation for numerical features
Created custom engineered features such as:
precipitation_risk_indexdrainage_risk_index
Applied Label Encoding for:
- Climate Type
- Landcover Type
- Soil Type
- Lithology Type
- XGBoost Classifier
RandomizedSearchCV- 50 parameter combinations
- 3-fold cross-validation
- GPU accelerated training (
tree_method=hist)
- Applied SMOTE on training dataset
| Metric | Score |
|---|---|
| Accuracy | 96.9% |
| F1 Score | 0.984 |
| Recall | 0.791 |
- High-risk locations identified: 2,538
- Total locations analyzed: 45,932
- Annual Precipitation
- Seasonal Rainfall Patterns
- Drainage Density
- Basin Relief
- Soil Characteristics
- Land Cover Features
- Temperature Seasonality
riskradar/
β
βββ flood_fast.py
βββ api.py
βββ app.py
βββ Dockerfile
βββ requirements.txt
βββ flood_model.pkl
βββ encoders.pkl
βββ feature_columns.pkl
βββ high_risk_locations.csv
βββ README.mdgit clone https://github.com/nitinc264/Flood-prediction-Model.git
cd Flood-prediction-Modelpython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtuvicorn api:app --reload --port 8000http://localhost:8000/docs
Open a new terminal and run:
streamlit run app.pyhttp://localhost:8501
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API Information |
| GET | /health |
Health Check |
| GET | /features |
Feature List |
| POST | /predict |
Flood Risk Prediction |
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{
"annual_precipitation": 1500,
"precipitation_of_wettest_month": 400,
"precipitation_seasonality": 60,
"drainage_density": 3.5,
"drainage_texture": 12.0,
"basin_relief": 800,
"annual_mean_temperature": 22,
"temperature_seasonality": 600,
"curve_number_amcii": 75,
"ruggedness_number": 0.8,
"infiltration_number": 6,
"climate_type": 2,
"landcover_type": 1,
"soil_type": 3
}'{
"flood_risk_score": 0.8341,
"risk_percentage": "83.4%",
"risk_level": "HIGH",
"color": "red",
"message": "Immediate attention required. High probability of flood event.",
"features_used": 13
}docker build -t riskradar .docker run -p 8000:8000 riskradar| Layer | Technology |
|---|---|
| Machine Learning | XGBoost, Scikit-learn |
| Data Processing | Pandas, NumPy |
| Imbalanced Learning | SMOTE |
| Backend API | FastAPI, Uvicorn |
| Frontend Dashboard | Streamlit |
| Visualization | Plotly, Folium, Matplotlib |
| Deployment | Docker |
| Training Environment | Google Colab |
- Hugging Face deployment β β Live at nitin454545-riskradar.hf.space
- Real-time weather API integration
- Global-scale flood dataset expansion
- SMS & Email flood alerts
- Mobile-responsive frontend
- Live geospatial monitoring
- Cloud deployment pipeline
This project is licensed under the MIT License.
You are free to:
- Use
- Modify
- Distribute
- Improve
with proper attribution.
π B.Tech β AI & Data Science
π« Dr. D.Y. Patil School of Science and Technology