# Water Quality Prediction Using Artificial Intelligence Algorithms

Authors: Theyazn H. H Aldhyani; Mohammed Al-Yaari; Hasan Alkahtani; Mashael Maashi
Journal: Applied Bionics and Biomechanics
 (2020)

---

## Abstract

During the last years, water quality has been threatened by various pollutants. Therefore, modeling and predicting water quality have become very important in controlling water pollution. In this work, advanced artificial intelligence (AI) algorithms are developed to predict water quality index (WQI) and water quality classification (WQC). For the WQI prediction, artificial neural network models, namely nonlinear autoregressive neural network (NARNET) and long short-term memory (LSTM) deep learning algorithm, have been developed. In addition, three machine learning algorithms, namely, support vector machine (SVM),K-nearest neighbor (K-NN), and Naive Bayes, have been used for the WQC forecasting. The used dataset has 7 significant parameters, and the developed models were evaluated based on some statistical parameters. The results revealed that the proposed models can accurately predict WQI and classify the water quality according to superior robustness. Prediction results demonstrated that the NARNET model performed slightly better than the LSTM for the prediction of the WQI values and the SVM algorithm has achieved the highest accuracy (97.01%) for the WQC prediction. Furthermore, the NARNET and LSTM models have achieved similar accuracy for the testing phase with a slight difference in the regression coefficient (RNARNET=96.17% and RLSTM=94.21%). This kind of promising research can contribute significantly to water management.


---

## Body

## 1. Introduction

Water is the most significant resource of life, crucial for supporting the life of most existing creatures and human beings. Living organisms need water with enough quality to continue their lives. There are certain limits of pollutions that water species can tolerate. Exceeding these limits affects the existence of these creatures and threatens their lives.Most ambient water bodies such as rivers, lakes, and streams have specific quality standards that indicate their quality. Moreover, water specifications for other applications/usages possess their standards. For example, irrigation water must be neither too saline nor contain toxic materials that can be transferred to plants or soil and thus destroying the ecosystems. Water quality for industrial uses also requires different properties based on the specific industrial processes. Some of the low-priced resources of fresh water, such as ground and surface water, are natural water resources. However, such resources can be polluted by human/industrial activities and other natural processes.Hence, rapid industrial development has prompted the decay of water quality at a disturbing rate. Furthermore, infrastructures, with the absence of public awareness, and less hygienic qualities, significantly affect the quality of drinking water [1]. In fact, the consequences of polluted drinking water are so dangerous and can badly affect health, the environment, and infrastructures. As per the United Nations (UN) report, about 1.5 million people die each year because of contaminated water-driven diseases. In developing countries, it is announced that 80% of health problems are caused by contaminated water. Five million deaths and 2.5 billion illnesses are reported annually [2]. Such a mortality rate is higher than deaths resulting from accidents, crimes, and terrorist attacks [3].Therefore, it is very important to suggest new approaches to analyze and, if possible, to predict the water quality (WQ). It is recommended to consider the temporal dimension for forecasting the WQ patterns to ensure the monitoring of the seasonal change of the WQ [4]. However, using a special variation of models together to predict the WQ grants better results than using a single model [5–7]. There are several methodologies proposed for the prediction and modeling of the WQ. These methodologies include statistical approaches, visual modeling, analyzing algorithms, and predictive algorithms. For the sake of the determination of the correlation and relationship among different water quality parameters, multivariate statistical techniques have been employed [4]. The geostatistical approaches were used for transitional probability, multivariate interpolation, and regression analysis [5].Massive increases in population, the industrial revolution, and the use of fertilizers and pesticides have led to serious effects on the WQ environments [8, 9]. Thus, having models for the prediction of the WQ is of great help for monitoring water contamination.Currently, two main types for modeling and predicting water quality are available: mechanism- and non-mechanism-oriented models. The mechanism model is relatively sophisticated; it uses the advanced system structure data for simulating the WQ, and thus, it is considered as a multifunctional model that can be used for any water body. In addition, the Streeter–Phelos (S–P) model, one of the earliest WQ simulation model, has been used widely.Later, some countries have developed a variety of WQ models including the QUAL model [10] and the WASP model [11], which have gained wide usage in mimicking the water quality of rivers. This was followed by Warren and Bach [12] who suggested to use MIKE21 for designing systems to model the estuaries, coastal waters, and seas.Hayes et al. [13] have paired two models for improving the quality of downstream water, namely, quasi-static two-dimensional dissolved oxygen reservoir model (DORM-II) and a daily scale optimal dispatch model.Using environmental fluid dynamics code (EFDC), a two-dimensional numerical model was developed to simulate the water environment of the Mudan River [14]. This is based on the distance between points and intervals [15].Another study was conducted by Batur and Maktav [16] to predict the WQ of Lake Gala (Turkey) using satellite image fusion based on the principal component analysis (PCA) method. Jaloree et al. [17] have attempted to predict the WQ of the Narmada River with five WQ indicators using a decision tree model. Another study suggested the use of the deep Bidirectional Stacked Simple Recurrent Unit (Bi-S-SRU) [18] for the designing of a precise forecasting scheme of the WQ in smart mariculture.Liao and Sun [19] developed a model to forecast the WQ of China’s Chao Lake by pairing the ANN and decision tree algorithm. Yan and Qian [20] proposed an affinity propagation clustering model based on a least-squares support vector machine (AP-LSSVM). This model is highly sensitive to vacancies. Solanki et al. [21] analyzed and predicted the chemical eigenvalues of water, especially dissolved oxygen and pH using the deep learning network model which was reported to demonstrate more accurate results compared with supervised learning-based techniques. Li et al. [22] developed a novel hybrid model using a neural network and the Markov chain method. This model has helped in predicting dissolved oxygen, a primary measure of the WQ [23]. Khan and See [24] included dissolved oxygen, chlorophyll, conductivity, and turbidity in the developed WQ model using an artificial neural network (ANN). Yan et al. [25] suggested a genetic algorithm (GA) and particle swarm optimization (PSO) algorithm to enhance the backpropagation (BP) neural network to predict the oxygen demanded in a lake. An enhanced accuracy of the prediction results was reported.Several studies have been performed to model and predict the water quality using different ANN models. These studies have approved the feasibility and effectiveness of employing ANN applications to predict the quality of drinking water.Currently, researchers mostly emphasize enhancing the applicability and reliability of water quality prediction/modelling by using a variety of new technologies such as Fuzzy logic, stochastic, ANN, and deep learning [26, 27].Shafi et al. [28] proposed four machine learning algorithms, namely, Support Vector Machines (SVM), Neural Networks (NN), Deep Neural Networks, and k-Nearest Neighbors (kNN), for the prediction of water quality. Using single feed-forward neural networks to classify water quality, 25 parameters have been included as input parameters [29].Ranković et al. [30] estimated the dissolved oxygen (DO) by employing the ANN model. Gazzaz et al. [31] estimated the WQI by using an ANN model, and the Internet of Things (IOT) technology was applied to collect the dataset from water resources. Abyaneh [32] has applied the machine learning approaches like ANN and regression to predict the chemical oxygen demand (COD). Sakizadeh [33] used ANN with Bayesian regularization to estimate the water quality index (WQI). However, the radial-basis-function (RBF), a type of the ANN model, was used for the prediction and classification of water quality [34, 35].In addition, it has been reported that deep learning methods showed high performance in predicting the WQ when compared to the traditional methods. Marir et al. [36] developed a model to find out the uncommon behavior from large-scale network traffic data. While a deep learning algorithm was employed for extracting features, a multilayer ensemble support vector machine model was used for classification. Fadlullah et al. [37] visualized a reward-based deep learning structure combining a deep convolutional neural network and a deep belief network.For the analysis and prediction of the WQ of groundwater, different algorithms including ANN, Bayesian neural networks, adaptive neurofuzzy [38], decision support system (DSS), and autoregressive moving average (ARMA) have been applied [39]. However, these mimicking models have some limitations.However, the contributions of the current study can be summarized as follows:(i)
Developing highly efficient advanced artificial intelligence models to predict the water quality index (WQI) based on artificial neural networks and deep learning algorithms(ii)
Applying some machine learning models, namely, support vector machine (SVM),K-nearest neighbour (K-NN), and Naive Bayes algorithms, for the prediction of water quality classification (WQC).The highly efficient developed models can be generalized and used to forecast the water pollution process which will help the decision-makers to make the right decisions at the right time.


## 2. Materials and Methods

Figure1 displays the proposed methodology of the present study.Figure 1
Framework of the proposed methodology.


### 2.1. Dataset

The dataset used in this study is collected from certain historical locations in India. It contained 1679 samples from different Indian states during the period from 2005 to 2014. The dataset has 7 significant parameters, namely, dissolved oxygen (DO), pH, conductivity, biological oxygen demand (BOD), nitrate, fecal coliform, and total coliform. Data was collected by the Indian government to ensure the quality of the supplied drinking water. This dataset was obtained from Kagglehttps://www.kaggle.com/anbarivan/indian-water-quality-data.


### 2.2. Data Preprocessing

The processing phase is very important in data analysis to improve the data quality. In this phase, the WQI has been calculated from the most significant parameters of the dataset. Then, water samples have been classified on the basis of the WQI values. For obtaining superior accuracy, thez-score method has been used as a data normalization technique.


#### 2.2.1. Water Quality Index Calculation

To measure water quality, WQI is used to be calculated using various parameters that significantly affect WQ [40–42]. In this study, a published dataset is considered to test the proposed model, and seven significant water quality parameters are included. The WQI has been calculated using the following formula:
(1)WQI=∑i=1Nqi×wi∑i=1Nwi,where:N is the total number of parameters included in the WQI calculationsqi is the quality rating scale for each parameter i calculated by equation (2) below, and wi is the unit weight for each parameter calculated by equation (3).
(2)qi=100×Vi−VIdealSi−VIdeal,where:Vi is the measured value of parameter i in the tested water samplesVIdeal is the ideal value of parameter i in pure water (0 for all parameters except DO=14.6mg/l and pH=7.0), and Si is the recommended standard value of parameter i (as shown in Table 1).
(3)wi=KSi,where K is the proportionality constant that can be calculated as follows:
(4)K=1∑i=1NSi,Table 1
Permissible limits of the parameters used in calculating WQI [43].
ParametersPermissible limitsDissolved oxygen, mg/l10pH8.5Conductivity,μS/cm1000Biological oxygen demand, mg/l5Nitrate, mg/l45Fecal coliform, Cfu/100 ml100Total coliform, Cfu/100 ml1000Tables2 and 3 represent the unit weight of each parameter and the WQC, respectively.Table 2
Parameter unit weights.
ParameterUnit weight (wi)Dissolved oxygen0.2213pH0.2604Conductivity0.0022Biological oxygen demand0.4426Nitrate0.0492Fecal coliform0.0221Total coliform0.0022Table 3
Water quality classification (WQC) [42].
Water quality index rangeClassification0-25Excellent26-50Good51-75Poor76-100Very poorAbove 100Unsuitable for drinking


#### 2.2.2.Z-Score Normalization Method

Normalization is a way to simplify calculations. It is a dimensional expression transformed into a nondimensional expression and becomes a scalar.Z-score normalization (or normalization score) is a normalization method used to normalize parameters by using the mean (μ) and standard deviation (σ) values of the tested data. It can be calculated as follows:
(5)Z‐score=x−μσ,where x is the measured value of the parameter i in the tested sample.


### 2.3. Prediction of Water Quality Index

For this purpose, ANN models, namely, nonlinear autoregressive neural network (NARNET) and long short-term memory (LSTM) deep learning algorithm, were used for the prediction of water quality index.


#### 2.3.1. Artificial Neural Network (ANN) Model

In general, the neural network (NN) models are used as very powerful machine learning algorithms for time-series prediction of different engineering applications. The ANN model has consisted of an input layer, a hidden layer/s, and an output layer. Each hidden layer has weight and bias parameters to manage neurons. To transfer the data from the hidden layer into the output layer, the activation function is used. The learning algorithms are used to select the weights within the NN framework. The weight selection is based on the minimum performance measures such as mean square error (MSE).The NARNET model is a very popular multilayer feed-forward network. It starts with a guessed initial weight value, which is then updated using the actual data. Consequently, there is some sort of randomness in the prediction process performed by the NN model. The network is regularly trained many times using different random values for the initialization, and the results are averaged. In the NARNET model, the number of hidden layers and nodes must be identified in advance. Figure2 displays the NARNET model scheme with multiple inputs and 4 hidden layers (as recommended for most of the research datasets). Equation (6) describes the NARNET time series model.
(6)yt=hyt−1,yt−2,⋯,yt−p+ϵt,Figure 2
Computation of the NARNET model.whereyis the value of time-series data at time t and yt for employing the p observation values of the series. The function h is used to optimize the network weights and neuron bias. Finally, the ϵt is the error obtained from the model at time t.In this work, the NARNET model has been developed to predict the WQI. The NARNET model is a time series model that is used to predict the stationary time series compared with other ANN models like the forward neural network model. The WQI parameters seem in the form of time series; therefore, the NARNET model is proposed to predict the WQI. Table4 shows the significant parameters of the developed model. Figure 3 represents the topology of the developed NARNET model.Table 4
Parameters of the developed ANN (NARNET) model.
Number of hidden layers12Number of delays1 : 8Maximum number of iterations100Maximum number of epochs12Number of gradients1.734×103Figure 3
Architecture of the NARNET model.


#### 2.3.2. Deep Neural Network (DNN) Model

The DNN model is one type of feedforward NN algorithms, which is a fundamental technique for deep learning. DNN consists of 3 levels of nodes, and each node follows a nonlinear function, except for the input node. DNN presents a technique of backpropagation supervised learning. In this work, a WQI model was developed using the DNN algorithm and the simple DNN was compared with the proposed model. This model includes the following parameters and functions: bias (b), input (x), output (y), weight (w), calculation function (α), and activation function fα. The neuron architecture of the DNN model is schematically shown in Figures 4and 5. Every single neuron in the DNN employs the following equations.
(7)α:sum=w∙x+b,(8)y:fα=fw∙x+b,Figure 4
Architecture of the DNN model.Figure 5
Architecture of the LSTM model.Recurrent neural network (RNN) is one type of deep learning techniques used in different domains such as computer vision, natural language processing, pattern recognition, and medical image diagnosis. As compared to different feed ANNs, RNN has a directional control loop that enables the previous states to be stored, recalled, and added to the current output. One of the most powerful RNN algorithms used to predict time series data is the LSTM model.The long short-term memory (LSTM) model, a deep learning algorithm, is appropriate for estimating the time-series data whenever there is a randomized sized time step. The activating function used in the LSTM model is a logistic sigmoid. Providing that the forget gate is opened and the input gate is closed, the memory cell keeps reminding of the first entry and thus solving the typical RNN problems [44]. The formulas of the RNN model are as follows:
(9)ht=tanhWi∙ht+wxxt,(10)yt=wy∙wt,wherehtis the hidden layer of NN for the input training data xt. The output layer is represented by yt. However, wtandwy are the weight of the neural cell and the matrix, respectively. The RNN model is used to create the LSTM model for the computing process. The LSTM consists of three significant parameters, namely, the input gate, forget gate, and output gate. The formulas used to compute the LSTM model are as follows:
(11)Inputgate:it=σWi∙ht−1,xt+bi,(12)Forgetgate:ft=σwf∙ht−1,xt+bf,(13)Outputgate:ot=σW0∙ht−1,xt+b0,(14)Newmemorycell:c~t=tanhWc∙ht−1,xt+bc,(15)Finalmemorycell:Ct=ft×Ct−1+it×c~t,(16)ht=ot×tanhCt,where:it, ft, andot: input, forget, and output gates, respectivelyht: number of hidden layersσ: the logistic sigmoid function is used to transfer the training data from a hidden layer into the output gatewt: the weighted neural networkc~t: an internal memory cell is used to compute in the hidden layerCt: the internal memoryht:the output of a hidden layer state is used to derive from the new memoryi,f,ando: are subscripts that stand for input, forget, and output gates, respectivelyxt: input training datawf, wowc: weight vector of NNbf and bo: bias vector in NNThe analysis of LSTM was performed utilizing MATLAB. Throughout the LSTM layer, 23 variables are open. We just set the units, activate the function, return the sequence, and dropout. Figure5 illustrates the architecture of the LSTM, and the significant parameters of the LSTM model are presented in Table 5.Table 5
Parameters of the LSTM model.
ParametersNumbersShallow hidden layer size[30 80]No. of hidden units 2200No. of hidden units 1350Delays[1 3 4 7]Maximum number of iterations1500Maximum number of epochs150


### 2.4. Prediction of Water Quality Classification

In this section, some machine learning algorithms, namely, support vector machine (SVM),K-nearest neighbor (KNN), and Naive Bayes, have been used to predict the water quality classification.


#### 2.4.1. Support Vector Machine (SVM) Model

The SVM model was developed in 1995 by Corinna Cortes and Vapnik. It has several unique benefits in solving small samples, and nonlinear and high-dimensional pattern recognition. It can be extended to function in the simulation of other machine learning problems. It uses the hyperplane to separate the points of the input vectors and finds the needed coefficients. The best hyperplane is the line with the largest margin, which is meant the distance between the hyperplane and the nearest input objects. The input points defined in the hyperplane are calledsupport vectors. In this work, the linear SVM model along with the Gaussian radial basis function (equation (17)) is used to classify the tested water samples based on their quality.
(17)KX,X′=exp−X−X′22σ2,where XandX′ represent the feature vectors of the input dataset and the X−X′2 is the squared Euclidean distance between the two feature inputs. The σ is a free parameter.


#### 2.4.2.K-Nearest Neighbor (K-NN) Model

The K-NN algorithm is a basic classification and regression method. It is used to find theK values that are close to values in the training dataset. Most of these values belong to a certain class, and thus, tested data can be classified. The K value is used to find the closest points in the feature vectors, and the value should be unique. The following expression of the Euclidean distance function (Di) can be used.
(18)Di=x1−x2+y1−y22,where x1, x2, y1, and y2 are the variables for input data.


#### 2.4.3. Naive Bayes Model

The Bayesian method uses the knowledge of probability statistics to predict and classify datasets. The Bayesian algorithm combines prior and posterior probabilities to avoid the supervisor’s bias and the overfitting phenomenon of using sample information alone.This Naive Bayes is a type of classification algorithms based on Bayes’ theorem and the assumption of the independence of characteristic conditions. Attributes are assumed to be conditionally independent of each other when the target value is given. This method greatly simplifies the complexity of the Bayesian method.In Bayesian analysis, the probability of an event A given an event B is not the same as the probability ofB given A as in equation (18).
(19)PA∣B≠PB∣A.Assuming thatA1,A2⋯.An and C are the feature vectors and the class of the WQC dataset, respectively, the Bayes equation can be expressed as follows:
(20)PC∣A=PC×PA∣CPA,where the PA is a prior probability representing the feature vectors of the WQC dataset and PA∣C is the prior probability of the class of the WQC dataset.


### 2.5. Performance Measurement

The statistical analysis, namely, mean square error (MSE), has been used to evaluate the robustness of the developed models to predict the WQI. However, the accuracy, specificity, sensitivity, precision, andF-score evaluation matrices were employed to evaluate the developed classification model to predict the WQC. The used statistical parameters were defined as follows:
(a)
Mean Square Error (MSE)(21)MSE=1N∑i=1Nyi−y∧i2,whereyi and y^i are the predicted and the observed responses, respectively, and N is the total number of variables.
(b)
Accuracy(22)Accuracy=TP+TNTP+FP+FN+TN×100%,(c)
Specificity(23)Specificity=TNTN+FP×100%,(d)
Sensitivity(24)Sensitivity=TPTP+FN×100%,(e)
Precision(25)Precision=TPTP+FP×100%,(f)
F-score(26)F‐score=2×precision×sensitivitypreision+sensitivity×100%,where TP, TN, FP, and FN are the true positive, true negative, false positive, and false negative, respectively.


### 2.6. Correlation Analysis

Pearson’s correlation coefficient approach is applied to analyze the correlation between the significant parameters of the dataset used for the prediction of the QWI values.(27)R=n∑x×y−ΣxΣyn∑x2−∑x2×n∑y2−∑y2×100%,where:R: Pearson’s correlation coefficient approachx: input values in the first set of the training datay: input values of the second set of the training datan: total number of input variables


### 2.7. Experimental Setup

The prediction experiments have been conducted in a specific environment (MATLAB 2018). The simulation has been performed using a system with i5 Processor and 4 GB RAM to process all required tasks.


## 2.1. Dataset

The dataset used in this study is collected from certain historical locations in India. It contained 1679 samples from different Indian states during the period from 2005 to 2014. The dataset has 7 significant parameters, namely, dissolved oxygen (DO), pH, conductivity, biological oxygen demand (BOD), nitrate, fecal coliform, and total coliform. Data was collected by the Indian government to ensure the quality of the supplied drinking water. This dataset was obtained from Kagglehttps://www.kaggle.com/anbarivan/indian-water-quality-data.


## 2.2. Data Preprocessing

The processing phase is very important in data analysis to improve the data quality. In this phase, the WQI has been calculated from the most significant parameters of the dataset. Then, water samples have been classified on the basis of the WQI values. For obtaining superior accuracy, thez-score method has been used as a data normalization technique.


### 2.2.1. Water Quality Index Calculation

To measure water quality, WQI is used to be calculated using various parameters that significantly affect WQ [40–42]. In this study, a published dataset is considered to test the proposed model, and seven significant water quality parameters are included. The WQI has been calculated using the following formula:
(1)WQI=∑i=1Nqi×wi∑i=1Nwi,where:N is the total number of parameters included in the WQI calculationsqi is the quality rating scale for each parameter i calculated by equation (2) below, and wi is the unit weight for each parameter calculated by equation (3).
(2)qi=100×Vi−VIdealSi−VIdeal,where:Vi is the measured value of parameter i in the tested water samplesVIdeal is the ideal value of parameter i in pure water (0 for all parameters except DO=14.6mg/l and pH=7.0), and Si is the recommended standard value of parameter i (as shown in Table 1).
(3)wi=KSi,where K is the proportionality constant that can be calculated as follows:
(4)K=1∑i=1NSi,Table 1
Permissible limits of the parameters used in calculating WQI [43].
ParametersPermissible limitsDissolved oxygen, mg/l10pH8.5Conductivity,μS/cm1000Biological oxygen demand, mg/l5Nitrate, mg/l45Fecal coliform, Cfu/100 ml100Total coliform, Cfu/100 ml1000Tables2 and 3 represent the unit weight of each parameter and the WQC, respectively.Table 2
Parameter unit weights.
ParameterUnit weight (wi)Dissolved oxygen0.2213pH0.2604Conductivity0.0022Biological oxygen demand0.4426Nitrate0.0492Fecal coliform0.0221Total coliform0.0022Table 3
Water quality classification (WQC) [42].
Water quality index rangeClassification0-25Excellent26-50Good51-75Poor76-100Very poorAbove 100Unsuitable for drinking


### 2.2.2.Z-Score Normalization Method

Normalization is a way to simplify calculations. It is a dimensional expression transformed into a nondimensional expression and becomes a scalar.Z-score normalization (or normalization score) is a normalization method used to normalize parameters by using the mean (μ) and standard deviation (σ) values of the tested data. It can be calculated as follows:
(5)Z‐score=x−μσ,where x is the measured value of the parameter i in the tested sample.


## 2.2.1. Water Quality Index Calculation

To measure water quality, WQI is used to be calculated using various parameters that significantly affect WQ [40–42]. In this study, a published dataset is considered to test the proposed model, and seven significant water quality parameters are included. The WQI has been calculated using the following formula:
(1)WQI=∑i=1Nqi×wi∑i=1Nwi,where:N is the total number of parameters included in the WQI calculationsqi is the quality rating scale for each parameter i calculated by equation (2) below, and wi is the unit weight for each parameter calculated by equation (3).
(2)qi=100×Vi−VIdealSi−VIdeal,where:Vi is the measured value of parameter i in the tested water samplesVIdeal is the ideal value of parameter i in pure water (0 for all parameters except DO=14.6mg/l and pH=7.0), and Si is the recommended standard value of parameter i (as shown in Table 1).
(3)wi=KSi,where K is the proportionality constant that can be calculated as follows:
(4)K=1∑i=1NSi,Table 1
Permissible limits of the parameters used in calculating WQI [43].
ParametersPermissible limitsDissolved oxygen, mg/l10pH8.5Conductivity,μS/cm1000Biological oxygen demand, mg/l5Nitrate, mg/l45Fecal coliform, Cfu/100 ml100Total coliform, Cfu/100 ml1000Tables2 and 3 represent the unit weight of each parameter and the WQC, respectively.Table 2
Parameter unit weights.
ParameterUnit weight (wi)Dissolved oxygen0.2213pH0.2604Conductivity0.0022Biological oxygen demand0.4426Nitrate0.0492Fecal coliform0.0221Total coliform0.0022Table 3
Water quality classification (WQC) [42].
Water quality index rangeClassification0-25Excellent26-50Good51-75Poor76-100Very poorAbove 100Unsuitable for drinking


## 2.2.2.Z-Score Normalization Method

Normalization is a way to simplify calculations. It is a dimensional expression transformed into a nondimensional expression and becomes a scalar.Z-score normalization (or normalization score) is a normalization method used to normalize parameters by using the mean (μ) and standard deviation (σ) values of the tested data. It can be calculated as follows:
(5)Z‐score=x−μσ,where x is the measured value of the parameter i in the tested sample.


## 2.3. Prediction of Water Quality Index

For this purpose, ANN models, namely, nonlinear autoregressive neural network (NARNET) and long short-term memory (LSTM) deep learning algorithm, were used for the prediction of water quality index.


### 2.3.1. Artificial Neural Network (ANN) Model

In general, the neural network (NN) models are used as very powerful machine learning algorithms for time-series prediction of different engineering applications. The ANN model has consisted of an input layer, a hidden layer/s, and an output layer. Each hidden layer has weight and bias parameters to manage neurons. To transfer the data from the hidden layer into the output layer, the activation function is used. The learning algorithms are used to select the weights within the NN framework. The weight selection is based on the minimum performance measures such as mean square error (MSE).The NARNET model is a very popular multilayer feed-forward network. It starts with a guessed initial weight value, which is then updated using the actual data. Consequently, there is some sort of randomness in the prediction process performed by the NN model. The network is regularly trained many times using different random values for the initialization, and the results are averaged. In the NARNET model, the number of hidden layers and nodes must be identified in advance. Figure2 displays the NARNET model scheme with multiple inputs and 4 hidden layers (as recommended for most of the research datasets). Equation (6) describes the NARNET time series model.
(6)yt=hyt−1,yt−2,⋯,yt−p+ϵt,Figure 2
Computation of the NARNET model.whereyis the value of time-series data at time t and yt for employing the p observation values of the series. The function h is used to optimize the network weights and neuron bias. Finally, the ϵt is the error obtained from the model at time t.In this work, the NARNET model has been developed to predict the WQI. The NARNET model is a time series model that is used to predict the stationary time series compared with other ANN models like the forward neural network model. The WQI parameters seem in the form of time series; therefore, the NARNET model is proposed to predict the WQI. Table4 shows the significant parameters of the developed model. Figure 3 represents the topology of the developed NARNET model.Table 4
Parameters of the developed ANN (NARNET) model.
Number of hidden layers12Number of delays1 : 8Maximum number of iterations100Maximum number of epochs12Number of gradients1.734×103Figure 3
Architecture of the NARNET model.


### 2.3.2. Deep Neural Network (DNN) Model

The DNN model is one type of feedforward NN algorithms, which is a fundamental technique for deep learning. DNN consists of 3 levels of nodes, and each node follows a nonlinear function, except for the input node. DNN presents a technique of backpropagation supervised learning. In this work, a WQI model was developed using the DNN algorithm and the simple DNN was compared with the proposed model. This model includes the following parameters and functions: bias (b), input (x), output (y), weight (w), calculation function (α), and activation function fα. The neuron architecture of the DNN model is schematically shown in Figures 4and 5. Every single neuron in the DNN employs the following equations.
(7)α:sum=w∙x+b,(8)y:fα=fw∙x+b,Figure 4
Architecture of the DNN model.Figure 5
Architecture of the LSTM model.Recurrent neural network (RNN) is one type of deep learning techniques used in different domains such as computer vision, natural language processing, pattern recognition, and medical image diagnosis. As compared to different feed ANNs, RNN has a directional control loop that enables the previous states to be stored, recalled, and added to the current output. One of the most powerful RNN algorithms used to predict time series data is the LSTM model.The long short-term memory (LSTM) model, a deep learning algorithm, is appropriate for estimating the time-series data whenever there is a randomized sized time step. The activating function used in the LSTM model is a logistic sigmoid. Providing that the forget gate is opened and the input gate is closed, the memory cell keeps reminding of the first entry and thus solving the typical RNN problems [44]. The formulas of the RNN model are as follows:
(9)ht=tanhWi∙ht+wxxt,(10)yt=wy∙wt,wherehtis the hidden layer of NN for the input training data xt. The output layer is represented by yt. However, wtandwy are the weight of the neural cell and the matrix, respectively. The RNN model is used to create the LSTM model for the computing process. The LSTM consists of three significant parameters, namely, the input gate, forget gate, and output gate. The formulas used to compute the LSTM model are as follows:
(11)Inputgate:it=σWi∙ht−1,xt+bi,(12)Forgetgate:ft=σwf∙ht−1,xt+bf,(13)Outputgate:ot=σW0∙ht−1,xt+b0,(14)Newmemorycell:c~t=tanhWc∙ht−1,xt+bc,(15)Finalmemorycell:Ct=ft×Ct−1+it×c~t,(16)ht=ot×tanhCt,where:it, ft, andot: input, forget, and output gates, respectivelyht: number of hidden layersσ: the logistic sigmoid function is used to transfer the training data from a hidden layer into the output gatewt: the weighted neural networkc~t: an internal memory cell is used to compute in the hidden layerCt: the internal memoryht:the output of a hidden layer state is used to derive from the new memoryi,f,ando: are subscripts that stand for input, forget, and output gates, respectivelyxt: input training datawf, wowc: weight vector of NNbf and bo: bias vector in NNThe analysis of LSTM was performed utilizing MATLAB. Throughout the LSTM layer, 23 variables are open. We just set the units, activate the function, return the sequence, and dropout. Figure5 illustrates the architecture of the LSTM, and the significant parameters of the LSTM model are presented in Table 5.Table 5
Parameters of the LSTM model.
ParametersNumbersShallow hidden layer size[30 80]No. of hidden units 2200No. of hidden units 1350Delays[1 3 4 7]Maximum number of iterations1500Maximum number of epochs150


## 2.3.1. Artificial Neural Network (ANN) Model

In general, the neural network (NN) models are used as very powerful machine learning algorithms for time-series prediction of different engineering applications. The ANN model has consisted of an input layer, a hidden layer/s, and an output layer. Each hidden layer has weight and bias parameters to manage neurons. To transfer the data from the hidden layer into the output layer, the activation function is used. The learning algorithms are used to select the weights within the NN framework. The weight selection is based on the minimum performance measures such as mean square error (MSE).The NARNET model is a very popular multilayer feed-forward network. It starts with a guessed initial weight value, which is then updated using the actual data. Consequently, there is some sort of randomness in the prediction process performed by the NN model. The network is regularly trained many times using different random values for the initialization, and the results are averaged. In the NARNET model, the number of hidden layers and nodes must be identified in advance. Figure2 displays the NARNET model scheme with multiple inputs and 4 hidden layers (as recommended for most of the research datasets). Equation (6) describes the NARNET time series model.
(6)yt=hyt−1,yt−2,⋯,yt−p+ϵt,Figure 2
Computation of the NARNET model.whereyis the value of time-series data at time t and yt for employing the p observation values of the series. The function h is used to optimize the network weights and neuron bias. Finally, the ϵt is the error obtained from the model at time t.In this work, the NARNET model has been developed to predict the WQI. The NARNET model is a time series model that is used to predict the stationary time series compared with other ANN models like the forward neural network model. The WQI parameters seem in the form of time series; therefore, the NARNET model is proposed to predict the WQI. Table4 shows the significant parameters of the developed model. Figure 3 represents the topology of the developed NARNET model.Table 4
Parameters of the developed ANN (NARNET) model.
Number of hidden layers12Number of delays1 : 8Maximum number of iterations100Maximum number of epochs12Number of gradients1.734×103Figure 3
Architecture of the NARNET model.


## 2.3.2. Deep Neural Network (DNN) Model

The DNN model is one type of feedforward NN algorithms, which is a fundamental technique for deep learning. DNN consists of 3 levels of nodes, and each node follows a nonlinear function, except for the input node. DNN presents a technique of backpropagation supervised learning. In this work, a WQI model was developed using the DNN algorithm and the simple DNN was compared with the proposed model. This model includes the following parameters and functions: bias (b), input (x), output (y), weight (w), calculation function (α), and activation function fα. The neuron architecture of the DNN model is schematically shown in Figures 4and 5. Every single neuron in the DNN employs the following equations.
(7)α:sum=w∙x+b,(8)y:fα=fw∙x+b,Figure 4
Architecture of the DNN model.Figure 5
Architecture of the LSTM model.Recurrent neural network (RNN) is one type of deep learning techniques used in different domains such as computer vision, natural language processing, pattern recognition, and medical image diagnosis. As compared to different feed ANNs, RNN has a directional control loop that enables the previous states to be stored, recalled, and added to the current output. One of the most powerful RNN algorithms used to predict time series data is the LSTM model.The long short-term memory (LSTM) model, a deep learning algorithm, is appropriate for estimating the time-series data whenever there is a randomized sized time step. The activating function used in the LSTM model is a logistic sigmoid. Providing that the forget gate is opened and the input gate is closed, the memory cell keeps reminding of the first entry and thus solving the typical RNN problems [44]. The formulas of the RNN model are as follows:
(9)ht=tanhWi∙ht+wxxt,(10)yt=wy∙wt,wherehtis the hidden layer of NN for the input training data xt. The output layer is represented by yt. However, wtandwy are the weight of the neural cell and the matrix, respectively. The RNN model is used to create the LSTM model for the computing process. The LSTM consists of three significant parameters, namely, the input gate, forget gate, and output gate. The formulas used to compute the LSTM model are as follows:
(11)Inputgate:it=σWi∙ht−1,xt+bi,(12)Forgetgate:ft=σwf∙ht−1,xt+bf,(13)Outputgate:ot=σW0∙ht−1,xt+b0,(14)Newmemorycell:c~t=tanhWc∙ht−1,xt+bc,(15)Finalmemorycell:Ct=ft×Ct−1+it×c~t,(16)ht=ot×tanhCt,where:it, ft, andot: input, forget, and output gates, respectivelyht: number of hidden layersσ: the logistic sigmoid function is used to transfer the training data from a hidden layer into the output gatewt: the weighted neural networkc~t: an internal memory cell is used to compute in the hidden layerCt: the internal memoryht:the output of a hidden layer state is used to derive from the new memoryi,f,ando: are subscripts that stand for input, forget, and output gates, respectivelyxt: input training datawf, wowc: weight vector of NNbf and bo: bias vector in NNThe analysis of LSTM was performed utilizing MATLAB. Throughout the LSTM layer, 23 variables are open. We just set the units, activate the function, return the sequence, and dropout. Figure5 illustrates the architecture of the LSTM, and the significant parameters of the LSTM model are presented in Table 5.Table 5
Parameters of the LSTM model.
ParametersNumbersShallow hidden layer size[30 80]No. of hidden units 2200No. of hidden units 1350Delays[1 3 4 7]Maximum number of iterations1500Maximum number of epochs150


## 2.4. Prediction of Water Quality Classification

In this section, some machine learning algorithms, namely, support vector machine (SVM),K-nearest neighbor (KNN), and Naive Bayes, have been used to predict the water quality classification.


### 2.4.1. Support Vector Machine (SVM) Model

The SVM model was developed in 1995 by Corinna Cortes and Vapnik. It has several unique benefits in solving small samples, and nonlinear and high-dimensional pattern recognition. It can be extended to function in the simulation of other machine learning problems. It uses the hyperplane to separate the points of the input vectors and finds the needed coefficients. The best hyperplane is the line with the largest margin, which is meant the distance between the hyperplane and the nearest input objects. The input points defined in the hyperplane are calledsupport vectors. In this work, the linear SVM model along with the Gaussian radial basis function (equation (17)) is used to classify the tested water samples based on their quality.
(17)KX,X′=exp−X−X′22σ2,where XandX′ represent the feature vectors of the input dataset and the X−X′2 is the squared Euclidean distance between the two feature inputs. The σ is a free parameter.


### 2.4.2.K-Nearest Neighbor (K-NN) Model

The K-NN algorithm is a basic classification and regression method. It is used to find theK values that are close to values in the training dataset. Most of these values belong to a certain class, and thus, tested data can be classified. The K value is used to find the closest points in the feature vectors, and the value should be unique. The following expression of the Euclidean distance function (Di) can be used.
(18)Di=x1−x2+y1−y22,where x1, x2, y1, and y2 are the variables for input data.


### 2.4.3. Naive Bayes Model

The Bayesian method uses the knowledge of probability statistics to predict and classify datasets. The Bayesian algorithm combines prior and posterior probabilities to avoid the supervisor’s bias and the overfitting phenomenon of using sample information alone.This Naive Bayes is a type of classification algorithms based on Bayes’ theorem and the assumption of the independence of characteristic conditions. Attributes are assumed to be conditionally independent of each other when the target value is given. This method greatly simplifies the complexity of the Bayesian method.In Bayesian analysis, the probability of an event A given an event B is not the same as the probability ofB given A as in equation (18).
(19)PA∣B≠PB∣A.Assuming thatA1,A2⋯.An and C are the feature vectors and the class of the WQC dataset, respectively, the Bayes equation can be expressed as follows:
(20)PC∣A=PC×PA∣CPA,where the PA is a prior probability representing the feature vectors of the WQC dataset and PA∣C is the prior probability of the class of the WQC dataset.


## 2.4.1. Support Vector Machine (SVM) Model

The SVM model was developed in 1995 by Corinna Cortes and Vapnik. It has several unique benefits in solving small samples, and nonlinear and high-dimensional pattern recognition. It can be extended to function in the simulation of other machine learning problems. It uses the hyperplane to separate the points of the input vectors and finds the needed coefficients. The best hyperplane is the line with the largest margin, which is meant the distance between the hyperplane and the nearest input objects. The input points defined in the hyperplane are calledsupport vectors. In this work, the linear SVM model along with the Gaussian radial basis function (equation (17)) is used to classify the tested water samples based on their quality.
(17)KX,X′=exp−X−X′22σ2,where XandX′ represent the feature vectors of the input dataset and the X−X′2 is the squared Euclidean distance between the two feature inputs. The σ is a free parameter.


## 2.4.2.K-Nearest Neighbor (K-NN) Model

The K-NN algorithm is a basic classification and regression method. It is used to find theK values that are close to values in the training dataset. Most of these values belong to a certain class, and thus, tested data can be classified. The K value is used to find the closest points in the feature vectors, and the value should be unique. The following expression of the Euclidean distance function (Di) can be used.
(18)Di=x1−x2+y1−y22,where x1, x2, y1, and y2 are the variables for input data.


## 2.4.3. Naive Bayes Model

The Bayesian method uses the knowledge of probability statistics to predict and classify datasets. The Bayesian algorithm combines prior and posterior probabilities to avoid the supervisor’s bias and the overfitting phenomenon of using sample information alone.This Naive Bayes is a type of classification algorithms based on Bayes’ theorem and the assumption of the independence of characteristic conditions. Attributes are assumed to be conditionally independent of each other when the target value is given. This method greatly simplifies the complexity of the Bayesian method.In Bayesian analysis, the probability of an event A given an event B is not the same as the probability ofB given A as in equation (18).
(19)PA∣B≠PB∣A.Assuming thatA1,A2⋯.An and C are the feature vectors and the class of the WQC dataset, respectively, the Bayes equation can be expressed as follows:
(20)PC∣A=PC×PA∣CPA,where the PA is a prior probability representing the feature vectors of the WQC dataset and PA∣C is the prior probability of the class of the WQC dataset.


## 2.5. Performance Measurement

The statistical analysis, namely, mean square error (MSE), has been used to evaluate the robustness of the developed models to predict the WQI. However, the accuracy, specificity, sensitivity, precision, andF-score evaluation matrices were employed to evaluate the developed classification model to predict the WQC. The used statistical parameters were defined as follows:
(a)
Mean Square Error (MSE)(21)MSE=1N∑i=1Nyi−y∧i2,whereyi and y^i are the predicted and the observed responses, respectively, and N is the total number of variables.
(b)
Accuracy(22)Accuracy=TP+TNTP+FP+FN+TN×100%,(c)
Specificity(23)Specificity=TNTN+FP×100%,(d)
Sensitivity(24)Sensitivity=TPTP+FN×100%,(e)
Precision(25)Precision=TPTP+FP×100%,(f)
F-score(26)F‐score=2×precision×sensitivitypreision+sensitivity×100%,where TP, TN, FP, and FN are the true positive, true negative, false positive, and false negative, respectively.


## 2.6. Correlation Analysis

Pearson’s correlation coefficient approach is applied to analyze the correlation between the significant parameters of the dataset used for the prediction of the QWI values.(27)R=n∑x×y−ΣxΣyn∑x2−∑x2×n∑y2−∑y2×100%,where:R: Pearson’s correlation coefficient approachx: input values in the first set of the training datay: input values of the second set of the training datan: total number of input variables


## 2.7. Experimental Setup

The prediction experiments have been conducted in a specific environment (MATLAB 2018). The simulation has been performed using a system with i5 Processor and 4 GB RAM to process all required tasks.


## 3. Results and Discussion

For validating the developed model, the dataset has been divided into 70% training and 30% testing subsets. While the ANN and LSTM models were used to predict the WQI, the SVM, KNN, and Naive Bayes were utilized for the water quality classification prediction.


### 3.1. Prediction of the WQI

A NARNET model, with 12 hidden layers, showed a good performance to predict the WQI values. As presented earlier, it has the following characteristics: 1 : 8 number of delays and 12 number of epochs. However, the developed LSTM model has a total number of 200 hidden layers,150 maximum number of epochs, and delays of [1, 3, 4, 7].Table6 summarizes the performance parameters of the developed models to predict WQI, although the prediction accuracy of LSTM for the testing data was slightly better than that for the training data. In addition, the LSTM model, in general, has shown a slightly better performance compared with the NARNET model according to the MSE values. However, based on the R value, the NARNET model has shown a better performance. In general, both models demonstrated an excellent prediction of the WQI values with R%>93.93.Table 6
Performances of the NARNET LSTM and ANN models to predict WQI.
ModelsTraining data setTesting dataMSER (%)MSER (%)NARNET0.281595.970.135396.17LSTM0.131693.930.102894.21Figure6 illustrate the histogram error of the NARNET model. The histogram metric is used to find errors between the target values and the predicted values of training and testing datasets. The total error range is divided into 20 smaller bins, where the y-axis refers to the number of samples located in a particular bin. Figure 7 displays the histogram metric and mean errors of the LSTM model in the training and testing phases. The mean error and histogram metric are used to find the deviation between the observation values and the predicted values of training and testing.Figure 6
Histogram error of the NARNET model.Figure 7
Histogram error and mean error of the LSTM model in the training and testing phases.Figures8 and 9 display the regression plots for the predicted values of training, testing, and whole datasets for the NARNET and LSTM models, respectively. This plot is used to find the relationship between the predicted values and actual values. The “target” values in the plot are the actual dataset, whereas the “output” is the predicted values obtained from the NARNET and LSTM models. As shown in both figures, there is a clear good agreement (R>95.7% (NARNET) and R>93.3% (LSMT)) between the predicted WQI values and the ones calculated from the measured parameters. This implies the highly efficient performance of both developed models.Figure 8
Regression plot of the NARNET model.Figure 9
Regression plot of the LSTM model.Table7 summarizes the Pearson’s correlation coefficient approach is used to predict the WQI values. The correlation between the WQI parameters for selecting the optimal parameters has been obtained. Results revealed that all parameters have a strong relationship with WQI parameters. This indicates that these parameters are very important for predicting the quality of water.Table 7
Performance of Pearson’s correlation coefficient approach.
ParameterDO (mg/l)pHConductivity (μS/cm)BOD (mg/l)Nitrate (mg/l)Fecal coliform (MPN/100 ml)Total coliform (MPN/100 ml)WQIDO (mg/l)1.000.0466-0.2914-0.1819-0.03470.1128-0.1536-0.3836pH0.04661.000.32680.26970.0562-0.2082-0.21700.5233Conductivity (μS/cm)-0.29140.32681.000.32880.1009-0.1120-0.07770.3935BOD (mg/l)-0.18190.26970.32881.000.2257-0.1597-0.16330.6130Nitrate (mg/l)-0.03470.05620.10090.22571.000.14080.05450.1768Fecal coliform (MPN/100 ml)-0.1128-0.2082-0.1120-0.15970.14081.000.91190.2779Total coliform (MPN/100 ml)-0.1536-0.2170-0.0777-0.16330.05450.91191.000.2679WQI-0.38360.52330.39350.61300.17680.27790.26791.00


### 3.2. Prediction of the Water Quality Classification

This section presents the results of the classification algorithms are used to predict the WQC. Table8 shows the results of the used machine learning algorithms. It is noted that the performance of the SVM algorithm is very superior as compared to the KNN and Naive Bayes models. However, the Naive Bayes algorithm has shown the poorest performance. Figure 10 shows the performance of the used algorithms to predict the WQC.Table 8
Performance of the used machine learning models to predict WQC.
ModelsAccuracy (%)Sensitivity (%)Specificity (%)Precision (%)F-score (%)SVM97.0199.2397.7894.9398.54KNN83.6384.7394.9387.5085.84Naive Bayes75.2077.7691.6578.0881.51Figure 10
Performance of the machine learning algorithms used for the prediction of the WQC.


## 3.1. Prediction of the WQI

A NARNET model, with 12 hidden layers, showed a good performance to predict the WQI values. As presented earlier, it has the following characteristics: 1 : 8 number of delays and 12 number of epochs. However, the developed LSTM model has a total number of 200 hidden layers,150 maximum number of epochs, and delays of [1, 3, 4, 7].Table6 summarizes the performance parameters of the developed models to predict WQI, although the prediction accuracy of LSTM for the testing data was slightly better than that for the training data. In addition, the LSTM model, in general, has shown a slightly better performance compared with the NARNET model according to the MSE values. However, based on the R value, the NARNET model has shown a better performance. In general, both models demonstrated an excellent prediction of the WQI values with R%>93.93.Table 6
Performances of the NARNET LSTM and ANN models to predict WQI.
ModelsTraining data setTesting dataMSER (%)MSER (%)NARNET0.281595.970.135396.17LSTM0.131693.930.102894.21Figure6 illustrate the histogram error of the NARNET model. The histogram metric is used to find errors between the target values and the predicted values of training and testing datasets. The total error range is divided into 20 smaller bins, where the y-axis refers to the number of samples located in a particular bin. Figure 7 displays the histogram metric and mean errors of the LSTM model in the training and testing phases. The mean error and histogram metric are used to find the deviation between the observation values and the predicted values of training and testing.Figure 6
Histogram error of the NARNET model.Figure 7
Histogram error and mean error of the LSTM model in the training and testing phases.Figures8 and 9 display the regression plots for the predicted values of training, testing, and whole datasets for the NARNET and LSTM models, respectively. This plot is used to find the relationship between the predicted values and actual values. The “target” values in the plot are the actual dataset, whereas the “output” is the predicted values obtained from the NARNET and LSTM models. As shown in both figures, there is a clear good agreement (R>95.7% (NARNET) and R>93.3% (LSMT)) between the predicted WQI values and the ones calculated from the measured parameters. This implies the highly efficient performance of both developed models.Figure 8
Regression plot of the NARNET model.Figure 9
Regression plot of the LSTM model.Table7 summarizes the Pearson’s correlation coefficient approach is used to predict the WQI values. The correlation between the WQI parameters for selecting the optimal parameters has been obtained. Results revealed that all parameters have a strong relationship with WQI parameters. This indicates that these parameters are very important for predicting the quality of water.Table 7
Performance of Pearson’s correlation coefficient approach.
ParameterDO (mg/l)pHConductivity (μS/cm)BOD (mg/l)Nitrate (mg/l)Fecal coliform (MPN/100 ml)Total coliform (MPN/100 ml)WQIDO (mg/l)1.000.0466-0.2914-0.1819-0.03470.1128-0.1536-0.3836pH0.04661.000.32680.26970.0562-0.2082-0.21700.5233Conductivity (μS/cm)-0.29140.32681.000.32880.1009-0.1120-0.07770.3935BOD (mg/l)-0.18190.26970.32881.000.2257-0.1597-0.16330.6130Nitrate (mg/l)-0.03470.05620.10090.22571.000.14080.05450.1768Fecal coliform (MPN/100 ml)-0.1128-0.2082-0.1120-0.15970.14081.000.91190.2779Total coliform (MPN/100 ml)-0.1536-0.2170-0.0777-0.16330.05450.91191.000.2679WQI-0.38360.52330.39350.61300.17680.27790.26791.00


## 3.2. Prediction of the Water Quality Classification

This section presents the results of the classification algorithms are used to predict the WQC. Table8 shows the results of the used machine learning algorithms. It is noted that the performance of the SVM algorithm is very superior as compared to the KNN and Naive Bayes models. However, the Naive Bayes algorithm has shown the poorest performance. Figure 10 shows the performance of the used algorithms to predict the WQC.Table 8
Performance of the used machine learning models to predict WQC.
ModelsAccuracy (%)Sensitivity (%)Specificity (%)Precision (%)F-score (%)SVM97.0199.2397.7894.9398.54KNN83.6384.7394.9387.5085.84Naive Bayes75.2077.7691.6578.0881.51Figure 10
Performance of the machine learning algorithms used for the prediction of the WQC.


## 4. Conclusions

Modeling and prediction of water quality are very important for the protection of the environment. Developing a model by using advanced artificial intelligence algorithms can be used to measure the future water quality. In this proposed methodology, the advanced artificial intelligence algorithms, namely, NARNET and LSTM models were used to predict the WQI. Moreover, machine learning algorithms such as SVM, KNN, and Naive Bayes were used to classify the WQI data. The proposed models were evaluated and examined by some statistical parameters. For the WQI prediction, the result has revealed that the performance of the NARNET model is slightly better than the LSTM model based on the obtainedR value. However, the SVM algorithm has achieved the highest accuracy of the prediction of the WQC as compared with KNN and Naive Bayes algorithms. After examining the robustness and efficiency of the proposed model for predicting the WQI, in future work, the developed models will be implemented to predict the water quality in Saudi Arabia for different types of water.



---

*Source: 6659314-2020-12-30.xml*