From raw seismic signal to actionable rescue plan — fully automated, zero human bottleneck.
Overview · Architecture · Modules · ML Model · Installation · Usage
AEGIS AI eliminates the critical gap between seismic detection and emergency rescue deployment. Instead of relying on slow, manual interpretation of geological data across fragmented tools, AEGIS automatically predicts earthquake impact, identifies safe medical facilities, filters danger zones, and generates dispatch orders — all within 1.5 seconds.
Current systems create dangerous data silos: seismologists use geological software while emergency services use separate logistics databases. During the golden hour, this fragmentation costs lives. AEGIS solves this with a unified, automated intelligence pipeline.
Detection Speed → Raw seismic signal to dispatch order in 1.5 seconds
ML Accuracy → Random Forest R² = 0.835, CV Accuracy = 83.5%
Data Source → Live USGS GeoJSON API (60-second poll interval)
Geospatial Engine → OpenStreetMap Overpass API + 5km Danger Zone Filtering
Alert Threshold → Automated flashing alerts for M ≥ 6.0 events
USGS Live API (60s poll)
│
▼
┌─────────────────────┐
│ Data Ingestion │ ← fetch_latest_earthquakes() + purify_data()
│ & Preprocessing │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ AI Intelligence │ ← Random Forest Regressor (Scikit-Learn)
│ Layer │ ← Impact Score = (Mag × Pop Density) / log(Depth+1)
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ Geospatial Engine │ ← OpenStreetMap Overpass API
│ │ ← 5km Danger Zone Filter + Safe Route Mapping
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ Presentation Layer │ ← Streamlit + Folium + Leafmap
│ (Dashboard) │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ Admin Control │ ← Dispatch Orders + Report Generation + Audit Log
└─────────────────────┘
Impact Score Formula:
Impact Score = (Magnitude × Population Density) / log(Depth + 1)
Engineering decisions worth noting:
- USGS API feeds normalized in real time before hitting the prediction pipeline — no stale batch processing
- Geospatial routing triggers only on filtered high-magnitude events, preventing alert fatigue in field use
- QoS-style traffic class applied to event severity: minor, moderate, major, critical — each routing to a different dispatch protocol
- Offline model served from
earthquake_model.pklvia Joblib; no network dependency at prediction time - Streamlit dashboard designed for minimal-click operation: data ingestion to actionable output in under 3 interactions
DISASTER_RESPONSE_SYSTEM/
│
├── Home.py # Entry point — Global Seismic Heatmap
│
├── pages/
│ ├── 1_Data_Analysis.py # Data purification & geospatial visualization
│ ├── 2_AI_Training.py # Model training, comparison & persistence
│ ├── 3_Live_Monitoring.py # Real-time global monitoring & flash alerts
│ ├── 4_Resource_Allocation.py # Risk assessment & dispatch order generation
│ ├── 5_Evacuation_Planning.py # Safe zone routing via OpenStreetMap
│ └── 6_Admin_Dashboard.py # Command center & official report generation
│
├── utils/
│ ├── __init__.py
│ └── data_processor.py # USGS API fetch + data purification logic
│
├── models/
│ └── earthquake_model.pkl # Saved trained Random Forest model (Joblib)
│
├── data/ # Local data cache
├── .streamlit/config.toml # Theme & config settings
├── requirements.txt
└── pages.txt
| Function | Description |
|---|---|
fetch_latest_earthquakes() |
Calls USGS GeoJSON API, returns raw DataFrame |
purify_data(df) |
Extracts magnitude, depth, lat, lon, location from raw feed |
| Page | Responsibility |
|---|---|
1_Data_Analysis.py |
Fetches and purifies 10,853+ seismic records · Magnitude vs Depth scatter · Frequency histogram |
2_AI_Training.py |
Trains RF, Decision Tree, Linear Regression · 5-Fold CV · Saves best model via Joblib |
3_Live_Monitoring.py |
Real-time Folium map · Flashing CSS alerts for M ≥ 6.0 · Timestamped broadcast audit log |
4_Resource_Allocation.py |
Geocodes place names · Predicts magnitude · Calculates impact score · Auto-generates dispatch orders |
5_Evacuation_Planning.py |
Queries OSM Overpass API · Filters 5km danger zone · Plots safe routing · Resilience gap analysis |
6_Admin_Dashboard.py |
System status metrics · Formal report form with .txt download · Global alert audit trail |
| Model | R² Score | RMSE | CV Accuracy |
|---|---|---|---|
| Random Forest | 0.835 | 0.4962 | 83.5% |
| Decision Tree | 0.740 | 0.6725 | 74.0% |
| Linear Regression | 0.620 | 0.8355 | 62.0% |
Input Features:
X = ['depth', 'latitude', 'longitude']
y = ['magnitude']Why Random Forest?
- Handles non-linear relationships between depth and surface magnitude
- Ensemble of 100 trees significantly reduces overfitting on real-world seismic outliers
- Highest R² and CV accuracy across all three compared models
- Model serialized via Joblib for zero-latency offline prediction at runtime
Prerequisites: Python 3.10+, pip, internet connection (USGS API + OpenStreetMap)
# Clone the repository
git clone https://github.com/nayar-900/AEGIS-AI.git
cd AEGIS-AI
# Create virtual environment
python -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtKey dependencies:
streamlit · pandas · numpy · scikit-learn · joblib
folium · leafmap · plotly · requests · geopy · geopandas
streamlit run Home.pyOpens at http://localhost:8501. Follow this sequence on first launch:
| Step | Page | Action |
|---|---|---|
| 1 | Data Analysis | Fetch and purify live USGS data |
| 2 | AI Training | Train and save the Random Forest model |
| 3 | Live Monitoring | View real-time global seismic activity |
| 4 | Resource Allocation | Test AI risk assessment for any location |
| 5 | Evacuation Planning | Get safe zone routing via OpenStreetMap |
| 6 | Admin Dashboard | Generate official disaster reports |
| Category | Technology |
|---|---|
| Frontend / UI | Streamlit |
| ML / AI | Scikit-Learn — Random Forest · Decision Tree · Linear Regression |
| Data Processing | Pandas · NumPy |
| Visualization | Plotly · Folium · Leafmap |
| Geospatial | OpenStreetMap Overpass API · GeoPy · GeoPandas |
| Live Data | USGS Earthquake Hazards API (GeoJSON) |
| Model Persistence | Joblib (.pkl) |
| Language | Python 3.10+ |
[ ] Multi-disaster support — wildfire, flood, and tsunami live data feeds
[ ] Database integration — PostgreSQL for historical event storage and trend analysis
[ ] WebSocket alerts — replace 60s polling with true real-time push notifications
[ ] Mobile application — field-level access for first responders
[ ] Live census data — replace static population density with real-time figures
[ ] REST API endpoint — expose AEGIS predictions as an external API for third-party integration
Muhammad Rayan Badar — BS Computer Science, Namal University Mianwali
