Skip to content

devawais01/flood-prediction-using-machine-learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌊 Flood Prediction Using Machine Learning

Python Jupyter Notebook Scikit-Learn Polynomial Regression MIT License

An end-to-end Machine Learning project that predicts Flood Probability using Polynomial Regression. The project follows a complete machine learning pipelineβ€”from exploratory data analysis and preprocessing to feature engineering, model training, comparison, and evaluationβ€”to accurately estimate flood probability from environmental factors.


πŸ“Œ Project Overview

Floods are among the most devastating natural disasters, causing significant damage to lives, infrastructure, and economies. Predicting flood probability can help authorities make informed decisions regarding disaster preparedness and risk management.

This project develops a predictive machine learning model capable of estimating flood probability using historical flood-related data. Different polynomial model complexities were explored and compared against a K-Nearest Neighbors (KNN) Regression model to identify the most effective approach.


🎯 Objectives

βœ… Analyze the flood dataset using Exploratory Data Analysis (EDA)

βœ… Clean and preprocess the dataset

βœ… Detect outliers and analyze feature relationships

βœ… Train Polynomial Regression models with different polynomial degrees

βœ… Compare Polynomial Regression with KNN Regression

βœ… Evaluate models using multiple regression metrics

βœ… Select the best-performing prediction model


πŸ“Š Dataset

The project uses a flood prediction dataset containing 21 environmental and geographical features used to predict Flood Probability.

The dataset was analyzed to understand:

  • Feature distributions
  • Missing values
  • Duplicate records
  • Outliers
  • Correlations
  • Multicollinearity
  • Data quality

πŸ” Exploratory Data Analysis (EDA)

A comprehensive exploratory analysis was performed before building the machine learning models.

βœ” Dataset Inspection

  • Dataset Shape
  • Data Types
  • Statistical Summary
  • Missing Value Analysis
  • Duplicate Record Analysis
  • Unique Value Analysis

βœ” Data Visualization

The following visualizations were created to better understand the dataset:

  • πŸ“ˆ Correlation Heatmaps
  • πŸ“‰ Histograms
  • πŸ“¦ Boxplots
  • 🎻 Violin Plots
  • 🌐 Pair Plots
  • πŸ“Š Pie Charts
  • πŸ“Œ KDE (Kernel Density Estimation) Plots
  • 🧊 3D Visualizations

These visualizations helped identify data distributions, feature relationships, outliers, and important patterns before model development.


βš™οΈ Data Preprocessing

Several preprocessing techniques were applied to improve data quality and model performance.

Preprocessing Pipeline

  • βœ… Missing Value Checking
  • βœ… Duplicate Record Detection
  • βœ… Outlier Detection using IQR
  • βœ… Boxplot Analysis
  • βœ… Correlation Analysis
  • βœ… Weak Feature Analysis
  • βœ… Multicollinearity Analysis
  • βœ… Feature Scaling using StandardScaler

πŸ€– Machine Learning Models

🌟 Primary Model β€” Polynomial Regression

Polynomial Regression was selected as the primary prediction model because it can capture non-linear relationships between environmental variables and flood probability.

The project evaluates multiple polynomial complexities:

  • Degree 1
  • Degree 2
  • Degree 3
  • Degree 4

Each model was trained independently and evaluated to determine the optimal polynomial degree.


πŸ”„ Comparison Model β€” KNN Regression

To compare performance, a K-Nearest Neighbors Regression model was also implemented.

Configuration:

  • n_neighbors = 5

The same training and testing data were used to ensure a fair comparison between both algorithms.


πŸ§ͺ Model Training

Dataset Split:

  • πŸ“š Training Data β€” 80%
  • πŸ“ Testing Data β€” 20%

Random State:

random_state = 42

This ensures reproducible experimental results.


πŸ“ Model Evaluation

The performance of each model was evaluated using multiple regression metrics.

Evaluation Metrics

  • πŸ“Œ Mean Absolute Error (MAE)
  • πŸ“Œ Mean Squared Error (MSE)
  • πŸ“Œ Root Mean Squared Error (RMSE)
  • πŸ“Œ RΒ² Score
  • πŸ“Œ Mean Absolute Percentage Error (MAPE)

These metrics provide a comprehensive understanding of prediction accuracy and model generalization.


πŸ› οΈ Technologies Used

Technology Purpose
🐍 Python Programming Language
πŸ““ Jupyter Notebook Development Environment
🐼 Pandas Data Manipulation
πŸ”’ NumPy Numerical Computing
πŸ“Š Matplotlib Data Visualization
πŸ“ˆ Seaborn Statistical Visualization
πŸ€– Scikit-learn Machine Learning

πŸ“ Project Structure

flood-prediction-using-machine-learning/
β”‚
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ notebook/
β”‚   └── flood_prediction.ipynb
β”‚
β”œβ”€β”€ report/
β”‚   └── project_report.pdf
β”‚
β”œβ”€β”€ dataset/
β”‚   └── flood.csv
β”‚
└── images/

πŸš€ Getting Started

Clone the Repository

git clone https://github.com/devawais01/flood-prediction-using-machine-learning.git

Navigate to the Project

cd flood-prediction-using-machine-learning

Install Required Libraries

pip install numpy pandas matplotlib seaborn scikit-learn notebook

Launch Jupyter Notebook

jupyter notebook

Open:

notebook/flood_prediction.ipynb

and execute the notebook from top to bottom.


🌱 Future Enhancements

  • Implement additional regression algorithms (Random Forest, XGBoost, SVR)
  • Perform automated hyperparameter tuning
  • Build an interactive prediction dashboard
  • Deploy the trained model as a web application
  • Integrate real-time weather and hydrological datasets
  • Explore deep learning techniques for flood prediction

πŸ‘¨β€πŸ’» Author

Muhammad Awais

πŸ”— GitHub: https://github.com/devawais01

πŸ’Ό LinkedIn: https://www.linkedin.com/in/dev-awais01


πŸ“„ License

This project is licensed under the MIT License.

See the LICENSE file for complete license information.

About

End-to-end machine learning project for flood probability prediction using Polynomial Regression, featuring exploratory data analysis, data preprocessing, feature engineering, model comparison with KNN Regression, and comprehensive performance evaluation.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors