Abstract
Ensuring safe drinking water is crucial for public health, yet existing assessment methods often fail to capture complex contaminant interactions, provide real-time analysis, or offer model interpretability. Traditional threshold-based evaluations lack adaptability, while many machine learning models are opaque, making it difficult to understand key influencing factors. To address these challenges, we propose SafeH2O, a data-driven framework integrating machine learning and explainability techniques. The system applies data preprocessing, including normalization, feature scaling, and class balancing using SMOTE, to enhance dataset reliability. K-means clustering is employed to categorize water samples, followed by supervised classifiers – such as Random Forest, Logistic Regression, and Gradient Boosting – to predict water potability. Among them, Gradient Boosting achieves the highest accuracy of 93%. To improve interpretability, local interpretable model-agnostic explanations (LIME) is used to analyze key contaminants influencing water quality across clusters. Additionally, we design a health risk assessment microservice that issues real-time contamination alerts and safe water recommendations.