K-Nearest Neighbors Model to Optimize Data Classification According to the Water Quality Index of the Upper Basin of the City of Huarmey
Authors:
- Hugo Vega-HuertaHugo Vega-Huerta
- Jean Pajuelo-LeonJean Pajuelo-Leon
- Percy De-La-Cruz-VdVPDPercy De-La-Cruz-VdV
- David CalderónDCDavid Calderón
- Gisella Luisa Elena Maquen-NiñoGisella Luisa Elena Maquen-Niño
- Milton E. Rios-CastilloMilton E. Rios-Castillo
- Adegundo Camara-FigueroaACAdegundo Camara-Figueroa
- Rubén Gil-CalvoRubén Gil-Calvo
- Luis Guerra-GradosLGLuis Guerra-Grados
- Oscar Benito-PachecoOBOscar Benito-Pacheco
Open Access
- 19 September 2025
- journal article
- research article
- Published by MDPI AG in Applied Sciences
- Vol. 15 (18) , 10202
Abstract
Water quality in Peru is an increasing concern, particularly in the upper Huarmey watershed, which is affected by heavy metal contamination and untreated wastewater. This study proposes an automated classification approach using three supervised machine learning algorithms—K-Nearest Neighbors (KNN), Support Vector Machine (SVM), and Random Forest (RF)—to assess the water quality based on the Water Quality Index (WQI) of Peru. The experimental results show that KNN outperforms other methods, reaching an accuracy of 95.2%. The proposed system automates and improves the classification accuracy compared with manual methods based on Microsoft Excel. The methodology, performance metrics, dataset characteristics, and geographical context are detailed to ensure replicability. This algorithm assists decision-makers with environmental monitoring and public health protection.Keywords
All Related Versions
Funding Information
- Universidad Nacional Mayor de San Marcos (RR_005446-2025-R, C25202481)
This publication has 25 references indexed in Scilit:
- Unlocking policy effects: Water resources management plans and urban water pollutionJournal of Environmental Management, 2024
- An unsupervised water quality anomaly detection method based on a combination of time-frequency analysis and clusteringEnvironmental Science and Pollution Research, 2024
- Diagnosis of Brain Tumors Using a Convolutional Neural Network2023
- Water quality prediction using machine learning models based on grid search methodMultimedia Tools and Applications, 2023
- The seasonal patterns of aquatic insect composition and diversity in a disturbed (sub)tropical river revealed by linear and nonlinear approaches with occurrence and abundance dataHydrobiologia, 2023
- A new robust hybrid model based on support vector machine and firefly meta-heuristic algorithm to predict pistachio yields and select effective soil variablesEcological Informatics, 2023
- Water quality classification using machine learning algorithmsJournal of Water Process Engineering, 2022
- Prediction of the groundwater quality index through machine learning in Western Middle Cheliff plain in North AlgeriaActa Geophysica, 2022
- Ensemble machine learning paradigms in hydrology: A reviewJournal of Hydrology, 2021
- Procedimiento de validación de un método para cuantificar cobalto en suero por espectroscopia de absorción atómica con atomización electrotérmicaRevista del Laboratorio Clínico, 2015