APPLICATION OF THE NONLINEAR AUTOREGRESSIVE MODEL WITH EXOGENOUS INPUTS FOR RIVER LEVEL FORECAST IN THE AMAZON

The present work is justified by three basic lines that involve the problem of the theme, which are the use of Artificial Intelligence, the problem of floods in the Amazon and the issue of technology in favor of decision making. The environmental impacts caused by economic and social factors are problems portrayed in scenarios such as floods and ebbs of rivers, bringing up situations such as an increase in diseases, reduction of agricultural production in locations that depend on accurate geological control, in addition to the increase in erosive processes. in risk locations. Thus, the use of AI to predict the river level, which consequently can minimize problems arising from floods that cause an environmental impact, is highly possible, since when it is known in advance that an event is close to happening, decisions can be taken so that the impacts be smaller. This work models and applies NARX to forecast the river level in the Amazon with variables of easy access and implementation through the MATLAB software, in order to contribute with a forecast model capable of predicting a possible flood from the river level. with Artificial Neural Networks: Application to the river basin, Hydrological models with RNA N, this


Introduction
In Brazil, natural floods occur every year and some caused over the years, causing damage and these could be avoided if they were foreseen. There are a variety of methods for forecasting river-level floods that can help society, especially riverside people. For stochastic flood prevention, a large amount of data samples is needed, so that the accuracy of the forecast is high and thus can be effective (FAVA, 2015). In the North of Brazil, there is a large number of heavy rains and these events cause flooding and possibly economic and social losses, such as loss of materials and individuals, proliferation of diseases and homeless people (SILVA, 2006). Among the existing forecast models, the stochastic ones stand out, which use data, preferably in real time, to make the forecast with more probability of success. Among the stochastic models, there are those that use Artificial Intelligence techniques, which are used because they have greater feasibility of implementation and satisfactory accuracy, which provides a greater potential for flood alerts, in order to avoid catastrophes and large losses (FAVA). , 2015). Stochastic models that make use of Artificial Neural Networks have the advantage of not needing explicit knowledge of the watershed, since ANNs work well in this scenario due to the way in which the neurons that compose them are learned (MARACAJÁ, 2005;GORODETSKAYA, DA FONSECA and DE MELO RIBEIRO, 2017). The objective of this work is to apply the non-linear autoregressive model with exogenous inputs to forecast the river level in light of the scenarios of environmental impacts caused by floods or ebbs in the state of Amazonas. To achieve this objective, the following steps were carried out: Identify the significant input variables with correlation with the output variable for river level prediction, define optimal settings (number of layers, training algorithm, activation functions, number of neurons). for application in the forecast model, simulate forecasts with the ideal configurations of the model to verify its accuracy, compare the results obtained observed record of the 2010 historical series, the median and the permanence series from 2021 to 2021, the envelope curves represented by the blue band characterize data between 15 and 85% permanence for daily quota data (CPRM, 2021). According to Alves (2021) the blue band curves presented in Figure 1 express values to be analyzed carefully, that is, for values above the band, it represents an expressive flood process and, for the values below, an accentuated ebb process. Figure 2 illustrates a comparison of historical highs and lows recorded in Manaus, capital of the state of Amazonas, over a period from 1903 to 2019. ISSN 2411ISSN -2933ISSN 01-03-2022 International Educative Research Foundation and Publisher © 2022 pg. 308 It is possible to identify that the historical maximum of 2.997 cm is reached in 2012 as shown in Figure 2, this shows the expressive increase in the river level as a result of external events that directly influence the change in hydrological behavior. Every year, global climate influences affect and harm the situation of the residents of the riverbanks and the presence of deforestation further aggravates the situation of climate change within the Amazon.

Methods and models for time series prediction
In the literature there are some models for forecasting time series, among them the following models can be cited: ARIMA, SARIMA, RNA and NARX. ARIMA is generally used for short-term forecasts, in which the data behavior is not seasonal, whereas SARIMA is used for series that have seasonality. ANNs and the NARX model can be used for both types of time series (BLÁZQUEZ-GARCÍA et al., 2020;WANG et al., 2015).

Statistical Models
Statistical models are simple to implement and have the characteristic of having a good performance when the forecast is short-term, these models use a historical data to base and predict steps forward (CHANG et al., 2014

RNA Model
The ANNs were initially constituted in 1943 by Mcculloch and Pitts, in which this AI technique was based on the functioning of human neurons, thus imitating the learning capacity that the brain has to learn, having as a starting point a data history that simulates human experience over time and thus can determine a prediction (MCCULLOCH and PITTS, 1943). According to Haykin (2008), the neural network is like a processor with numerous processing units acting at the same time, which has the ability to store data and show the knowledge acquired through data processing. The representation of the human neuron and the Artificial Neural Network (ANN) can be exemplified in CERRI (2020) and PARENTE (2021). The artificial neuron imitates the behavior of biological neurons in order to learn according to training based on a history of data, and the model of a neural network consists of inputs that can assume any positive value indicating the number of variables to be used in the process. model. ANN models have three layers, being divided into input layer, hidden layer and output layer (SILVA et. al., 2020;DE MENDONÇA et. al., 2021).

Input Layer:
In the input layer are the input variables, which are used to achieve the ultimate goal, be it predicting a variable x or y. Since the input variables must have a correlation with the output variable, the greater the correlation between the variables, the better the final result. It is worth mentioning that the forecast loses reliability in the measure of predicted steps ahead, example: Forecasting data from one day ahead is easier than forecasting from 365 days ahead. Hidden Layer: The hidden layer contains the neurons that are responsible for approximating the most suitable values to achieve the intended final result, such approximation values are known as weights. The hidden layer can be composed of several sublayers and with n neurons in each of them.

Output Layer:
The output layer is the final result of the processing done by the Neural Network which may contain one or more dependent variables as a result.
In DE MENDONÇA et al., (2021), the architecture of a multilayer RNA, also known as MLP, is presented. The process of building an ANN has some parameters, among them, there is the definition of the number of hidden layers, the number of neurons in each layer, the definition of the variables to be used in the problem to be solved, defining the algorithm of Neural Network training, find the best transfer function and use parameters to measure ANN performance. These are the main elements for the development of an ANN.

Definition of variables:
The first process is to define the input variables, which must have a correlation with the output variable, which is the result to be found. For a good variable definition, there must be the same number of records between both input variables.

Number of hidden layers:
The number of hidden layers is usually defined by trial and error tests to arrive at the number that best suits the problem under study. Few hidden layers can harm the performance of the ANN, many hidden layers also happens the same, so it is necessary to test several layers to verify how many layers the studied problem has a better performance.

Number of neurons:
With neurons, the premise is the same as the number of hidden layers, it must be tested to find the best amount, thus aiming to achieve the best possible performance of the ANN.

Training Algorithm:
The training algorithm is intended to make the ANN learn from historical data. Each algorithm has its particularities, some are better for forecasting seasonal data, others linear, and others for pattern identification. Therefore, it is interesting that in the process of choosing the training algorithm, some algorithms are tested to identify the best one for the problem under study. There are some training algorithms, among the best known can be listed 12 algorithms, namely: •

Transfer function:
The transfer function is present both in the hidden layers and in the output layer, there are some transfer functions that can be found in REIS et al., (2018).
International Journal for Innovation Education and Research www.ijier.net Vol:-10 No-3, 2022 International Educative Research Foundation and Publisher © 2022 pg. 311 Performance parameters: There are some performance parameters that can be used to evaluate the performance of an ANN, the most used being MSE, RMSE, Regression and MAPE. There are some RNA variants, including NARX, which is the technique selected for this study. This model is widely used for time series forecasting (MATKOVSKYY and BOURAOUI, 2019;WUNSCH, LIESCH and BRODA, 2018). DE MENDONÇA et. al., (2021), shows the operation of the NARX Neural Network, which has an input layer, a hidden layer and an output layer, the main difference between an Artificial Neural Network and NARX is that the NARX model has feedback, being indicated for time series forecasting, especially if there is seasonality in the input and target data.

Materials
The materials of this article will be presented below.

Significant Variables for the Forecast Model
The variables used for the forecast model are shown in Table 1.

Methods
The research is characterized by the investigation of computational methods that show efficiency in data processing and effectiveness in simulating the results, to apply the concepts related to the forecast of the river level in function of the scenarios of environmental impacts caused by floods or ebbs, through database referring to the river level in the state of Amazonas, an analysis was carried out on the content.

Survey of Data Relating to the River Level
The data collection must be done in meteorological databases, or specific sites that show the collection of data in a chronological way, in such a way that it is possible to use this recorded history. The mapping of the input variable must be done through the National Institute of Meteorology by consulting the database, the output variable must be acquired through the Port of Manaus website.

Selection of Computational Methods for the Forecasting Model
In this step, the computational methods that should be used for the NARX learning process are defined, in this case, specifically because they are time series with seasonality, and stochastic variables related to the river level, it is necessary to use the model with inputs exogenous autoregressive.
The algorithms used to test the feasibility of using NARX were: Optimization, Heuristic, Iterative, Quasi-Newton, Newton and Numerical, these methods are of paramount importance for performing mathematical, stochastic procedures and iterative searches to find local and close to global solutions. , targeting minimization or maximization factors with respect to algorithm performance on a dataset.

Definition and Implementation of the NARX Architecture
As shown in Figure 3, the NARX architecture is composed of three (3) input variables, namely: Rainfall, Temperature and Relative Humidity, in addition, one (1) output variable, which is the river level. The concept of feedback, or Recurrent Neural Network, is due to the fact that the architecture provides Vol :-10 No-3, 2022 International Educative Research Foundation and Publisher © 2022 pg. 313 mechanisms to recursively call a function or pass the estimated parameter to a new training cycle without losing the a priori adjustment information. A regressive model, corresponds to the NARX architecture, through state space models, the transition function is responsible for mapping the current state and the current input of the dynamic system, in such a way as to return this without loss of information, characterizing a state transition (MUÑOZ CHÁVEZ, 2020), it can be represented by Eq. (3.1) and (3.2).
In this way, a regressive model like NARX has its terminologies similar to a statistical model, in such a way that the computational model reaches an expected and estimated degree of precision, thanks to the implemented mathematical models that give support and consistency in the approximation of functions to the use a training algorithm. Table 3 presents a comparison of the terminologies of a NARX regression model and a statistical model.  Figure 4, for the execution of the simulation procedures and comparison of the results with the winning algorithm, 3 steps will be necessary, namely: Selection of n layers and best transfer function; Selection of n neurons, number of feed delays and use of Parallelism; finally, Simulation with 12 training algorithms. Figure 4 -Steps for simulation and comparison of results.
The first step consists of performing verification and testing procedures to find the ideal number of layers and the best transfer function, based on a simulation range from 1 to 10, where Linear, Hyperbolic Tangent and Sigmoid transfer functions are used. With this, it is expected to obtain satisfactory results due to a number of 30 Neural Networks trained and able to perform predictions, in this way the developed algorithm must analyze and point out the best ANN architecture to be used in the next step. The second step consists of selecting an amount x of neurons, an amount y of feed delays and the use of parallelism or not. Due to the demand as a function of time and computational cost, it is necessary to take advantage of the auxiliary processors of the test machine, characterizing parallel computing. In this way, it is expected to find the satisfactory amount in a range of 10 to 15 neurons, a satisfactory amount of feed delays ranging from 1 to 5 and the definition of the computational cost for using parallel computing. Finally, the third step consists of actually training the best ANN architecture using a method of statistical analysis by calculating 12 training algorithms, in such a way that it is possible to define the best ANN with the optimized algorithm depending on the quantity characteristics. of layers, neurons, activation functions and use of parallelism.
The algorithm will have as main workflow, 5 steps that lead to the generation of results, that is, graphs, tables and performance indicators according to training and simulations.
International Journal for Innovation Education and Research www.ijier.net Vol:-10 No-3, 2022 International Educative Research Foundation and Publisher © 2022 pg. 315 Step 1 -Initializes the NARX parameters; Step 2 -Configure the tested parameters; Step 3 -Select the current algorithm n of 12; Step 4 -Calculates and analyzes training performance; Step 5 -Capture the results.
To statistically analyze the ANN training performance as a function of its characteristics, in this case, calculated model and approximate model, it is done through four mathematical models to measure errors through the waste flow and dispersion rate, called: Where: MSE = Mean Square Error; RMSE = Root Mean Square error; MAPE = Mean Absolute Percent Error; n = number of elements in the output vector; ra = target result; rs = simulated result; Y = is the dependent variable and Ŷ_t is the predicted value of Y given an X_i; X = is the independent variable; α = is the predicted value of Y when X = 0 (the intercept); β = is how much Y changes, on average, per unit change in X (the slope).
Due to the use of statistical models to analyze the error rates, a mathematical model expressed by Eq. (3.6) was prepared in order to facilitate the process of selecting the best ANN architecture based on these indicators, in such a way that, the lower the value acquired by this indicator, the better the performance.
In the end, the algorithm should generate analysis results with performance indicators of the simulation performance and of the scenarios projected for the river level prediction problem.

RESULTS AND DISCUSSIONS.
The partial results are in accordance with the steps planned for the research, where it was carried out in order to validate the proposal and the hypothesis of a solution at work. For the qualification project, it was possible to acquire: • The database containing the meteorological records necessary for acquiring the forecast model; • The significant variables that will serve as the input history of the NARX model for the river level forecast; • The definition of the algorithm responsible for the river level prediction, computationally characterized as a prediction model.

Database
The database is composed of 4 variables, namely: Rain, Temperature, Humidity and River Level, Table 1 presents a sample of this database. It is worth noting that this table presents a stratification of data from 01/01/2000 to 06/30/2021 collected from the bases of the Port of Manaus and INMET. International Journal for Innovation Education and Research www.ijier.net Vol:-10 No-3, 2022 International Educative Research Foundation and Publisher © 2022 pg. 317 Figure 5 shows the flowchart of steps of the main algorithm, with five steps for acquiring the final results. Source: (AUTHOR, 2021).

Definition of the algorithm
Step 1 -Definition of parameters according to the characteristics of the NARX model; Step 2 -Reading the database and selecting significant variables for the forecast model, for training and simulation; Step 3 -Training of the Recurrent Neural Network, using the NARX model, definitions of the configurations of the training algorithms, data division and performance analysis; Step 4 -Execution of simulations according to the best Neural Network architecture and generation of results; Step 5 -Export of graphs, tables and indicators of simulation results and forecast model performance.

Algorithm Performance Tests
The first test aimed to find the ideal number of layers for the computational model and the transfer function with the best performance rate. Thus, the Levenberg-Marquardt training algorithm was used, where an interval of layers between 1 to 10 is tested, alternating between the 3 transfer functions: Linear, Hyperbolic Tangent and Sigmoid, Figure 6 shows the test scheme. Through the scheme, the results found are shown by Figures 7, 8 and 9, respectively with the functions: Linear, Sigmoid and Hyperbolic Tangent. The graph in Figure 7 shows expressive values when increasing the number of layers, as a result, the performance rate follows a varying pattern between 2 and 3, however, the time in seconds is also greater as the number of layers is increased. . Source: (AUTHOR, 2021). Figure 7 shows the graph of the Sigmoid function, it presents a different behavior compared to Figure 8, where the time in seconds increases as a function of the number of layers, however, the performance rate remains variable in a range of 6 to 7, it is possible to identify that the number of layers 7 presents the lowest results characterizing the best in relation to the range 1 to 10.
International Journal for Innovation Education and Research www.ijier.net Vol:-10 No-3, 2022 International Educative Research Foundation and Publisher © 2022 pg. 319 Source: (AUTHOR, 2021). Figure 9 shows the graph of the Hyperbolic Tangent function. other figures, where the variance occurs in a range of 1.5 to 4.3, it is possible to identify that even layer 5 presents the best results for performance and time in seconds. Figure 9 -Graph of the Hyperbolic Tangent function for the Layers test. Table 2 presents the values of the performance simulation results performed for the 3 transfer functions using the Levenberg-Marquardt learning algorithm, where it is possible to identify that the best (winner) is the Layer 5 Hyperbolic Tangent, with a time of 0, 90328, 17 epochs and a rate of 1.33307 for performance. The second test aimed to identify the ideal number of neurons for the layers, in this case 5 layers, having seen the result of the first test, in addition, the use of parallel computing is verified and the number of feed delays, as a result, where 1765 neural network models were totaled as a test for this step, as shown in Figure  10. Figure 10 -Test scheme for neurons.
Source: (AUTHOR, 2021). Source: (AUTHOR, 2021). Table 3 presents the results of the test to find the winning parameters for the best number of neurons that will be used with 5 layers in the computational model, it is possible to identify that the model with 2 feed delays, 15 neurons in the first layer, 10 in the second, 15 in the third, 10 in the fourth and 10 in the fifth, a performance rating of 0.9181 and a time of 1.6712 seconds, was the winner.

Conclusion
Through the results found with the computer simulations to find the ideal number of layers and the number of neurons, it is possible to affirm that the simulations were important to verify the performance and quality indicators of the computational model in function of the chosen training algorithm (Levenberg -Marquardt).
On the other hand, of the four specific objectives it was possible to develop two of them, in such a way that the significant variables for the forecast model were acquired, as mentioned in the materials section of chapter 3, the selection of indicator settings for the computational model (quantity number of layers, number of neurons, activation functions and number of feed delays) were acquired. Finally, the results presented here are of relevant characteristics for the continuity of the research and improvement of the parameters with other training algorithms to carry out comparisons of results with the NARX and SARIMA model in order to achieve the general objective of applying this computational model to the prediction of the river level due to the environmental impacts caused by floods or ebbs in the state of Amazonas.

Acknowledgement
To Institute of Technology and Education Galileo of the Amazon (ITEGAM) for supporting this research and the Postgraduate Program in Engineering, Process Management, Systems and Environmental (PPEPMSE). And to Academic Department of the Amazon State University -UEA.