A neural network-based prediction model in water monitoring networks

To improve the prediction accuracy of ammonia nitrogen in water monitoring networks, the combination of a bio-inspired algorithm and back propagation neural network (BPNN) has often been deployed. However, due to the limitations of the bio-inspired algorithm, it would also fall into the local optimal. In this paper, the seagull optimization algorithm (SOA) was used to optimize the structure of BPNN to obtain a better prediction model. Then, an improved SOA (ISOA) was proposed, and the common functional validation method was used to verify its optimization performance. Finally, the ISOA was applied to improve BPNN, which is known as the improved seagull optimization algorithm–back propagation (ISOA–BP) model. The simulation results showed that the prediction accuracy of ammonia nitrogen was greatly improved and the proposed model can be better applied to the prediction of complex water quality parameters in water monitoring networks.


INTRODUCTION
As an important part of the new generation of information technology, the Internet of Things (IoT) has been widely researched and applied in various scenarios (Fang et al. , a; Khan et al. ). Although the emergence of IoT has greatly improved our lives with the increase in the type and number of sensor devices, the amount of data to be processed is also increasing (Taonameso et al. ; Fang et al. b, c). How to deal with data efficiently and accurately has become the focus of people's research.
As a method of data fusion, neural networks can abstract human brain neurons from the perspective of information processing and establish models, and compose different networks according to different connections which can be used for analysis and prediction. However, the neural network also has some shortcomings, such as falling into local optimization and poor generalization ability.
As one of the most widely used neural network structures, back propagation neural network (BPNN) is widely used in different fields. However, it is often unable to achieve global convergence and falls into local minima when solving complex problems, resulting in an invalid learning process. Additionally, the learning algorithm converges slowly, especially near the target (Han & Huang ). Therefore, in practical applications, the bio-inspired algorithm is often used to optimize its model structure. For example, the particle swarm optimization (PSO) algorithm is used to optimize BPNN to overcome the sensitivity and error fluctuation of the initial value of gradient descent method, and obtain the global optimal initial parameters which make the neural networks converge quickly (Wu As a newly proposed bio-inspired algorithm, the seagull optimization algorithm (SOA) has been proven to achieve better performance than some traditional algorithms (Dhiman & Kumar ). Therefore, in this paper, SOA was used to optimize the structure of BPNN to obtain an improved ammonia nitrogen prediction model. Then, considering the shortcomings of the SOA, an improved algorithm was proposed, and some benchmark functions were used to verify its performance. Finally, the improved SOA (ISOA) was applied to improve the BPNN to obtain a better prediction model. The simulation results verified that the performance of the model is better than that of the traditional model and the model using PSO to optimize BPNN. In other words, the proposed algorithm can be applied to a more complex water quality environment for water quality detection.

SOA
The SOA is a novel bio-inspired algorithm for solving computationally expensive problems. This algorithm has a good global search ability, it imitates the way a seagull circles over its prey, and its attack will affect the local search ability of this algorithm (Dhiman & Kumar ; Jia et al. ).
Mathematical models of predator migration and attack are discussed. During the migration, the algorithm simulated how a group of gulls moved from one location to another. A seagull must meet the conditions in Equations (1)-(5).
To avoid collisions between adjacent search agents, we use an additional variable A, to calculate the new search agent location.
whereC s represents the position of the search agent which does not collide with other search agents,P s represents the current position of the search agent, x indicates the current iteration, and A represents the movement behaviour of the search agent in a given search space.
where f c is introduced to control the frequency of employing variable A, which decreases linearly from f c to 0. After avoiding collisions between neighbours, the search agents move towards the direction of the best neighbour.
whereM s represents the positions of the search agentP s towards the best-fit search agent P bs ! . The behaviour of B is randomized and is responsible for balancing between exploration and exploitation properly. B is calculated as: where rd is a random number in the range of [0, 1].
Lastly, the search agent can update its position with respect to the best search agent by: whereD s represents the distance between the search agent and best-fit search agent.
This development is designed to take advantage of the history and experience of the search process. When attacking prey, the spiral action takes place in the air.
This behaviour in the x, y and z planes are represented as follows: where r is the radius of each turn of the spiral, k is a random number in the range (0 < ¼ k < ¼ 2π), u and v are constants to define the spiral shape, and e is the base of the natural logarithm. The updated position of the search agent is calculated using Equation (6)-(9), and the positions of the other search agents can be calculated using Equation (10): whereP s saves the best solution and updates the position of other search agents.

ISOA
Due to the randomness of factor B, the traditional SOA has a poor optimization effect and is prone to fall into local optimization. Therefore, an improved factor B is expressed as follows: where Cx kþ1 i represents the ith (i ¼ 1, 2, 3, Á Á Á , n) iteration of the kth chaotic variable, and μ is generally 4. The transformation between the chaotic variable and the original variable is as follows: 10: r ← u × e kv 11: Calculate the distanceD s using Equation (11) 12 where x L,i and x U,i are the search upper and lower bounds of the ith dimension variable, respectively, and y k i is the value obtained by transforming the ith chaotic variable Cx k i into the optimization variable after chaotic mapping.
The idea of the improved SOA is to use chaotic after iteration to conduct chaotic iteration on the location of a seagull with the best fitness and increase its diversity. First, the original variables are mapped to chaotic variables using Equation (13), and then transformed using Equation (12). Finally, the original spatial position value is returned by Equation (14). If the position after the chaos is better than before the chaos, save it; otherwise, save the position before the chaos.

Functions test
In this section, the improved algorithm is tested on some unimodal and multimodal benchmark functions (Dhiman & Kumar ). The information of these functions is shown in Table 2.
Here, the PSO, the traditional SOA and the ISOA are used for comparison. The parameter settings of each algorithm are shown in Table 3  As can be seen from the figures and the tables, the optimization effect of the SOA is better than that of the PSO, and the convergence speed is faster. When        layer is V ih , and the threshold value of hth neuron in the hidden layer is θ h . The connection weight of hth neuron in the hidden layer and jth neuron in the output layer is W hj and the threshold is θ j . The input of the hth neuron in the hidden layer is A h and C j is the input of the jth neuron in the output layer.
Assuming the actual value of jth neuron in the output layer is R j , the total error of network output is: BPNN adopts the gradient descent method to adjust the weights and thresholds of the network to obtain better output. The following equation can be obtained by expanding the error to the hidden layer and then to the input layer: where f(Á) is represented as an S function. It can be seen from the above that error E is related to the thresholds and weights. Therefore, the final error can be changed indirectly by changing the weights and thresholds.
The related equations of the weights and thresholds are as follows: where k ¼ 1, 2, Á Á Á , N À 1 is the number of samples.

ISOA-BP
The main idea of the ISOA-BP hybrid programming is to optimize the weights and thresholds of the back propagation network based on the ISOA. The main steps are shown as follows.
Step 1: Set the parameters of ISOA, including the number of seagulls. The weights and thresholds of the BPNN that need to be optimized are encoded as the initial seagull population.
Step 2: Initialize the position of seagulls and use Equation (7) to change their position so as to avoid collisions.
Step 3: Calculate the fitness of all seagulls at present, and find the best one as the best seagull in this iteration.
Step 5: Chaotic algorithm (Equations (12) better than the old one.
Step 6: To determine whether the iteration times or required accuracy are reached, output the final position as the optimal seagull position; otherwise, return to step 3.
Step 7: Decode the optimal output into the initial weights and thresholds of BPNN, and train the neural network until it meets the requirements.

Data pre-processing
Data from May to August in 2016 for a river in Qinghai province were collected once a day, including water temperature ( C), pH, dissolved oxygen (mg/L), conductivity (μs/cm), turbidity (nephelometric turbidity units, NTU), permanganate index (mg/L) and ammonia nitrogen (mg/L). A total of 123 groups of data were collected. The first 100 groups of data were used to train the network and the last 23 groups of data were used to verify the network performance.
Before using the sample data for training, it is necessary to process the sample data and pre-process the missing or wrong data. After that, the following equation was used for normalization: where x i and y i are the data before and after normalization, and x i max and x i min are the maximum and minimum values of data before normalization.

Simulation results
In this subsection, the back propagation (BP), PSO-BP, SOA-BP and ISOA-BP models are compared to verify the performance of BPNN optimized by the ISOA. The parameters of each model are shown in Table 5, and the Max iterations are 1,000, train function is trainrp, number of seagulls is 100, iteration times of seagulls is 30 and the structure of BP is 6-7-1.
The convergence comparison of different models is shown in Figure 6. As can be seen from Figure 6, the proposed ISOA-BP model has a smaller convergence value, which is better than that of the BP, PSO-BP and SOA-BP models.
As can be seen from Figure 7, the proposed ISOA-BP model has a faster convergence speed, which converges to the optimal value faster, and its convergence value is better than that of the BP, PSO-BP and SOA-BP models.
In other words, the predicted value of the proposed algorithm is closer to the actual value. The simulation results of 23 groups of validation data from different models are shown in Figure 7.
As can be seen from Figure 8, the average error of the predicted value of the proposed algorithm is the smallest,    which indicates that the predicted value is closer to the actual value. The predicted value of the proposed ISOA-BP prediction model is closer to the actual value, which shows more accurate prediction accuracy than the traditional BP, PSO-BP or SOA-BP prediction models.
In Figure 8 shows the error comparison of the four models, and the value is the absolute value of the error. It can be seen from the figure that the proposed model has the lowest error value for the verification samples, the lowest average error and the highest prediction accuracy.
The following two evaluation methods are used to evaluate the prediction accuracy of different models (Yu & Bai ).
2: Nash-Sutcliffe Efficiency (NS) where x i represent the actual output of the test data, p i is the predicted output of the test data, x is the average of the actual output of the test data, and n is the number of samples. For the first evaluation method, the lower the value, the better the effect. For the second evaluation, the closer the value to 1, the better.
The results of the above two evaluation algorithms calculations are shown in Table 6.
As can be seen from

CONCLUSIONS
Since the traditional BPNN is easily limited to local optimization, which leads to the low accuracy of ammonia nitrogen prediction, in this paper, the SOA is adopted with strong optimization performance to optimize the weights and thresholds of BPNN. Because of the shortcomings of the SOA, this paper proposes an improved algorithm to optimize BPNN by using chaos. The simulation results show that the prediction accuracy of the proposed model is higher than that of the traditional BPNN, PSO and SOA models. The prediction accuracy of the new model is higher and the effect is better, which can be applied to predict ammonia nitrogen in more complex water environments.