Penerapan Algoritma K-Nearest Neighbors untuk Klasifikasi Kualitas Air Minum - Jansen, Jansen; Tanova, Cariven; Dariel, Dariel; Marciano, Marciano; Maulana, Ade (Yayasan Pendidikan Penelitian Pengabdian Algero, 2025)
This study aims to classify drinking water potability based on physical and chemical parameters using the K-Nearest Neighbors (KNN) algorithm. The dataset, sourced from the Kaggle platform, contains 100,000 water samples with nine key attributes, including pH, hardness, total dissolved solids (TDS), sulfate, chloramines, conductivity, organic carbon, trihalomethanes, and turbidity. The target label is potability, indicating whether the water is safe (1) or unsafe (0) for consumption. The preprocessing steps included normalization and splitting the data into training and testing sets. The KNN model was trained by experimenting with various K values to achieve optimal performance. Evaluation using a confusion matrix showed that the model achieved an accuracy of 78%. For the potable class, the model reached a precision of 72%, recall of 91%, and F1-score of 81%. For the non-potable class, it achieved a precision of 88%, recall of 65%, and F1-score of 75%. Although the model tends to misclassify unsafe water as safe, overall performance is promising. These findings suggest that the KNN algorithm can serve as an effective classification approach and has potential for application in automated water quality monitoring systems.