Penerapan Algoritma K-Nearest Neighbors untuk Klasifikasi Kualitas Air Minum
DOI:
https://doi.org/10.54259/jdmis.v3i2.4513Keywords:
K-Nearest Neighbors, Klasifikasi, Machine Learning, Kelayakan Air Minum, Kualitas AirAbstract
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.
Downloads
References
Nurmahaludin, “Klasifikasi Kualitas Air Pdam Menggunakan Algoritma Knn Dan K-means,” Klasifikasi Kualitas Air Pdam Menggunakan Algoritma Knn Dan K-means, vol. 1, no. 1, 2019.
A. Muhtar , P. Wibawa , and M. Kallista, “Klasifikasi Kualitas Sungai Air Menggunakan Metode Pembelajaran Mesin k-Nearest Neighbour,” Klasifikasi Kualitas Sungai Air Menggunakan Metode Pembelajaran Mesin k-Nearest Neighbour, vol. 11, no. 1, Feb. 2024.
M. Syarifuddin, “Klasifikasi Kualitas Air Pada Program Penyediaan Air Minum Dan Sanitasi Berbasis Masyarakat Desa Semenpinggir Dengan Metode Algoritma K-Nearest Neighbor,” Klasifikasi Kualitas Air Pada Program Penyediaan Air Minum Dan Sanitasi Berbasis Masyarakat Desa Semenpinggir Dengan Metode Algoritma K-Nearest Neighbor, vol. 2, no. 1, Mar. 2024.
United States, “The Sustainable Development Goals Report,” The Sustainable Development Goals Report, vol. 1, no. 1, 2021.
World Health Organization, “Progress on household drinking water, sanitation and hygiene, 2000-2020: Five years into the SDGs,” Unicef Data. [Online]. Available: https://data.unicef.org/resources/progress-on-household-drinking-water-sanitation-and-hygiene-2000-2020/
World Health Organization: WHO, “Drinking-water,” World Health Organization: WHO, Sep. 13, 2023. [Online]. Available: https://www.who.int/news-room/fact-sheets/detail/drinking-water
P. Sawant, “Physico-chemical parameters for testing of water – A review,” Physico-chemical parameters for testing of water – A review, vol. 3, no. 3, 2012.
S. Putri, “Penerapan Metode SVM pada Klasifikasi Kualitas Air,” Penerapan Metode SVM pada Klasifikasi Kualitas Air, vol. 3, no. 2, 2023.
Q. Jemila, Dhanalakshmi, and Amutha, “Water Quality Prediction Using Decision Tree and KNN,” Water Quality Prediction Using Decision Tree and KNN, vol. 9, no. 1, Jan. 2024.
M. Hasin, “Penerapan Neural Network sebagai Klasifikasi Kualitas Air Hasil Filtrasi Reverse Osmosis,” Penerapan Neural Network sebagai Klasifikasi Kualitas Air Hasil Filtrasi Reverse Osmosis, vol. 11, no. 3, Sep. 2024.
Kemenkes, Profil Kesehatan Indonesia. Kementrian Kesehatan, 2022.
T. Brian, “Application of K-Nearest Neighbor (KNN) Algorithm to Predict Drinking Water Quality,” Application of K-Nearest Neighbor (KNN) Algorithm to Predict Drinking Water Quality, vol. 5, no. 1, Jan. 2025.
S. Ulum, R. F. Alifa, P. Rizkika, and C. Rozikin, “Perbandingan Performa Algoritma KNN dan SVM dalam Klasifikasi Kelayakan Air Minum,” Generation Journal, vol. 7, no. 2, Jul. 2023.
Pangaribuan, J. J., Maulana, A., & Romindo, R. (2024). UNLEASHING THE POWER OF SVM AND KNN: ENHANCED EARLY DETECTION OF HEART DISEASE. JITK (Jurnal Ilmu Pengetahuan dan Teknologi Komputer), 10(2), 342-351.
S. Jadhav, “Comparative Study of K-NN, Naive Bayes and Decision Tree Classification Techniques,” International Journal of Science and Research (IJSR), vol. 5, no. 1, 2016.
A. Kumar, “Review on Data Mining Techniques for Prediction of Water Quality,” Review on Data Mining Techniques for Prediction of Water Quality, vol. 6, no. 6, Jun. 2019.
P. Padmaja, “Water Quality Prediction Using Machine Learning Algorithms,” Water Quality Prediction Using Machine Learning Algorithms, vol. 10, no. 4, Apr. 2023.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 Jansen Jansen, Cariven Tanova, Dariel Dariel, Marciano Marciano, Ade Maulana

This work is licensed under a Creative Commons Attribution 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under Creative Commons Attribution 4.0 International License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (Refer to The Effect of Open Access).























