# Application of Machine Learning Models in Optimizing Wastewater Treatment Processes: A Review
## 4 Classification of ML Models Applied in the Optimization of Wastewater Treatment Processes
### ML Models Applied in the Optimization of Wastewater Treatment Processes
#### 4.1.3 K-Nearest Neighbors (KNNs) and Regression Trees (RTs)  
KNNs and RTs are ML techniques used for classification and regression purposes, each with a set of advantages and limitations regarding wastewater quality prediction and optimization. KNNs are known to be a lazy learning algorithm, which in the data classification process uses the majority class (determined using the Euclidean distance metric) of their k-nearest neighbors. Although they can be computationally intensive and sensitive to the features' scale, KNNs are efficient for nonlinear data distributions [41; 69; 76]. Despite their limitation regarding the handling of high-dimensional data, KNNs were successfully applied in environmental optimization processes, environmental monitoring, water quality prediction and modeling, and so on [52; 66; 76]. Being robust to overfitting, RTs (such as those used in RFs) are based on the decision tree algorithms (the data are divided into data subsets; the multiple trees' outputs are aggregated) for the continuous output prediction process, with this reducing the data variance and improving the prediction accuracy [71; 77]. Maybe the most important of RTs' advantages is their ability to work with linear and nonlinear relationships between data and their interpretability, thus surpassing models like KNNs when it comes to complex prediction tasks [52; 71]. KNNs (because of their efficiency in working with complex wastewater datasets) and RTs (preferred for their interpretability, scalability, and ability to model intricate data patterns) have been successfully applied in wastewater treatment optimization processes (such as wastewater quality prediction and management, resources and energy consumption reduction), in groundwater quality prediction, and so on, with the selection of one of these two models depending on the process characteristics [52; 69; 74; 77; 78]. In addition, KNNs' flexibility is a very important advantage in wastewater optimization, because, in a WWTP, the inputs are highly variable and influenced by many factors. Also, KNNs' ability to work efficiently with very large datasets and their robustness to noisy data make them a useful tool for prediction tasks and real-time monitoring of the WWTP processes [52]. Regarding RTs, because they are easy to use and interpret, and because they provide a visual representation of the decision-making process, they ensure a good and in-depthunderstanding of different inputs' influence on the plant outputs, in order to provide informed human operators' decisions. Also, their ability to model nonlinear relationships (due to the complex interactions between physical, chemical, and biological WWTP processes) without extensive data preprocessing makes them a very good tool for wastewater treatment optimization [52]. Overall, KNNs and RTs can be integrated (because they can handle various data types, are providing interpretable results, etc.) with other ML techniques in order to optimize WWTP operation (improved prediction accuracy, higher operational plant efficiency, enhanced wastewater quality management, better prediction of key wastewater parameters, etc.) and to ensure compliance with the environmental normative [5]. In Table 3, the main advantages, disadvantages, and applications of ML models in wastewater treatment optimization processes are presented.