Skip to content

Muaadh-Nazly/disaster-predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Disaster Prediction and Early Warning System

πŸ“‹ Project Overview

A comprehensive prediction model and early warning system for Flood, Cyclone, and Landslide disasters in Sri Lanka. This system empowers social resilience by providing timely predictions and safety information to the general public through a mobile application.

🎯 Project Objectives

  • Predict flood, cyclone, and landslide occurrences in Sri Lanka
  • Provide early warning alerts to common people
  • Enable proactive disaster preparedness
  • Empower social resilience through accessible technology

πŸ—οΈ System Architecture

The project consists of four main components:

  1. Data Preprocessing - Data cleaning and feature engineering
  2. Model Training - Machine learning model development
  3. API Integration - Backend service for predictions
  4. Mobile Application - Android app for end users

🎬 Demo

πŸ“± Full System Demo

End-to-end walkthrough of the Android app - user login, location-based disaster prediction, and real-time early warning alerts.

▢️ Watch Full Demo Video


🌐 Live API Response

Real prediction output from the Flask REST API across all three disaster types with a 3-day forecast horizon.

curl -X POST http://127.0.0.1:5000/predict_three \
  -F "Location=Kegalle" \
  -F "District=Colombo" \
  -F "Rainfall(mm)=30.0" \
  -F "Wind Speed(mph)=20.0"
{
  "Prediction for Cyclone RFR": 43.86,
  "Prediction for Cyclone XGB": 39.80,
  "Prediction for Flood RFR": 38.09,
  "Prediction for Flood XGB": 24.23,
  "Prediction for Landslide RFR": 54.43,
  "Prediction for Landslide XGB": 86.63
}

πŸ“ Repository Structure

DSGP/
β”œβ”€β”€ Preprocess/              # Data preprocessing and cleaning
β”‚   β”œβ”€β”€ Preprocess.ipynb    # Main preprocessing notebook
β”‚   └── [Data files]        # Processed datasets
β”œβ”€β”€ Modelling/               # Model training notebooks
β”‚   β”œβ”€β”€ Flood/              # Flood prediction models
β”‚   β”œβ”€β”€ Cyclone/            # Cyclone prediction models
β”‚   └── Landslide/          # Landslide prediction models
β”œβ”€β”€ Integration/             # Flask API backend
β”‚   β”œβ”€β”€ app.py              # Flask application
β”‚   β”œβ”€β”€ Model_*.py          # Model prediction modules
β”‚   └── *.pkl              # Trained model files
└── MyApplication/          # Android mobile application
    └── app/                # Android app source code

πŸ› οΈ Technology Stack

Data Science & Machine Learning

  • Language: Python 3
  • Libraries:
    • pandas - Data manipulation
    • numpy - Numerical computations
    • scikit-learn - Machine learning algorithms
    • xgboost - Gradient boosting framework
  • Models: Random Forest Regressor, XGBoost Regressor

Backend API

  • Framework: Flask
  • Deployment: Heroku
  • Functionality: RESTful API for predictions

Mobile Application

  • Platform: Android
  • Language: Java
  • IDE: Android Studio
  • Backend Services: Firebase
  • Features: Real-time predictions, location-based alerts, weather integration

πŸš€ Getting Started

Prerequisites

  • Python 3.7+
  • Jupyter Notebook
  • Android Studio (for mobile app)
  • Firebase account (for backend services)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd disaster-predictor
  2. Install Python dependencies

    cd Integration
    pip install -r requirements.txt
  3. Open preprocessing notebook

    cd Preprocess
    jupyter notebook Preprocess.ipynb
  4. Train models

    cd Modelling/Flood
    jupyter notebook "Model Flood.ipynb"
  5. Run Flask API

    cd Integration
    python app.py
  6. Build Android App

    • Open MyApplication/ in Android Studio
    • Configure Firebase
    • Build and run

πŸ“Š Workflow

1. Data Preprocessing

  • Load and combine multiple datasets
  • Handle missing values
  • Feature engineering
  • Create model-ready datasets

2. Model Training

  • Train Random Forest models
  • Train XGBoost models
  • Evaluate model performance
  • Save trained models

3. API Integration

  • Load trained models
  • Create prediction endpoints
  • Deploy to Heroku
  • Provide REST API services

4. Mobile Application

  • Connect to API
  • Display predictions
  • Show location-based alerts
  • Provide safety information

πŸ” Features

Prediction Capabilities

  • Flood Prediction - Based on rainfall, location, and temporal features
  • Cyclone Prediction - Based on wind speed, location, and temporal features
  • Landslide Prediction - Based on rainfall, location, and temporal features

Prediction Horizon

  • Current day prediction
  • 1-day ahead forecast
  • 2-day ahead forecast
  • 3-day ahead forecast

Mobile App Features

  • User authentication (Firebase)
  • Location-based predictions
  • Real-time weather data
  • Interactive maps
  • Disaster alerts and warnings
  • Safety information and guidelines

πŸ“ˆ Model Performance

Each disaster type uses two models:

  • Random Forest Regressor (RFR) - Ensemble learning approach
  • XGBoost Regressor (XGB) - Gradient boosting approach

Both models provide predictions for comparison and ensemble decision-making.

🌐 API Endpoints

Flood Prediction

POST /predict_flood
Parameters: Location, Location1, Location2, District, Rainfall(mm)
Returns: Predictions for current day + 3 days ahead (RFR and XGB)

Cyclone Prediction

POST /predict_cyclone
Parameters: Location, Location1, Location2, District, Wind Speed(mph) (current + 3 days)
Returns: Predictions for current day + 3 days ahead (RFR and XGB)

Landslide Prediction

POST /predict_landslide
Parameters: Location, Location1, Location2, District, Rainfall(mm)
Returns: Predictions for current day + 3 days ahead (RFR and XGB)

πŸ“± Mobile Application

Key Activities

  • MainActivity - Home screen
  • FloodActivity - Flood predictions
  • CycloneActivity - Cyclone predictions
  • LandslideActivity - Landslide predictions
  • MapActivity - Interactive maps
  • LoginActivity/RegisterActivity - User authentication
  • AboutUsActivity - Project information

Features

  • User registration and login
  • Location-based services
  • Real-time predictions
  • Weather data integration
  • Interactive disaster maps
  • Safety guidelines

πŸ“š Dependencies

Backend (Integration/)

flask
numpy
scikit-learn
pandas
joblib
datetime
xgboost
gunicorn

Data Science (Preprocess & Modelling)

pandas
numpy
scikit-learn
xgboost
matplotlib
seaborn
joblib

πŸ”§ Configuration

Model Files

Trained models are stored as .pkl files:

  • Flood_RFRModel.pkl / Flood_XGBModel.pkl
  • Cyclone_RFRModel.pkl / Cyclone_XGBModel.pkl
  • Landslide_RFRModel.pkl / Landslide_XGBModel.pkl

Mapping Files

  • District_Mapped.txt - District encoding mappings
  • Location_Mapped.txt - Location encoding mappings

πŸ“ Usage

Making Predictions via API

import requests

# Flood prediction example
response = requests.post('https://your-api-url/predict_flood', data={
    'Location': 'Colombo',
    'Location1': 'Western',
    'Location2': 'Colombo',
    'District': 'Colombo',
    'Rainfall(mm)': 150.5
})

predictions = response.json()

Mobile App Usage

  1. Register/Login to the app
  2. Allow location permissions
  3. Select disaster type (Flood/Cyclone/Landslide)
  4. View predictions for your location
  5. Check 3-day forecast
  6. View safety guidelines

🌍 Impact

This system aims to:

  • Save Lives - Early warning enables evacuation
  • Reduce Damage - Proactive preparation
  • Empower Communities - Accessible technology
  • Build Resilience - Data-driven disaster management

About

Multi-hazard early warning system predicting floods, cyclones, and landslides in Sri Lanka using XGBoost, Flask REST API, and an Android app with Firebase.

Topics

Resources

License

Stars

2 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors