scieee AI-readable full text Open interactive document viewer

Water quality prediction based on machine learning and comprehensive weighting methods

Wang, Xianhe; Li, Ying; Qiao, Qian; Tavares, Adriano; Liang, Yanchun

Abstract

In the context of escalating global environmental concerns, the importance of preserving water resources and upholding ecological equilibrium has become increasingly apparent. As a result, the monitoring and prediction of water quality have emerged as vital tasks in achieving these objectives. However, ensuring the accuracy and dependability of water quality prediction has proven to be a challenging endeavor. To address this issue, this study proposes a comprehensive weight-based approach that combines entropy weighting with the Pearson correlation coefficient to select crucial features in water quality prediction. This approach effectively considers both feature correlation and information content, avoiding excessive reliance on a single criterion for feature selection. Through the utilization of this comprehensive approach, a comprehensive evaluation of the contribution and importance of the features was achieved, thereby minimizing subjective bias and uncertainty. By striking a balance among various factors, features with stronger correlation and greater information content can be selected, leading to improved accuracy and robustness in the feature-selection process. Furthermore, this study explored several machine learning models for water quality prediction, including Support Vector Machines (SVMs), Multilayer Perceptron (MLP), Random Forest (RF), XGBoost, and Long Short-Term Memory (LSTM). SVM exhibited commendable performance in predicting Dissolved Oxygen (DO), showcasing excellent generalization capabilities and high prediction accuracy. MLP demonstrated its strength in nonlinear modeling and performed well in predicting multiple water quality parameters. Conversely, the RF and XGBoost models exhibited relatively inferior performance in water quality prediction. In contrast, the LSTM model, a recurrent neural network specialized in processing time series data, demonstrated exceptional abilities in water quality prediction. It effectively captured the dynamic patterns present in time series data, offering stable and accurate predictions for various water quality parameters.

Full text

Citation: Wang, X.; Li, Y.; Qiao, Q.; Tavares, A.; Liang, Y. Water Quality Prediction Based on Machine Learning and Comprehensive Weighting Methods. Entropy 2023,25, 1186. https://doi.org/10.3390/ e25081186 Academic Editor: Jose Santamaria Received: 30 June 2023 Revised: 26 July 2023 Accepted: 2 August 2023 Published: 9 August 2023 Copyright: © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/). entropy Article Water Quality Prediction Based on Machine Learning and Comprehensive Weighting Methods Xianhe Wang 1,2 , Ying Li 1,2, Qian Qiao 1, Adriano Tavares 2and Yanchun Liang 3,4,* 1 School of Applied Chemistry and Materials, Zhuhai College of Science and Technology, Zhuhai 519041, China; [email protected] (X.W.); [email protected] (Y.L.) 2Department of Industrial Electronics, School of Engineering, University of Minho, 4704-553 Braga, Portugal 3School of Computer Science, Zhuhai College of Science and Technology, Zhuhai 519041, China 4Key Laboratory of Symbol Computation and Knowledge Engineering of the Ministry of Education, College of Computer Science and Technology, Jilin University, 2699 Qianjin Street, Changchun 130012, China *Correspondence: [email protected] Abstract: In the context of escalating global environmental concerns, the importance of preserving water resources and upholding ecological equilibrium has become increasingly apparent. As a result, the monitoring and prediction of water quality have emerged as vital tasks in achieving these objectives. However, ensuring the accuracy and dependability of water quality prediction has proven to be a challenging endeavor. To address this issue, this study proposes a comprehensive weight-based approach that combines entropy weighting with the Pearson correlation coefficient to select crucial features in water quality prediction. This approach effectively considers both feature correlation and information content, avoiding excessive reliance on a single criterion for feature selection. Through the utilization of this comprehensive approach, a comprehensive evaluation of the contribution and importance of the features was achieved, thereby minimizing subjective bias and uncertainty. By striking a balance among various factors, features with stronger correlation and greater information content can be selected, leading to improved accuracy and robustness in the feature-selection process. Furthermore, this study explored several machine learning models for water quality prediction, including Support Vector Machines (SVMs), Multilayer Perceptron (MLP), Random Forest (RF), XGBoost, and Long Short-Term Memory (LSTM). SVM exhibited commendable performance in predicting Dissolved Oxygen (DO), showcasing excellent generalization capabilities and high prediction accuracy. MLP demonstrated its strength in nonlinear modeling and performed well in predicting multiple water quality parameters. Conversely, the RF and XGBoost models exhibited relatively inferior performance in water quality prediction. In contrast, the LSTM model, a recurrent neural network specialized in processing time series data, demonstrated exceptional abilities in water quality prediction. It effectively captured the dynamic patterns present in time series data, offering stable and accurate predictions for various water quality parameters. Keywords: water quality prediction; comprehensive weight-based approach; feature selection; machine learning; LSTM 1. Introduction With the increasing human activities associated with industrialization and urbanization development, the water quality of coastal rivers is facing escalating and severe threats and degradation [ 1 ]. Coastal rivers play a critical role in connecting land and ocean, and the water quality directly impacts the well-being and sustainable development of coastal ecosystems. Therefore, it is imperative to recognize and address the pressing issue of deteriorating water quality in coastal rivers [ 2 ]. To protect river water quality, maintain the integrity of coastal ecosystems, and ensure sustainable human development, effective management and protection measures must be implemented [ 3 ]. Advanced technological Entropy 2023,25, 1186. https://doi.org/10.3390/e25081186 https://www.mdpi.com/journal/entropy Entropy 2023,25, 1186 2 of 20 means and scientific methods should be employed to strengthen water quality monitoring, early warning systems, and governance capabilities [4]. Traditional river water quality monitoring and warning technology relies on theoretical models that encompass physical, chemical, and biological processes [5]. These models describe and predict changes in water quality parameters by establishing mathematical equations. Mechanism models typically consider factors such as water flow velocity, flow rate, water quality parameters, as well as the transport and transformation of pollutants [ 6 ]. Common mechanism models include hydrodynamic models, water quality models, and ecological models. Traditional water-quality-monitoring and early warning technologies based on mechanism models offer certain advantages [ 7 ]. They are grounded in a profound understanding of hydrology, hydrodynamics, water quality, and ecological processes, thereby exhibiting high interpretability and reliability [ 8 ]. These models enable quantitative prediction and analysis of water quality variations, facilitating the assessment of the health of the water environment and the formulation of strategies to improve water quality [ 9 ]. However, traditional mechanism models also possess certain limitations. Firstly, they typically require extensive input data and parameters, including flow rate, rainfall, sediment characteristics, etc., which entail complex data acquisition and processing [ 10 ]. Secondly, establishing and calibrating the model necessitate deep professional knowledge and a substantial volume of measured data, demanding high technical expertise [ 11 ]. Moreover, the representation of complex water environments and ecosystems by mechanism models may involve simplifications and idealizations that fail to fully capture the complexity of real-world situations. In recent years, there has been extensive research and applications of machine-learning- based technology for predicting river water quality [ 12 ]. In the context of river water quality prediction, machine learning utilizes a large amount of historical water quality data to construct accurate prediction models and enable early warning. This technology offers several advantages [ 13 ]. Firstly, it facilitates real-time and continuous monitoring and prediction of water quality, enhancing the responsiveness and effectiveness of water quality management. Secondly, machine learning models can automatically learn and adapt to the complex relationships within water quality data, resulting in more-accurate predictions [ 14 ]. Additionally, these models can incorporate other environmental factors and meteorological data, thereby improving the accuracy and reliability of water quality prediction. However, machine learning methods also face challenges and limitations in predicting river water quality. Issues such as data quality and missing data can impact the model’s performance [ 15 ]. Moreover, training and parameter selection require a certain level of professional knowledge and experience. Additionally, the interpretability of the model is relatively low, making it difficult to interpret the predicted results. Therefore, further research and improvement are necessary to enhance the effectiveness and reliability of machine learning in river water quality prediction. The entropy weighting method is an information-theory-based approach used to evaluate the information content and importance of features [ 16 ]. By computing the entropy value of features, the purity and discriminability of the features can be measured [ 17 ]. By combining the Pearson correlation coefficient with the entropy weighting method, the correlation and information content of the features can be comprehensively considered, avoiding over-reliance on a single criterion for feature selection. This approach enables a more-comprehensive evaluation of the contribution and importance of features, reducing subjectivity and uncertainty. By balancing different factors, features with higher correlation and greater information content can be selected, thereby improving the accuracy and stability of feature selection. Both the Pearson correlation coefficient and the entropy weighting method are relatively simple and intuitive approaches, making them easy to understand and interpret [ 18 ]. By integrating them into feature selection in machine learning, featureselection results with higher interpretability and practicality can be obtained. This enhances the transparency and reliability of the feature-selection process, helping decision-makers Entropy 2023,25, 1186 3 of 20 understand the importance and contribution of features while improving the performance and interpretability of the model [19]. The objective of this study was to utilize machine learning techniques, in conjunction with the entropy weight method and Pearson correlation coefficient method as featureselection methods, to achieve high-precision prediction of major water quality indicators, such as Dissolved Oxygen (DO), Ammonia Nitrogen (NH 3 -N), Total Phosphorus (TP), and Total Nitrogen (TN). The models considered in this study encompass Long Short-Term Memory (LSTM), Support Vector Machine (SVM), Multilayer Perceptron (MLP), Random Forest (RF), and XGBoost. LSTM, as a variant of the Recurrent Neural Network (RNN) suitable for processing time series data, exhibited superior performance in predicting water quality changes. By inputting historical water quality data as time series, the LSTM model can be used to effectively capture long-term dependencies and accurately forecast future trends in water quality changes. Furthermore, other machine learning models offer distinct advantages and applicability in water quality prediction, enabling the selection of appropriate models based on specific requirements. 2. Materials and Methods 2.1. Data Acquisition The data used for this research were sourced from the China Environmental Monitoring General Station, specifically from the monitoring point at Shijiaoju Section in the Pearl River Basin. The dataset comprises water quality measurements collected at four-hour intervals, covering the time period from 8 November 2020 to 28 February 2023. In total, there are 5058 samples in this dataset, encompassing 9 water quality parameters: Ammonia Nitrogen (NH 3 -N), water Temperature (Temp), pH, Dissolved Oxygen (DO), the permanganate index (KMnO 4 , Total Phosphorus (TP), Total Nitrogen (TN), Conductivity (Cond), and Turbidity (Turb). 2.2. Data Preprocessing Data preprocessing is a vital step in machine learning, encompassing various tasks such as handling outliers, missing values, and data normalization [ 20 ]. For this study, historical monitoring data were collected, including water quality indicators such as temperature, pH, the potassium permanganate index, dissolved oxygen, ammonia nitrogen, total phosphorus, total nitrogen, turbidity, and conductivity. Firstly, outlier detection was performed on the data. Outliers can arise due to sensor malfunctions, human errors, or other factors, resulting in abnormal data points. Statistical analysis is commonly employed for outlier detection, involving calculations of the mean and standard deviation to identify values significantly deviating from the mean. If outliers are detected, they can be treated as missing values or corrected based on the specific circumstances [ 21 ]. Next, the focus was placed on addressing missing values in the data. Linear interpolation was utilized in this study to fill in the missing values. Linear interpolation estimates the missing values by considering the linear relationship between known data points. Specifically, for time series data, the observed values of the preceding and succeeding time points are used to perform linear interpolation and estimate the missing values. Suppose we want to estimate the missing value xbetween the known data points x1and x2, corresponding to observed values y1 and y2 , respectively. The linear interpolation formula for estimating the value y is as follows: y=y1+(x−x1)y2−y1 x2−x1(1) Here, (x −x1 ) represents the offset of xrelative to x1 and (( y2−y1 )/( x2−x1 )) represents the slope from x1 to x2 . By multiplying the offset by the slope and adding it to y1 , the missing value y can be estimated [22]. The advantages of linear interpolation include its simplicity, ease of use, and the ability to produce reasonably accurate estimation results in certain cases [ 23 ]. However, linear interpolation also has limitations. Firstly, it assumes a linear relationship between data Entropy 2023,25, 1186 4 of 20 points, which may not hold true in all situations. Secondly, it requires a high density of data points, and sparse or unevenly distributed data may lead to inaccurate estimates. Additionally, linear interpolation cannot capture nonlinear trends or special patterns in the data [ 24 ]. Therefore, when applying linear interpolation, it is crucial to assess the characteristics and validity of the data within the specific context and consider the suitability of alternative interpolation methods [25]. Lastly, data normalization will be performed to eliminate dimensional differences among different water quality indicators [ 26 ]. The chosen method was min–max normalization, which linearly transforms the data to a specific range, typically [0, 1] or [ −1, 1 ], ensuring that feature variables have similar scales. Min–max normalization can be calculated using the following formula: XN=X−Xmin Xmax −Xmin (2) Here, XN represents the normalized value, X represents the original value, Xmin represents the minimum value and Xmax represents the maximum value. This formula maps the original data to a range between 0 and 1. By following these data preprocessing steps, we can obtain cleaned and prepared data suitable for the subsequent feature selection, training, and prediction of machine learning models. This process will enhance the accuracy and stability of the models and provide a reliable foundation for predicting river water quality. 2.3. Feature Variable Selection 2.3.1. Entropy Weighting Method The entropy weight method is a technique employed to determine the weights of multiple indicators. It utilizes the concept of entropy to measure the uncertainty or diversity of indicators by computing their information entropy [ 27 ]. This method finds widespread application in multi-indicator decision-making, evaluation, and ranking, aiding in addressing challenges associated with trade-offs and optimization among multiple indicators [ 28 ]. The steps involved in calculating weights using the entropy weighting method based on information entropy are as follows: • Calculate information entropy: Compute the information entropy for each indicator. The information entropy quantifies the uncertainty or diversity of an indicator, with higher entropy values indicating greater diversity. The calculation formula for the information entropy is as follows: H(X)=−∑(Pi×log2Pi)(3) Here, H(X) represents the information entropy of the indicator and Pi represents the normalized value of the indicator. • Calculate information weight: Determine the information weight for each indicator based on its information entropy. The calculation formula for the information weight is as follows: Wi=(1−H(Xi)) (4) Here, Wi denotes the information weight of indicator Xi and H(Xi) represents the information entropy of indicator Xi. The information weight reflects the level of information contained within an indicator. A higher information weight signifies a greater impact of the indicator on the decision outcome. Hence, information weights can be utilized to assess the significance of indicators and their contributions to the decision-making process. By calculating the information entropy and information weights for each indicator, a weight vector can be derived for subsequent tasks such as multi-indicator decision-making, evaluation, or optimization [ 29 ]. Incorporating information weights assists decision-makers in making informed trade-offs Entropy 2023,25, 1186 5 of 20 and selections among indicators, thus enhancing the accuracy and credibility of decisions. However, it is essential to recognize that information weights solely consider the diversity and uncertainty of indicators, disregarding their interrelationships. Therefore, in practical applications, it is crucial to consider additional methods or domain knowledge to comprehensively assess the indicators [30]. According to the analysis presented in Table 1and Figure 1, several variables stand out with relatively higher weights. Specifically, NH 3 -N, DO, KMnO 4 , TP, Cond, and Turb exhibit higher weights compared to other variables. Among these, NH 3 -N, Cond, and Turb emerge as particularly influential indicators, indicating their significance and stronger influence on the decision outcome. Conversely, Temp, pH, and TN display relatively lower weights, implying their diminished importance and weaker impact on the decision outcome. Table 1. Results of information weight calculation using entropy weight method. Variables Mean Standard Deviation CV Coefficient 1Weight 2 NH3-N 0.484 0.464 0.958 0.232 Temp 24.504 4.763 0.194 0.047 pH 7.554 0.540 0.072 0.017 DO 7.887 3.642 0.462 0.112 KMnO43.715 1.591 0.428 0.104 TP 0.110 0.047 0.427 0.103 TN 3.274 0.672 0.205 0.050 Cond 1264.521 979.968 0.775 0.188 Turb 49.761 30.356 0.610 0.148 1CV coefficient = standard deviation/mean. 2The weights are calculated by normalizing the CV coefficients. Figure 1. Information weight distribution map (according to Table 1). 2.3.2. Pearson Correlation Coefficient Method The Pearson correlation coefficient is a statistical measure utilized to evaluate the linear correlation between two continuous variables [ 31 ]. It provides information about the strength and direction of the linear relationship between the variables, making it a commonly employed method for feature variable selection and evaluation [ 32 ]. The coefficient, denoted as “r”, ranges from − 1 to 1. A value of r = 1 indicates a perfect positive linear relationship, while r = − 1 indicates a perfect negative linear relationship. A value of Entropy 2023,25, 1186 6 of 20 r = 0 suggests no linear relationship, indicating no correlation between the variables. The calculation formula is as follows: R=∑(Xi−Xmean)(Yi−Ymean) NXstdYstd (5) Here, Rrepresents the Pearson correlation coefficient, Xi and Yi denote the values of the variables in the observation matrix, Xmean and Ymean represent the means of the variables, Xstd and Ystd represent the standard deviations of the variables, and Ndenotes the number of observations in the sample. According to Figure 2, significant correlation coefficients were observed between NH 3 - N and pH, DO, KMnO 4 , TP, and TN, indicating a substantial relationship. DO exhibited significant correlation coefficients with NH 3 -N, temperature, pH, KMnO 4 , TP, conductivity, and turbidity, indicating significant relationships. Similarly, TP showed significant correlation coefficients with NH 3 -N, temperature, pH, DO, KMnO 4 , TN, conductivity, and turbidity, indicating significant relationships. Likewise, TN exhibited significant correlation coefficients with NH 3 -N, temperature, pH, KMnO 4 , TP, conductivity, and turbidity, indicating significant relationships. Figure 2. Visualization of Pearson correlation. 2.3.3. Comprehensive Weight Method The comprehensive weight method is an approach for selecting feature variables that combines the Pearson correlation coefficient method and the entropy weight method. It aims to evaluate and select feature variables by calculating their comprehensive weights, which are obtained by multiplying the Pearson correlation coefficient value of each feature variable with its corresponding information weight. The formula for calculating the comprehensive weight is as follows: VCW =VPCC ×VIW (6) Here, VCW represents the comprehensive weight, VPCC represents the Pearson correlation coefficient, and VIW represents the information weight. A higher comprehensive weight indicates a greater importance and relevance of the feature variable in predicting the target variable. The comprehensive weight method offers the advantage of considering both linear relationships and importance factors, resulting in a more-comprehensive evaluation and selection of feature variables. This, in turn, improves the accuracy and stability of the feature-selection process. Based on the comprehensive weight calculation results presented Entropy 2023,25, 1186 7 of 20 in Table 2and Figure 3, the following input variables were selected for predicting the respective target variables: • Dissolved Oxygen (DO) prediction: DO, NH 3 -N, Temp, pH, KMnO 4 , TP, Cond, and Turb; • Ammonia Nitrogen (NH3-N) prediction: NH3-N, DO, KMnO4, TP, and TN; • Total Nitrogen (TN) prediction: TN, NH3-N, KMnO4, TP, Cond, and Turb; • Total Phosphorus (TP) prediction: TP, NH 3 -N, Temp, DO, KMnO 4 , TN, Cond, and Turb. Figure 3. The comprehensive weight of input variables under each output variable: ( a ) DO and comprehensive weights of its corresponding input variables; ( b ) NH 3 -N and comprehensive weights of its corresponding input variables; ( c ) TN and comprehensive weights of its corresponding input variables; (d) TP and comprehensive weights of its corresponding input variables. Entropy 2023,25, 1186 8 of 20 Table 2. Summary of comprehensive weight results (The comprehensive weight values of different input variables for predicting the target variable). Variables DO NH3-N TN TP NH3-N 0.091 0.232 0.104 0.142 Temp 0.027 0.001 0.009 0.020 pH 0.014 0.007 0.003 0.007 DO 0.112 0.044 0.006 0.054 KMnO40.053 0.022 0.057 0.015 TP 0.050 0.063 0.048 0.103 TN 0.003 0.022 0.050 0.023 Cond 0.118 0.007 0.079 0.046 Turb 0.052 0.003 0.022 0.049 These selected input variables were determined based on their respective comprehensive weights, which consider both the Pearson correlation coefficient and information weight. By including these variables in the prediction models, it is expected to enhance the accuracy and reliability of the predictions for Dissolved Oxygen (DO), Ammonia Nitrogen (NH3-N), Total Nitrogen (TN), and Total Phosphorus (TP). 2.4. Models 2.4.1. Support Vector Machine Support Vector Machine (SVM) is a popular supervised learning algorithm utilized for classification and regression tasks. Its objective is to discover an optimal hyperplane that effectively separates different classes of samples while maximizing the margin between them, thereby achieving robust generalization performance [ 33 ]. SVM achieves this by mapping the samples into a high-dimensional feature space and identifying the hyperplane that maximizes the margin within this space. This hyperplane is defined as the one with the greatest distance to the nearest samples of different classes, referred to as support vectors, which play a crucial role in determining the hyperplane’s position. SVM demonstrates high accuracy and generalization performance, particularly for small-sized datasets. It exhibits robustness against noise and outliers and is well-suited for handling high-dimensional data. Moreover, the decision function of SVM is based on the support vectors, which provide valuable insights into the data distribution and decision boundary, thus offering interpretability to some extent. However, SVM also has certain limitations. It can be computationally slow when applied to large-scale datasets, and its performance may degrade on high-dimensional data or when dealing with imbalanced classes. Additionally, the selection of appropriate kernel functions and tuning of the related parameters are important considerations when utilizing SVM [34]. 2.4.2. Multilayer Perceptron Multilayer Perceptron (MLP) is a neural network with an input layer, multiple hidden layers, and an output layer. It uses weighted connections and nonlinear activation functions to process data. The network is trained using the backpropagation algorithm, updating weights to minimize prediction errors. MLP excels in modeling complex patterns and can be adjusted to fit different task complexities [ 35 ]. However, training and prediction times may be longer for large-scale or high-dimensional data. The model’s performance depends on factors such as activation functions, the architecture, and the hyperparameters [ 36 ]. Multiple metrics should be used for evaluation, considering the model structure, feature selection, and data distribution. Enhancements can be made through adjustments, optimization, additional features, or alternative algorithms [37]. Entropy 2023,25, 1186 9 of 20 2.4.3. Random Forest Random Forest is an ensemble learning method that constructs multiple weak learners based on decision trees. It combines the predictions of individual trees through voting or averaging to make the final predictions. In each node of the decision tree, Random Forest considers only a random subset of features for splitting. This selective feature consideration reduces the correlation between trees, leading to increased model diversity. To create diverse decision trees, multiple training sets are generated using bootstrap sampling. This process involves randomly selecting samples with replacement from the original training set, enabling the training of different decision trees [ 17 ]. The utilization of bootstrap sampling enhances model diversity and mitigates overfitting. Random Forest generates predictions by aggregating the collective decisions of multiple decision trees. In classification tasks, the prediction is determined by the majority class obtained through voting, while in regression tasks, the average prediction of the multiple decision trees is used. Random Forest models are highly proficient in handling high-dimensional and large-scale data, demonstrating their suitability for complex nonlinear relationships [ 33 ]. Furthermore, they exhibit robustness in the presence of missing values and outliers. 2.4.4. Extreme Gradient Boosting Extreme Gradient Boosting (XGBoost) is an algorithm developed based on the gradient boosting decision trees approach. It enhances model accuracy and efficiency by incorporating regularization techniques and parallel computing. XGBoost leverages the gradient boosting algorithm, which iteratively trains a sequence of decision trees to progressively enhance the predictive model’s performance. Each tree is trained to rectify the prediction errors made by the preceding tree, gradually aligning with the negative gradient of the objective function. To address the risk of overfitting, XGBoost employs various regularization techniques, including L1 and L2 regularization. Additionally, constraints on tree depth and leaf weights are applied to manage the model’s complexity and prevent overfitting. These measures collectively contribute to improving the overall performance and generalization capability of the XGBoost algorithm [38]. 2.4.5. Long Short-Term Memory Long Short-Term Memory (LSTM) is a specialized variant of Recurrent Neural Networks (RNNs) that excels in processing time series data. Unlike conventional RNNs, LSTM incorporates gating mechanisms that effectively capture and retain long-term dependencies [ 39 ]. The core of an LSTM network comprises three essential gate units: the forget gate, the input gate, and the output gate. These gate units regulate the flow and manipulation of information through learnable weights, thereby controlling the input, output, and memory processes. By selectively forgetting, updating, and outputting information, LSTM enables the model to effectively retain and utilize long-term data information, effectively addressing the challenge of long-term dependencies encountered in traditional RNNs. The gating mechanisms employed by LSTM also address the issues of vanishing and exploding gradients, ensuring smooth gradient propagation over extended time intervals [ 40 ]. LSTM exhibits versatility in handling diverse input and output types, including univariate and multivariate time series data, as well as text data. It offers flexibility in adjusting input and output dimensions and possesses strong representational capabilities [ 12 ]. LSTM has achieved remarkable success in various domains such as natural language processing, speech recognition, machine translation, and time series prediction. Consequently, LSTM finds widespread application in modeling and prediction tasks across a wide range of practical problems. 2.4.6. Grid Search (GridSearchCV) In this study, the Grid Search technique (GridSearchCV) was utilized to fine-tune the parameters of the machine learning model and identify the optimal combination of parameters, thereby enhancing the model’s performance and predictive capability. Grid Entropy 2023,25, 1186 16 of 20 Table 6. Performance evaluation of the LSTM model in predicting other water quality variables. Variables R2MSE RMSE NSE DO 0.882 3.361 1.827 0.877 NH3-N 0.830 5.614 2.330 0.829 TN 0.745 5.747 2.352 0.745 TP 0.773 5.683 2.332 0.763 Figure 6. Comparison of LSTM model’s actual and predicted values for other water quality parameters: ( a ) Comparison of true and predicted values of DO; ( b ) Comparison of true and predicted values of NH 3 -N; ( c ) Comparison of true and predicted values of TN; ( d ) Comparison of true and predicted values of TP. However, it is noteworthy that Figure 6c reveals a relatively weaker predictive performance of the LSTM model for TN content, particularly in capturing extreme values accurately. This observation can be attributed to several contributing factors. Firstly, the complexity of the model may not be adequate to capture the intricate nonlinear relationships and long-term dependencies within the data, particularly when predicting extreme values. Therefore, it is recommended to consider utilizing a more-sophisticated model structure or enhancing the model’s capacity to improve its ability to predict extreme values. Secondly, improper feature selection could be another influential factor. Although a comprehensive weight method, along with the entropy weight method and Pearson correlation coefficient method, was employed for feature screening, the selection of individual feature variables may have been subjective. Specifically, when predicting TN content, the input features of the LSTM model may not effectively capture the characteristics necessary to handle extreme information. Thirdly, the presence of noise or outliers in the data can negatively impact the accurate prediction of extreme values by the model. Lastly, insufficient training could also contribute to the relatively weaker performance of the LSTM model. To enhance TN content prediction, it is advisable to increase the training sample size and extend the training duration to enable the model to fully capture extreme patterns. Insufficient training samples or a relatively short training period may hinder the model’s ability to effectively Entropy 2023,25, 1186 17 of 20 capture extreme features. To address these potential limitations, future improvements can include increasing the training sample size, adjusting the model structure, optimizing the feature selection, and conducting longer training sessions to enhance the overall predictive performance of the LSTM model for TN content. The LSTM model’s proficiency in capturing dynamic features and trends in time series data significantly contributed to its accurate prediction of water quality variables. By leveraging its ability to learn temporal relationships and long-term dependencies within the sequence data, the LSTM model excelled in predicting future values of water quality variables. Furthermore, its capability to handle nonlinear relationships and complex temporal patterns further strengthened its performance in predicting water quality variables. 4. Conclusions The primary objective of this study was to evaluate the predictive capabilities of various machine learning models for water quality parameters using the entropy weighting method. A comprehensive weighting method was proposed, which combines the entropy weighting method with the Pearson correlation coefficient method, for feature selection in water quality prediction. This method takes into account both the information entropy of the input features and their correlation with the target variable, effectively identifying the features possessing a significant impact on water quality variable prediction. The method offers valuable insights for subsequent water quality prediction modeling, including feature set selection, the reduction of redundant features, and the optimization of model performance. Multiple machine learning models were investigated for their applicability in water quality prediction, the Support Vector Machine (SVM), Multilayer Perceptron (MLP), Random Forest (RF), XGBoost, and LSTM models. These models demonstrated varying capabilities in water quality prediction. SVM, in particular, exhibited good generalization performance and high prediction accuracy, specifically for the prediction of Dissolved Oxygen (DO). The MLP model, known for its strong nonlinear modeling capability, performed well in predicting DO and NH 3 -N, explaining a significant proportion of the target variable’s variance and exhibiting relatively small prediction errors. In contrast, the RF model, despite its ability to handle high-dimensional data and complex relationships, showed relatively poor performance in water quality prediction. It displayed lower R2 values and higher MSE and RMSE values, indicating larger prediction errors. This could be attributed to the model’s limitations in capturing complex relationships and extreme values in water quality data, leading to decreased prediction accuracy. Similarly, the XGBoost model also exhibited relatively poor predictive performance, with lower R2 values and higher MSE and RMSE values, indicating larger prediction errors. This might be due to the model’s limited ability to capture complex relationship patterns and extreme values in the water quality data, resulting in lower prediction accuracy compared to the other models. The LSTM model demonstrated excellent water quality prediction capabilities. As a recurrent neural network model designed to handle sequential data, LSTM possesses strong memory and long-term dependency modeling capabilities. In water quality prediction, the LSTM model effectively captured dynamic changes in time series data and consistently delivered outstanding predictive performance for various water quality parameters. Its high R2 values and NSE values, along with low MSE and RMSE values, indicated small average prediction errors and significant improvements over simple mean value prediction methods. In summary, the comprehensive weighting method that combines the entropy weighting method and the Pearson correlation coefficient method showed effectiveness in selecting a feature set for water quality prediction, enhancing the predictive performance of the models. Through comparative studies, the LSTM model emerged as the top-performing model for water quality prediction, accurately forecasting variations in different water quality variables in a stable manner. These research findings provide essential insights for Entropy 2023,25, 1186 18 of 20 water quality monitoring and management, assisting water quality management agencies in making informed decisions and devising effective management strategies. However, further research and applications are necessary to explore optimized feature-selection methods, improve machine learning models, and enhance the accuracy and reliability of water quality prediction. Author Contributions: Conceptualization, X.W., Y.L. (Yanchun Liang) and A.T.; methodology, Q.Q.; software, X.W. and Y.L. (Ying Li); validation, A.T., X.W. and Y.L. (Yanchun Liang); formal analysis, X.W. and A.T.; investigation, X.W.; resources, Q.Q.; data curation, X.W. and Y.L. (Ying Li); writing—original draft preparation, X.W.; writing—review and editing, Q.Q., A.T. and Y.L. (Yanchun Liang); visualization, X.W.; supervision, Y.L. (Yanchun Liang); project administration, Y.L. (Ying Li). All authors have read and agreed to the published version of the manuscript. Funding: This research was funded in part by the NSFC Grant Number 61972174, the Guangdong Universities’ Innovation Team Grant Number 2021KCXTD015, the Key Disciplines Projects Grant Number 2021ZDJS138, and the Guangdong Provincial Junior Innovative Talents Project for Ordinary Universities Number 2022KQNCX146. Institutional Review Board Statement: Not applicable. Informed Consent Statement: Not applicable. Data Availability Statement: Datashallbe providedby thecorresponding authorsupon special request . Conflicts of Interest: The authors declare no conflict of interest. References 1. Deng, T.; Chau, K.W.; Duan, H.F. Machine learning based marine water quality prediction for coastal hydro-environment management. J. Environ. Manag. 2021,284, 112051. [CrossRef] [PubMed] 2. Azrour, M.; Mabrouki, J.; Fattah, G.; Guezzaz, A.; Aziz, F. Machine learning algorithms for efficient water quality prediction. Model. Earth Syst. Environ. 2022,8, 2793–2801. [CrossRef] 3. Sinha, K.K.; Gupta, M.K.; Banerjee, M.K.; Meraj, G.; Singh, S.K.; Kanga, S.; Farooq, M.; Kumar, P.; Sahu, N. Neural Network-Based Modeling of Water Quality in Jodhpur, India. Hydrology 2022,9, 92. [CrossRef] 4. Jung, W.S.; Kim, S.E.; Kim, Y.D. Prediction of Surface Water Quality by Artificial Neural Network Model Using Probabilistic Weather Forecasting. Water 2021,13, 2392. [CrossRef] 5. Wang, S.; Peng, H.; Liang, S. Prediction of estuarine water quality using interpretable machine learning approach. J. Hydrol. 2022 , 605, 127320. [CrossRef] 6. Wan H.; Xu, R.; Zhang, M.; Cai, Y.; Li, J.; Shen, X. A novel model for water quality prediction caused by non-point sources pollution based on deep learning and feature extraction methods. J. Hydrol. 2022,612, 128081. [CrossRef] 7. Liu, J.; Wang, X.; Zhao, Y.; Xu, Y.; Pan, Y.; Feng, S.; Liu, J.; Huang, X.; Wang, H. Nh3 plasma functionalization of UiO-66-NH2 for highly enhanced selective fluorescence detection of u (vi) in water. Anal. Chem. 2022,94, 10091–10100. [CrossRef] 8. Zhu, R.; Wang, X.; Panther, J.G.; Wang, Q.; Chakir, S.; Ding, Y.; Huang, Y.; Wang, H. Micro/nanostructured MgO hollow spheres with selective adsorption performance and their application for fluoride monitoring in water. Sep. Purif. Technol. 2022 ,299, 121703. [CrossRef] 9. Seo, D.; Sigdel, R.; Kwon, K.H.; Lee, Y.S. 3-D hydrodynamic modeling of Yongdam Lake, Korea using EFDC. Desalin. Water Treat. 2010,19, 42–48. [CrossRef] 10. Rand, J.M.; Nanko, M.O.; Lykkegaard, M.B.; Wain, D.; King, W.; Bryant, L.D.; Hunter, A. The human factor: Weather bias in manual lake water quality monitoring. Limnol. Oceanogr. Methods 2022,20, 288–303. [CrossRef] 11. Wang, K.; Band, S.S.; Ameri, R.; Biyari, M.; Hai, T.; Hsu, C.C.; Hadjouni, M.; Elmannai, H.; Chau, K.W.; Mosavi, A. Performance improvement of machine learning models via wavelet theory in estimating monthly river streamflow. Eng. Appl. Comput. Fluid Mech. 2022,16, 1833–1848. [CrossRef] 12. Zhu, M.; Wang, J.; Yang, X.; Zhang, Y.; Zhang, L.; Ren, H.; Wu, B.; Ye, L. A review of the application of machine learning in water quality evaluation. Eco-Environ. Health 2022,1, 10. [CrossRef] 13. Alizadeh, M.J.; Kavianpour, M.R.; Danesh, M.; Adolf, J.; Shamshirband, S.; Chau, K.W. Effect of river flow on the quality of estuarine and coastal waters using machine learning models. Eng. Appl. Comput. Fluid Mech. 2018,12, 810–823. [CrossRef] 14. Omambia, A.; Maake, B.; Wambua, A. Water quality monitoring using IoT & machine learning. In Proceedings of the 2022 IST-Africa Conference (IST-Africa 2022), Virtual Conference, 16–20 May 2022; pp. 1–8. https://doi.10.23919/IST-Africa56635.202 2.9845590. 15. Kayhomayoon, Z.; Arya Azar, N.; Ghordoyee Milan, S.; Kardan Moghaddam, H.; Berndtsson, R. Novel approach for predicting groundwater storage loss using machine learning. J. Environ. Manag. 2021,296, 113237. [CrossRef] [PubMed] Entropy 2023,25, 1186 19 of 20 16. Cao, R.; Yuan, J. Selection Strategy of Vibration Feature Target under Centrifugal Pumps Cavitation. Appl. Sci. 2020 ,10, 8190. [CrossRef] 17. Yan, X.; Liu, Y.; Jia, M. A Feature Selection Framework-Based Multiscale Morphological Analysis Algorithm for Fault Diagnosis of Rolling Element Bearing. IEEE Access 2019,7, 123436–123452. [CrossRef] 18. Li, G.; Zhang, A.; Zhang, Q.; Wu, D.; Zhan, C. Pearson correlation coefficient-based performance enhancement of broad learning system for stock price prediction. IEEE Trans. Circuits Syst. II Express Briefs 2022,69, 2413–2417. [CrossRef] 19. Zheng, Y.; Li, Y.; Wang, G.; Chen, Y.; Xu, Q.; Fan, J.; Cui, X. A novel hybrid algorithm for feature selection based on whale optimization algorithm. IEEE Access 2018,7, 14908–14923. [CrossRef] 20. Zhang, Y.; Li, C.; Jiang, Y.; Sun, L.; Zhao, R.; Yan, K.; Wang, W. Accurate prediction of water quality in urban drainage network with integrated EMD-LSTM model. J. Clean. Prod. 2022,354, 131724. [CrossRef] 21. Ransom, K.M.; Nolan, B.T.; Traum, J.A.; Faunt, C.C.; Bell, A.M.; Gronberg, J.A.M.; Wheeler, D.C.; Rosecrans, C.Z.; Jurgens, B.; Schwarz, G.E.; et al. A hybrid machine learning model to predict and visualize nitrate concentration throughout the Central Valley aquifer, California, USA. Sci. Total Environ. 2017,601–602, 1160–1172. [CrossRef] 22. Rostam, N.A.P.; Malim, N.H.A.H.; Abdullah, R.; Ahmad, A.L.; Ooi, B.S.; Chan, D.J.C. A Complete Proposed Framework for Coastal Water Quality Monitoring System With Algae Predictive Model. IEEE Access 2021,9, 108249–108265. [CrossRef] 23. Wang, Z. A Numerical Method for Delayed Fractional-Order Differential Equations. J. Appl. Math. 2013 ,2013, 707–724. [CrossRef] 24. Noor, N.M.; Al Bakri Abdullah, M.M.; Yahaya, A.S.; Ramli, N.A. Comparison of linear interpolation method and mean method to replace the missing values in environmental data set. In Materials Science Forum; Trans Tech Publications: Baech, Switzerland, 2015; Volume 803, pp. 278–281. 25. Liu, P.; Wang, J.; Sangaiah, A.; Xie, Y.; Yin, X. Analysis and Prediction of Water Quality Using LSTM Deep Neural Networks in IoT Environment. Sustainability 2019,11, 2058. [CrossRef] 26. Hu, Z.; Zhang, Y.; Zhao, Y.; Xie, M.; Zhong, J.; Tu, Z.; Liu, J. A Water Quality Prediction Method Based on the Deep LSTM Network Considering Correlation in Smart Mariculture. Sensors 2019,19, 1420. [CrossRef] 27. Kumar, R.; Singh, S.; Bilga, P.S.; Jatin, K.; Pruncu, C.I. Revealing the Benefits of Entropy Weights Method for Multi-Objective Optimization in Machining Operations: A Critical Review. J. Mater. Res. Technol. 2021,10, 1471–1492. [CrossRef] 28. Liu, J.; Hu, Q.; Yu, D. A weighted rough set based method developed for class imbalance learning. Inf. Sci. 2008 ,178, 1235–1256. [CrossRef] 29. Mármol, A.M.; Puerto, J.; Fernández, F.R. The use of partial information on weights in multicriteria decision problems. J. Multi-Criteria Decis. Anal. 2015,7, 322–329. [CrossRef] 30. Salman, R.; Nikoo, M.R.; Shojaeezadeh, S.A.; Beiglou, P.H.B.; Sadegh, M.; Adamowski, J.F.; Alamdari, N. A novel Bayesian maximum entropy-based approach for optimal design of water quality monitoring networks in rivers. J. Hydrol. 2021 , 603, 126822 . [CrossRef] 31. Ly, A.; Marsman, M.; Wagenmakers, E.J. Analytic posteriors for Pearson’s correlation coefficient. Stat. Neerl. 2018 ,72, 4–13. [CrossRef] 32. Qiang, L.; Yang, Y.; Yang, L.; Wang, Y. Comparative analysis of water quality prediction performance based on LSTM in the Haihe River Basin, China. Environ. Sci. Pollut. Res. 2022,30, 7498–7509. [CrossRef] 33. Naghibi, S.A.; Ahmadi, K.; Daneshi, A. Application of Support Vector Machine, Random Forest, and Genetic Algorithm Optimized Random Forest Models in Groundwater Potential Mapping. Water Resour. Manag. 2017,31, 2761–2775. [CrossRef] 34. Kisi, O.; Shiri, J.; Karimi, S.; Shamshirband, S.; Motamedi, S.; Petkovi, D.; Hashim, R. A survey of water level fluctuation predicting in Urmia Lake using support vector machine with firefly algorithm. Appl. Math. Comput. 2015 ,270, 731–743. [CrossRef] 35. Yu, X.; Cui, T.; Sreekanth, J.; Mangeon, S.; Gilfedder, M. Deep learning emulators for groundwater contaminant transport modelling. J. Hydrol. 2020,590, 125351. [CrossRef] 36. Gambín, Á.F.; Angelats, E.; González, J.S.; Miozzo, M.; Dini, P. Sustainable Marine Ecosystems: Deep Learning for Water Quality Assessment and Forecasting. IEEE Access 2021,9, 121344–121365. [CrossRef] 37. Mohammadi, B.; Guan, Y.; Moazenzadeh, R.; Safari, M.J.S. Implementation of hybrid particle swarm optimization-differential evolution algorithms coupled with multi-layer perceptron for suspended sediment load estimation. Catena 2021 ,198, 105024. [CrossRef] 38. Osman, A.I.A.; Ahmed, A.N.; Chow, M.F.; Huang, Y.F.; El-Shafie, A. Extreme gradient boosting (Xgboost) model to predict the groundwater levels in Selangor Malaysia. Ain Shams Eng. J. 2021,12, 1545–1556. [CrossRef] 39. Ni, L.; Wang, D.; Singh, V.P.; Wu, J.; Wang, Y.; Tao, Y.; Zhang, J. Streamflow and rainfall forecasting by two long short-term memory-based models. J. Hydrol. 2020,583, 124296. [CrossRef] 40. Zhanga, J.; Zhub, Y.; Zhanga, X.; Yec, M.; Yangb, J. Developing a Long Short-Term Memory (LSTM) based model for predicting water table depth in agricultural areas. J. Hydrol. 2018,561, 918–929. [CrossRef] 41. Jiang, Y.; Li, C.; Zhang, Y.; Zhao, R.; Yan, K.; Wang, W. Data-driven method based on deep learning algorithm for detecting fat, oil, and grease (FOG) of sewer networks in urban commercial areas. Water Res. 2021,207, 117797. [CrossRef] 42. Jiang, Y.; Li, C.; Song, H.; Wang, W. Deep learning model based on urban multi-source data for predicting heavy metals (Cu, Zn, Ni, Cr) in industrial sewer networks. J. Hazard. Mater. 2022,432, 128732. [CrossRef] Entropy 2023,25, 1186 20 of 20 43. Aldhyani, T.H.H.; Al-Yaari, M.; Alkahtani, H.; Maashi, M. Water Quality Prediction Using Artificial Intelligence Algorithms. Appl. Bionics Biomech. 2020,2020, 6659314. [CrossRef] [PubMed] 44. Qian, J.; Liu, H.; Qian, L.; Bauer, J.; Xue, X.; Yu, G.; He, Q.; Zhou, Q.; Bi, Y.; Norra, S. Water quality monitoring and assessment based on cruise monitoring, remote sensing, and deep learning: A case study of Qingcaosha Reservoir. Front. Environ. Sci. 2022 , 10, 979133. [CrossRef] Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.