A Comparison of Artificial Neural Network (ANN) and Long Short-Term Memory (LSTM) in River Water Quality Prediction

: River water is a crucial natural resource utilized for various purposes, including agriculture and drinking. Human activities such as mining, industrial discharge, and improper waste management contribute to river water pollution, affecting its quality and posing risks to human health. Monitoring and predicting river water quality are essential for effective management and pollution control. The research focuses on Dissolved Oxygen (DO), and comparing of Artificial Neural Network (ANN) and Long Short-Term Memory (LSTM) to developed prediction models. Evaluation of the models' performance shows that the ANN model outperforms LSTM in predicting Dissolved Oxygen (DO) concentrations, achieving lower Root Mean Square Error (RMSE) and Mean Absolute Percentage Error (MAPE). Although LSTM exhibits lower Mean Squared Error (MSE), the ANN model demonstrates better accuracy in minimizing the average distance between predicted and actual values. The findings suggest that ANN-based models offer good performance in river water quality prediction, with potential for further enhancement through additional variables or model architecture adjustments.


INTRODUCTION
River water is one form of water that is frequently used and consumed.Water is a natural resource that is essential to human life as well as the sustainability of the ecosystem.River water is frequently used for irrigation in agriculture, drinking water, and as a habitat for a variety of organisms.Human activities include mining, industry, and home waste are the main causes of pollution in river water [1] [2].The domestic garbage that has not been properly managed may contain pathogens and bacteria that can spread disease via river water.River water pollution has a negative impact since it lowers the quality of water used for human consumption and endangers the lives of aquatic species.The indicator used for this study is dissolved oxygen (DO), a component of river water pollution that affects the river's quality.
Predicting river water quality can help minimize issues.To monitor river water quality, an algorithmic method is required to analyze time series data.This study expects to provide effective model predictions that may be evaluated more correctly by comparing the Artificial Neural Network (ANN) and Long Short-Term Memory (LSTM) algorithms.Multi-task deep learning can be used to analyze water quality model predictions [3].The research object is Chemical Oxygen Demand (COD) from the Yellow River environment in China.The data used is a complete time series of water quality data, which will be processed using Multi-Task Learning-CNN-LSTM.The MTL-CNN-LSTM model can forecast numerous parts of the Lanzhou section of the Yellow River at the same time, with more prediction accuracy than a single model prediction section and the ability to properly accommodate the sequential complicated COD variations in the Yellow River water.The methods used are Artificial Neural Network (ANN), Discrete Wavelet Transform (DWT), and Long Short-Term Memory (LSTM) [4] [5].The prediction model developed in this study is utilized to monitor water quality and cleanliness management in the Jinjiang River.This study applies artificial neural networks (ANNs) to fill in missing data using time series data from water quality samples.DWT is used to reconstruct water quality time series, remove the impact of short-term random noise, improve the accuracy of model predictions on out-of-sample data, and predict future dynamic trends, allowing it to predict short-term and long-term trends in quality time series data more effectively.
Neural network models can be useful for forecasting water quality indices [6].A Neural Network is used to describe the link between input data -physicochemical data from water parameters (TDS, chloride, TH, nitrate, and manganese) and output datathe water quality index.A qualitative or quantitative technique might be used for forecasting.[7]  CNN network to extract local features from preprocessed air quality data and transfer time series with better expressive power than original water quality information to LSTM layers for prediction [10] [11].The selection of optimal parameters is done by adjusting the number of neurons in the LSTM network and the size and number of convolution kernels in the CNN network.LSTM and the proposed model are used to cool the air quality data.This experiment shows that the proposed model is more accurate than conventional LSTM in predicting peak fitting effects.Compared with the conventional LSTM model, the root mean square error, Pearson correlation coefficient, mean absolute error and mean square error are optimized to be 5.99%, 2.80%, 2.24% and 11.63%, respectively.Long-Short term memory (LSTM) algorithms are known to be able to overcome several typical obstacles in hydrological model applications [12].In this research, the ability of the LSTM model to predict complex and nonlinear air quality behavior parameters at the Schwingbach Environmental Observatory (SEO), Germany.By selecting weekly nitrogen-nitrate concentration, weekly stable isotope air concentration (δ18O) and daily air temperature in six streams and six ground air sources with different land use and hillside conditions.The RMSE evaluation of LSTM performance ranges from 0.27 to 3.38 mg/l, from 0.069 to 0.27 ‰ and from 1.3 to 2.1 °C for nitrogen-nitrate, δ18O and air temperature.By comparing RMSE with statistical data parameters.The results confirm that LSTM can be used for initial risk assessment of air quality, and obtain robust results.
Water quality prediction method based on Long Short-Term Memory Neural Network (LSTM NN) [13].Training data and water quality indicator data taken from Lake Taihu were measured every month from 2000 to 2006 which were used for the training model.This proposed method will be compared with two methods, namely, based on back propagation neural network and based on online sequential extreme learning machine.The result after comparing with back propagation neural network (BPNN) and online sequential extreme learning machine (OSELM), is that the prediction accuracy of LSTM NN is higher.In addition, LSTM NN is more generalized.Managing pollution levels through water quality predictions is one of the most effective ways to speed up problem discovery.Artificial Neural Network (ANN) is a computer system that imitates the way the brain analyze data developing algorithms for modelling complex patterns [14] [15].It can be concluded that the ANN architecture can predict water quality, although to varying degrees according to efficiency, performance and time required.The RNN-based LSTM model achieved the best model, with measurement accuracy of 96% to 98%.

THEORITICAL FRAMEWORK
Artificial Neural Networks (ANN) are a system of parallel processors connected to each other in the form of a directed graph.according to the chart each neuron of the network is represented as a node.These connections provide a hierarchical structure that attempts to mimic brain physiology, seeking new models of processing to solve specific problems in the real world.ANN can be used to represent nonlinear mapping between input and output vectors and also as a signal processing technology [16].ANN functions as a pattern classifier and as a nonlinear adaptive filter.Artificial neural networks consist of 3 layers, which are Input layer, Hidden layer and Output layer.Each layer is responsible for performing the same function completing the system.[17] Multilayer Perception (MLP) is an example of an artificial neural network that is widely used to solve a number of different problems, including pattern recognition and interpolation.Each layer consists of neurons that are interconnected with each other with weights.In each neuron, a mathematical function is called an activation function that receives input from the previous layer and produces output for the next layer [18].In the experiment, the activation function used is the hyperbolic tangent sigmoid transfer function.
Long Short-Term Memory (LSTM) was introduced by Hotchreiter and Schmidhuber in 1997 to solve the gradient diffusion problem of Recurrent Neural Network (RNN).LSTM is a variation of RNN which was created to avoid the problem of remembering long-term information in RNN.LSTM consists of three gate structures, namely input gate, output gate and forget gate as shown in Figure I.The way LSTM works is by making changes to the RNN by adding memory cells that can store information for a long period of time.Memory cells are used to overcome the occurrence of vanishing gradients in RNNs when processing long sequential data [19] [20].f.Verify and validate the models.g.Compare the result of actual value and predict value.When the evaluation process for both ANN and LSTM methods is declared complete, testing is carried out using testing data.The process carried out is making predictions.The prediction results that have been made based on the ANN and LSTM models will be compared with the actual values.

RESULT AND DISCUSSION
The training results of the prediction model were obtained using 1247 training data and 312 test data to find out how accurate the model that had been designed and used in research was.This process is carried out before testing the prediction model.Based on this data, this research uses Python syntax to process prediction training with training data.The aim is to produce a model that is used in the testing process and the prediction results will be matched with actual or real data from the training data.The table I provides information about the configurations of two different models ANN and LSTM, that used for a specific machine learning task.Hidden Neuron is the number of neurons in the hidden layers of the model.The ANN and LSTM models are compared in this table according to the way ANN and LSTM predicted a certain parameter known as Dissolved Oxygen (DO).The MSE is measures the average squared difference between the predicted and actual values.The lower the value, the better the model's performance.Based on table II, the LSTM model has a lower MSE (0.000109) compared to the ANN model (1.90465), it means that the LSTM model is more accurate in predicting the Dissolved Oxygen (DO) parameter.The RMSE is the square root of the MSE and represents the average distance between the predicted and actual values.The lower the value, the better the model's performance.Based on table II, the ANN model has a lower RMSE (0.0436) compared to the LSTM model (0.01045), it means that the ANN model is better at minimizing the average distance between the predicted and actual values.And the MAPE is measures the average absolute difference between the predicted and actual values as a percentage of the actual values.The lower the value, the better the model's performance.In this case, the ANN model has a lower MAPE (1.85%) compared to the LSTM model (4.27%), it means that the ANN model has a better performance in predicting the DO parameter.
Based on the evaluations, the LSTM model has a lower MSE, but the ANN model has a lower RMSE and MAPE, and the result of evaluation is indicating that the ANN model forecasts the DO parameter has a greater accuracy.Therefore, the correct interpretation of the table is that the ANN model performs better than the LSTM model in predicting the DO parameter, according to the evaluation metrics.The LSTM model has a lower MSE, indicating that it is better at reducing the average squared difference between the predicted and actual values.However, the ANN model is better at minimizing the average distance between the predicted and actual values and has a lower percentage difference between the predicted and actual values.

CONCLUSION
In conclusion, the models show the performance of the ANN and LSTM in predicting the DO concentration in a river water quality.The models show a good performance in predicting DO concentrations, but there is a slight deviation in the predicted values for observations.The ANN model performs better than the LSTM model in predicting the DO parameter, according to the evaluation metrics.The LSTM model has a lower MSE which is 0.000109, indicating that it is better at reducing the average squared difference between the predicted and actual values.And, the ANN model is better at minimizing the average distance between the predicted and actual values and has a lower percentage difference between the predicted and actual values which is RMSE 0.00436 and MAPE 1.85%.Further research can be done to improve the performance of the model by incorporating additional variables or changing the model architecture.
Predicting economic trends, and the impact of the environment on these trends are the goals of forecasting[8][9].The research's prediction results are expected to aid in the creation of a mathematical model for river water pollution, which will be tested and trained on relevant datasets through the use of Artificial Neural Networks (ANN) and Long Short-Term Memory (LSTM) techniques, and its effectiveness will be assessed.Neuronal Network (ANN) and Long Short-Term Memory (LSTM).
Figure I. LSTM Architecture ANN has two different configurations with 128 and 1 neurons, whereas LSTM has only one configuration with 128 neurons.The step size for the model to update the weights during the training process, both models have a learning rate of 0.001.The number of training samples used for each update of the model's weights during the training process.ANN has a batch size of 32, while LSTM has a batch size of 48.The function used to introduce non-linearity in the model's output.Both models use the Rectified Linear Unit (ReLU) activation function.The function used to measure the error between the predicted and actual outputs of the model.Both models use the Mean Squared 2003 * Corresponding Author: Sekarlangit Volume 07 Issue 04 April 2024 Available at: www.ijcsrr.orgPage No. 2000-2005 Error (MSE) loss function.The algorithm used to optimize the weights during the training process.Both models use the Adam optimization algorithm.The strategy used for the training process.ANN uses a regular training strategy, while LSTM uses early stopping to prevent overfitting.Based on the given configurations, it can be observed that the ANN model has a higher number of configurations with different hidden neurons, while the LSTM model has a fixed configuration with 128 neurons.The learning rate is the same for both models, while the batch size, activation function, loss function, and training optimizer are also the same.However, the training strategy is different for the two models, where ANN uses a regular training strategy, while LSTM uses early stopping.

Figure II .
Figure II.The Result of ANN