Predicts whether a water sample is safe for drinking using supervised machine learning, comparing a baseline Logistic Regression model against a tuned Random Forest classifier across 9 physicochemical water quality indicators.
Safe drinking water classification is a high-stakes decision problem — false negatives (labeling unsafe water as drinkable) carry serious public health consequences. This project mirrors real-world predictive modeling challenges: class imbalance, missing data, and the tradeoff between precision and recall.
- Source: Kaggle — Water Potability
- 3,276 rows | 9 features | Binary target (Potability: 0 = not drinkable, 1 = drinkable)
- Features: pH, Hardness, Solids, Chloramines, Sulfate, Conductivity, Organic Carbon, Trihalomethanes, Turbidity
- Explored distributions, correlations, and class balance
- Imputed missing values (ph: 491, Sulfate: 781, Trihalomethanes: 162) using median — chosen over mean due to outlier sensitivity
- Stratified 80/20 train-test split
- Standardized features using
StandardScaler
- Established performance floor for classification benchmarking
- 100 estimators, evaluated against baseline
- Demonstrated ensemble advantage over logistic regression
- Parameters tuned:
n_estimators=500,max_depth=10,min_samples_split=[5,10],class_weight='balanced' - 5-fold cross-validation, scored on F1
| Model | Accuracy | F1 Score | ROC-AUC |
|---|---|---|---|
| Logistic Regression | ~60% | baseline | baseline |
| Random Forest (base) | ~66% | +↑ | +↑ |
| Tuned Random Forest | ~67% | best | best |
(Update with your actual output numbers before sharing)
- Accuracy, Precision, Recall, F1 Score, ROC-AUC
- ROC curves and confusion matrices for all 3 models
- Bar + line graph comparison across all three models
- Python, Pandas, NumPy, Scikit-learn
- Matplotlib, Seaborn
- Google Colab / Jupyter Notebook
| File | Description |
|---|---|
BSAN_734_Final_Project_HA.ipynb |
Full pipeline: EDA → modeling → evaluation |
water_potability.csv |
Source dataset |