This repository contains an end-to-end Machine Learning project designed to predict whether water is safe for human consumption (potable) based on its chemical and physical properties. The project covers the entire Machine Learning lifecycle, from data preprocessing and pipeline creation to model training and deployment as an interactive web application.
- Live Web App: Try the Predictor on Hugging Face Spaces
- Google Colab Notebook: View the Training Process & Code
- Programming Language: Python
- Machine Learning Library: Scikit-Learn
- Data Manipulation: Pandas, NumPy
- Data Visualization: Matplotlib, Seaborn
- Web Framework: Gradio
- Deployment Platform: Hugging Face Spaces
- Data Preprocessing: Handled missing values using Mean Imputation and capped outliers using the Interquartile Range (IQR) method to ensure data quality.
- Feature Engineering: Categorized the
pHvalues into three distinct groups (Acidic, Neutral, Alkaline) and applied One-Hot Encoding to improve model comprehension. - Model Selection: Evaluated multiple algorithms (Logistic Regression, Decision Tree, AdaBoost, and XGBoost). Random Forest Classifier was selected as the final model due to its superior accuracy.
- Hyperparameter Tuning: Utilized
RandomizedSearchCVto find the optimal hyperparameters for the Random Forest model. - Machine Learning Pipeline: Built a robust Scikit-Learn
PipelinecombiningStandardScalerand the tunedRandomForestClassifierto automatically scale and predict new incoming user data. - Web Application Deployment: Developed an interactive user interface using Gradio and successfully deployed the packaged pipeline to Hugging Face Spaces.
If you want to run this project on your local machine, follow these steps:
1. Clone the repository:
git clone [https://github.com/coderzaman/Water-Potability-Predictor.git](https://github.com/coderzaman/Water-Potability-Predictor.git)
cd Water-Potability-Predictor
2. Create and activate a virtual environment (Recommended):
python -m venv venv
# For Linux/Mac:
source venv/bin/activate
# For Windows:
# venv\Scripts\activate
3. Install required dependencies:
pip install -r requirements.txt
4. Run the Gradio App:
python app.py
Click on the local URL provided in the terminal (e.g., http://127.0.0.1:7860) to view the app in your browser.
app.py: The main script for the Gradio web application.water_pipeline.pkl: The exported Scikit-Learn pipeline (contains both the Scaler and the Random Forest Model).requirements.txt: List of required Python libraries to run the project.Water_Quality_Prediction.ipynb: The primary notebook containing data analysis, model training, and evaluation steps.
Author: Aktaruzzaman
B.Sc. in Computer Science & Engineering