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.
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.
β 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
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
A comprehensive exploratory analysis was performed before building the machine learning models.
- Dataset Shape
- Data Types
- Statistical Summary
- Missing Value Analysis
- Duplicate Record Analysis
- Unique Value Analysis
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.
Several preprocessing techniques were applied to improve data quality and model performance.
- β Missing Value Checking
- β Duplicate Record Detection
- β Outlier Detection using IQR
- β Boxplot Analysis
- β Correlation Analysis
- β Weak Feature Analysis
- β Multicollinearity Analysis
- β Feature Scaling using StandardScaler
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.
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.
Dataset Split:
- π Training Data β 80%
- π Testing Data β 20%
Random State:
random_state = 42This ensures reproducible experimental results.
The performance of each model was evaluated using multiple regression 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.
| 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 |
flood-prediction-using-machine-learning/
β
βββ README.md
βββ LICENSE
βββ .gitignore
β
βββ notebook/
β βββ flood_prediction.ipynb
β
βββ report/
β βββ project_report.pdf
β
βββ dataset/
β βββ flood.csv
β
βββ images/
git clone https://github.com/devawais01/flood-prediction-using-machine-learning.gitcd flood-prediction-using-machine-learningpip install numpy pandas matplotlib seaborn scikit-learn notebookjupyter notebookOpen:
notebook/flood_prediction.ipynb
and execute the notebook from top to bottom.
- 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
Muhammad Awais
π GitHub: https://github.com/devawais01
πΌ LinkedIn: https://www.linkedin.com/in/dev-awais01
This project is licensed under the MIT License.
See the LICENSE file for complete license information.