# Modelling and Prediction of Water Quality by Using Artificial Intelligence

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Materials and Methods

#### 2.1. Dataset

#### 2.2. Data Preprocessing

#### 2.2.1. Water Quality Index (WQI) Calculation

_{i}denotes the quality estimate scale for each parameter i calculated by Formula (2), and w

_{i}denotes the unit weight of each parameter in Formula (3).

_{i}is a measured value that refers to the water samples tested, V

_{Ideal}is an ideal value and indicates pure water (0 for all parameters except OD = 14.6 mg/L and pH = 7.0), and S

_{i}is a standard value recommended for parameter i, as shown in Table 1.

#### 2.2.2. Z-Score Normalization Method

#### 2.3. Adaptive Neuro-Fuzzy Inference System (ANFIS) Model

- Layer 1 (Fuzzification Layer):

_{i}is the linguistic variable; and σ

_{i}, b

_{i}, and c

_{i}are the parameters of the Bell function.

- Layer 2 (Antecedent Layer):

_{i}signal refers to the firing strength of the rule.

- Layer 3 (Strength Normalization Layer):

_{3,i}is the output of layer 3 and $\overline{w}$ is the normalized firing strength.

- Layer 4 (Consequent Layer):

- Layer 5 (Inference Layer):

^{−5}, partition matrix exponent 2, and number epoch 150 were appropriate.

#### 2.4. Classification of Water Quality

#### 2.4.1. K-Nearest Neighbors (KNN) Model

_{1}, x

_{2}, y

_{1}, and y

_{2}are variables for input data.

#### 2.4.2. Artificial Neural Networks (ANNs)

#### 2.5. Performance Measurement

- Mean square error (MSE)$$MSE=\frac{1}{N}{\displaystyle \sum}_{i=1}^{N}{\left({y}_{i}-{\widehat{y}}_{i}\right)}^{2}$$

- Root mean square error (RMSE)$$RMSE=\text{}\sqrt{{\displaystyle \sum}_{i=1}^{N}\frac{{\left(y-\widehat{y}\right)}^{2}}{N}}$$$$R=\frac{n{{\displaystyle \sum}}^{\text{}}\left(x\text{}\times \text{}y\right)-({{\displaystyle \sum}}^{\text{}}x)\text{}({{\displaystyle \sum}}^{\text{}}y)}{\text{}[n{{\displaystyle \sum}}^{\text{}}({x}^{2})-{{\displaystyle \sum}}^{\text{}}({x}^{2})]\text{}\times \text{}[n{{\displaystyle \sum}}^{\text{}}({y}^{2})-{{\displaystyle \sum}}^{\text{}}({y}^{2})]}\times 100\%$$

- Accuracy$$Accuracy=\frac{TP+TN}{TP+FP+FN+TN}\times 100\%$$

- Specificity$$Specificity=\frac{TN}{TN+FP}\times 100\%$$

- Sensitivity$$Sensitivity=\frac{TP}{TP+FN}\times 100\%$$

- Precision$$Precision=\frac{TP}{TP+FP}\times 100\%$$

- F-score$$\mathrm{F}-\mathrm{score}\text{}=\frac{2\ast preision\ast \mathrm{Sensitivity}}{preision+\mathrm{Sensitivity}}\times 100\%$$

## 3. Experimental Setup

#### 3.1. Prediction of WQI Using the ANFIS Model

#### 3.2. Experiment Results of WQC Classification

^{−6}at epoch 52. In the performance of the FFNN model, the MSE decreased rapidly as it learns. The blue, green and red lines represent the training process, validation error and training error, respectively. Increased numbers of epochs indicate that the training data had small errors. When the validation error stops, the training stops.

## 4. Discussion

## 5. Conclusions

- First, the present study explored an alternative method of artificial intelligence to predict water quality by employing minimal and available water quality parameters. The datasets employed to conduct the research were acquired from different locations in India and contained 1679 samples from 666 different sources of rivers and lakes in the country. Artificial intelligence models were applied to predict and classify WQI.
- Second, an advanced AI ANFIS model can be developed to predict WQI by selecting important parameters from a standard dataset. Notably, prediction values were very close to the observation values.
- Third, machine learning algorithms, namely, FFNN and KNN, can be developed for WQC. The FFNN outperformed KNN in WQC. The classification results of FFNN were superior to those of the KNN algorithm.
- Fourth, the system will help reduce people’s consumption of poor-quality water and consequently curtail horrific diseases such as typhoid and diarrhea. In this case, our application can improve water pollution in different water bodies. The robustness and efficiency of the proposed model in predicting WQI can be examined in future works. The developed models can be implemented to predict the quality of different types of water in Saudi Arabia.

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## References

- Ågren, J.; Svensson, R. Postglacial Land Uplift Model and System Definition for the New Swedish Height System RG 2000; Lantmäteriet: Gävle, Sweden, 2007; Available online: https://www.lantmateriet.se/globalassets/kartor-och-geografisk-information/gps-och-matning/geodesi/rapporter_publikationer/rapporter/lmv-rapport_2007_4.pdf (accessed on 31 May 2017).
- Clark, R.; Hakim, S.; Ostfeld, A. Handbook of Water and Wastewater Systems Protection (Protecting Critical Infrastructure); Springer: New York, NY, USA, 2011. [Google Scholar]
- Zhou, J.; Wang, Y.; Xiao, F.; Sun, L. Water Quality Prediction Method Based on IGRA and LSTM. Water
**2018**, 10, 1148. [Google Scholar] [CrossRef][Green Version] - 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. [Google Scholar] [CrossRef][Green Version] - Gomolka, Z.; Twarog, B.; Zeslawska, E.; Lewicki, A.; Kwater, T. Using Artificial Neural Networks to Solve the Problem Represented by BOD and DO Indicators. Water
**2017**, 10, 4. [Google Scholar] [CrossRef][Green Version] - Melesse, A.M.; Khosravi, K.; Tiefenbacher, J.P.; Heddam, S.; Kim, S.; Mosavi, A.; Pham, B.T. River Water Salinity Prediction Using Hybrid Machine Learning Models. Water
**2020**, 12, 2951. [Google Scholar] [CrossRef] - Hayes, D.F.; Sanders, T.G.; Brown, J.K.; Labadie, J.W. Enhancing water quality in hydropower system operations. Water Resour. Res.
**1998**, 34, 471–483. [Google Scholar] [CrossRef] - Tang, G.; Li, J.; Zhu, Y.; Li, Z.; Nerry, F. Two-Dimensional Water Environment Numerical Simulation Research Based on EFDC in Mudan River, Northeast China. In Proceedings of the 2015 IEEE European Modelling Symposium (EMS), Madrid, Spain, 6–8 October 2015; pp. 238–243. [Google Scholar] [CrossRef]
- Hu, L.; Zhang, C.; Hu, C.; Jiang, G. Use of grey system for assessment of drinking water quality: A case S study of Jiaozuo city, China. In Proceedings of the 2009 IEEE International Conference on Grey Systems and Intelligent Services, Nanjing, China, 10–12 November 2009; pp. 803–808. [Google Scholar]
- Batur, E.; Maktav, D. Assessment of Surface Water Quality by Using Satellite Images Fusion Based on PCA Method in the Lake Gala, Turkey. IEEE Trans. Geosci. Remote Sens.
**2018**, 57, 2983–2989. [Google Scholar] [CrossRef] - Jaloree, S.; Rajput, A.; Sanjeev, G. Decision tree approach to build a model for water quality. Bin. J. Data Min. Net.
**2014**, 4, 25–28. [Google Scholar] [CrossRef] - Liu, J.; Yu, C.; Hu, Z.; Zhao, Y.; Bai, Y.; Xie, M.; Luo, J. Accurate Prediction Scheme of Water Quality in Smart Mariculture With Deep Bi-S-SRU Learning Network. IEEE Access
**2020**, 8, 24784–24798. [Google Scholar] [CrossRef] - Khan, Y.; See, C.S. Predicting and analyzing water quality using Machine Learning: A comprehensive model. In Proceedings of the 2016 IEEE Long Island Systems, Applications and Technology Conference, Farmingdale, NY, USA, 29 April 2016; pp. 1–6. [Google Scholar]
- Shafi, U.; Mumtaz, R.; Anwar, H.; Qamar, A.M.; Khurshid, H. Surface Water Pollution Detection using Internet of Things. In Proceedings of the 2018 15th International Conference on Smart Cities: Improving Quality of Life Using ICT & IoT (HONET-ICT), Islamabad, Pakistan, 8–10 October 2018; pp. 92–96. [Google Scholar]
- Baek, S.-S.; Pyo, J.; Chun, J.A. Prediction of Water Level and Water Quality Using a CNN-LSTM Combined Deep Learning Approach. Water
**2020**, 12, 3399. [Google Scholar] [CrossRef] - Liu, P.; Wang, J.; Sangaiah, A.K.; Xie, Y.; Yin, X. Analysis and Prediction of Water Quality Using LSTM Deep Neural Networks in IoT Environment. Sustainability
**2019**, 11, 2058. [Google Scholar] [CrossRef][Green Version] - Chen, D.Y.; Zhang, X.Z. Application of variable structure neural network in prediction of future water quality parameters. Sci. Technol. Eng.
**2008**, 22, 1577–1579. (In Chinese) [Google Scholar] - Singh, K.P.; Basant, A.; Malik, A.; Jain, G. Artificial neural network modeling of the river water quality—A case study. Ecol. Model.
**2009**, 220, 888–895. [Google Scholar] [CrossRef] - Zheng, G.Y.; Luo, F.; Chen, W.B. Quality prediction of waste water treatment based on Immune Particle Swarm Neural Networks. Microprocessors
**2010**, 31, 75–77. (In Chinese) [Google Scholar] - Gao, F.; Feng, M.Q.; Teng, S.F. On the way for forecasting the water quality by BP neural network based on the PSO. J. Saf. Environ.
**2015**, 15, 338–341. [Google Scholar] - Zhang, X.D.; Gao, M.T. Water quality prediction method based on IGA-BP. Chin. J. Environ. Eng.
**2016**, 10, 1566–1571. [Google Scholar] - Wang, Z.; Shao, D.; Yang, H.; Yang, S. Prediction of water quality in South to North Water Transfer Project of China based on GA-optimized general regression neural network. Water Supply
**2014**, 15, 150–157. [Google Scholar] [CrossRef] - Abyaneh, H.Z. Evaluation of multivariate linear regression and artificial neural networks in prediction of water quality parameters. J. Environ. Health Sci. Eng.
**2014**, 12, 40. [Google Scholar] [CrossRef] [PubMed][Green Version] - Yesilnacar, M.I.; Sahinkaya, E.; Naz, M.; Ozkaya, B. Neural network prediction of nitrate in groundwater of Harran Plain, Turkey. Environ. Earth Sci.
**2008**, 56, 19–25. [Google Scholar] [CrossRef] - Bouamar, M.; Ladjal, M. A comparative study of RBF neural network and SVM classification techniques performed on real data for drinking water quality. In Proceedings of the 2008 5th International Multi-Conference on Systems, Signals and Devices, Amman, Jordan, 20–22 July 2008; pp. 1–5. [Google Scholar]
- Barzegar, R.; Aalami, M.T.; Adamowski, J. Short-term water quality variable prediction using a hybrid CNN–LSTM deep learning model. Stoch. Environ. Res. Risk Assess.
**2020**, 34, 415–433. [Google Scholar] [CrossRef] - Maiti, S.; Tiwari, R.K. A comparative study of artificial neural networks, Bayesian neural networks and adaptive neuro-fuzzy inference system in groundwater level prediction. Environ. Earth Sci.
**2014**, 71, 3147–3160. [Google Scholar] [CrossRef] - Min, C. An Improved Recurrent Support Vector Regression Algorithm for Water Quality Prediction. J. Comput. Inf.
**2011**, 12, 4455–4462. [Google Scholar] - Piazza, S.; Sambito, M.; Feo, R.; Freni, G.; Puleo, V. CCWI2017: F6 ‘Optimal positioning of water quality sensors in water distribution networks: Comparison of numerical and experimental results’. J. Contrib.
**2017**. [Google Scholar] [CrossRef] - Sambito, M.; Di Cristo, C.; Freni, G.; Leopardi, A. Optimal water quality sensor positioning in urban drainage systems for illicit intrusion identification. J. Hydroinform.
**2020**, 22, 46–60. [Google Scholar] [CrossRef] - Das Kangabam, R.; Bhoominathan, S.D.; Kanagaraj, S.; Govindaraju, M. Development of a water quality index (WQI) for the Loktak Lake in India. Appl. Water Sci.
**2017**, 7, 2907–2918. [Google Scholar] [CrossRef][Green Version] - Tyagi, S.; Sharma, B.; Singh, P.; Dobhal, R. Water Quality Assessment in Terms of Water Quality Index. Am. J. Water Resour.
**2020**, 1, 34–38. [Google Scholar] [CrossRef] - Mensah, R.A.; Xiao, J.; Das, O.; Jiang, L.; Xu, Q.; Alhassan, M.O. Application of Adaptive Neuro-Fuzzy Inference System in Flammability Parameter Prediction. Polymers
**2020**, 12, 122. [Google Scholar] [CrossRef] [PubMed][Green Version] - Walia, N.; Singh, H.; Sharma, A. ANFIS: Adaptive Neuro-Fuzzy Inference System—A Survey. Int. J. Comput. Appl.
**2015**, 123, 32–38. [Google Scholar] [CrossRef] - Rezakazemi, M.; Mosavi, A.; Shirazian, S. ANFIS pattern for molecular membranes separation optimization. J. Mol. Liq.
**2019**, 274, 470–476. [Google Scholar] [CrossRef] - Al-Mughanam, T.; Aldhyani, T.; AlSubari, B.; Al-Yaari, M. Modeling of Compressive Strength of Sustainable Self-Compacting Concrete Incorporating Treated Palm Oil Fuel Ash Using Artificial Neural Network. Sustainability
**2020**, 12, 9322. [Google Scholar] [CrossRef] - Aldhyani, T.H.H.; Al-Yaari, M.; Alkahtani, H.; Maashi, M. Water Quality Prediction Using Artificial Intelligence Algorithms. Appl. Bionics Biomech.
**2020**, 2020, 1–12. [Google Scholar] [CrossRef] [PubMed] - Ahmad, Z.; Rahim, N.A.; Bahadori, A.; Zhang, J. Improving water quality index prediction in Perak River basin Malaysia through a combination of multiple neural networks. Int. J. River Basin Manag.
**2016**, 15, 79–87. [Google Scholar] [CrossRef][Green Version] - Gazzaz, N.M.; Yusoff, M.K.; Aris, A.Z.; Juahir, H.; Ramli, M.F. Artificial neural network modeling of the water quality index for Kinta River (Malaysia) using water quality variables as predictors. Mar. Pollut. Bull.
**2012**, 64, 2409–2420. [Google Scholar] [CrossRef] [PubMed] - Sakizadeh, M. Artificial intelligence for the prediction of water quality index in groundwater systems. Model. Earth Syst. Environ.
**2016**, 2, 1–9. [Google Scholar] [CrossRef] - Ranković, V.; Radulović, J.; Radojević, I.; Ostojić, A.; Čomić, L. Neural network modeling of dissolved oxygen in the Gruža reservoir, Serbia. Ecol. Model.
**2010**, 221, 1239–1244. [Google Scholar] [CrossRef] - Ahmed, U.; Mumtaz, R.; Anwar, H.; Shah, A.A.; Irfan, R.; García-Nieto, J. Efficient Water Quality Prediction Using Supervised Machine Learning. Water
**2019**, 11, 2210. [Google Scholar] [CrossRef][Green Version]

**Figure 2.**Architecture of the adaptive euro-fuzzy inference system ANFIS model (

**A**) order of sugeno and (

**B**) layers of ANFIS model.

**Figure 9.**Histogram error of the FFNN model for the WQC, the histogram error between 0.9749 to −0.0228.

**Figure 11.**Performance plot of training WQ data using the FFNN model, best performance between 10

^{0}to 10

^{−2}.

**Table 1.**Permissible limits of the parameters used in calculating the WQI [33].

Parameters | Permissible Limits |
---|---|

Dissolved oxygen, mg/L | 10 |

pH | 8.5 |

Conductivity, µS/cm | 1000 |

Biological oxygen demand, mg/L | 5 |

Nitrate, mg/L | 45 |

Fecal coliform/100 mL | 100 |

Total coliform/100 mL | 1000 |

Water Quality Index Range | Classification |
---|---|

0–25 | Excellent |

26–50 | Good |

51–75 | Poor |

76–100 | Very poor |

Parameter | Unit Weight (w_{i}) |
---|---|

Dissolved Oxygen | 0.2213 |

pH | 0.2604 |

Conductivity | 0.0022 |

Biological Oxygen Demand | 0.4426 |

Nitrate | 0.0492 |

Fecal Coliform | 0.0221 |

Total Coliform | 0.0022 |

Model | Training Dataset | Testing Data | ||||||
---|---|---|---|---|---|---|---|---|

MSE | RMSE | Mean Errors | R (%) | MSE | RMSE | Mean Errors | R (%) | |

ANFIS | 0.00336 | 0.0580 | 6.456 × 10^{−9} | 90.29 | 0.0029 | 0.0540 | 0.001330 | 92.39 |

Models | Accuracy (%) | Sensitivity (%) | Specificity (%) | Precision (%) | Recall (%) |
---|---|---|---|---|---|

FFNN | 100 | 99.61 | 99.61 | 99.961 | 100 |

KNN | 80.63 | 82.50 | 89.50 | 82.50 | 86.84 |

Authors | Water Body | Place of Study | Models | Number of Parameters | Purpose of System | Results of WQI | Results of WQC | |||
---|---|---|---|---|---|---|---|---|---|---|

Model Prediction of WQI | Model for Classification of WQC | WQI | WQC | MSE | R% | Accuracy (%) | ||||

Ahmed et al. [38] | River | Malaysia | FFNN | Not used | 25 | Yes | No | 0.1156 | 97.7 | No |

Gazzaz et al. [39] | River | Malaysia | ANNs | Not used | 23 | Yes | No | 9.25 | 77.0 | No |

Sakizadeh et al. [40] | Groundwater | Iran | ANNs | Not used | 16 | Yes | No | 9.25 | 77.0 | No |

Rankovic et al. [41] | River | Serbia | FFNN | Not used | 10 | Yes | No | 0.9923 | 87.4 | No |

Umair Ahmed et al. [42] | River | Pakistan | Polynomial regression | Multi-layer perceptron (MLP) | 4 | Yes | Yes | 7.9467 | - | 85.07 |

Proposed system | Rivers and lakes | India | ANFIS | FFNN | 7 | Yes | Yes | 0.0029 | 96.17 | 100 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 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/).

## Share and Cite

**MDPI and ACS Style**

Hmoud Al-Adhaileh, M.; Waselallah Alsaade, F.
Modelling and Prediction of Water Quality by Using Artificial Intelligence. *Sustainability* **2021**, *13*, 4259.
https://doi.org/10.3390/su13084259

**AMA Style**

Hmoud Al-Adhaileh M, Waselallah Alsaade F.
Modelling and Prediction of Water Quality by Using Artificial Intelligence. *Sustainability*. 2021; 13(8):4259.
https://doi.org/10.3390/su13084259

**Chicago/Turabian Style**

Hmoud Al-Adhaileh, Mosleh, and Fawaz Waselallah Alsaade.
2021. "Modelling and Prediction of Water Quality by Using Artificial Intelligence" *Sustainability* 13, no. 8: 4259.
https://doi.org/10.3390/su13084259