MONTHLY RAINFALL FORECAST IN THE MUNICIPALITY OF BARRA MANSA/RJ USING DEEP LEARNING TIME SERIES TECHNIQUES

Precipitation forecasting is essential for sectors such as water resources management and urban planning. In this study, a deep learning model was developed to predict rainfall in Brazilian cities, focusing on the municipality of Barra Mansa, Rio de Janeiro. Four neural network architectures were tested: FCN, Resnet, ResCNN and InceptionTime. Among them, FCN stood out significantly, presenting the lowest error rates and the best overall adjustment. The study highlights the ability of deep learning, especially through the FCN (Fully Convolutional Network - Segmented) architecture, to make accurate predictions and uncover hidden rainfall patterns. Such discoveries have great potential to improve rainfall forecasting systems and assist in decision-making in areas that require accurate climate information


INTRODUCTION
Accurate and reliable forecasting of weather conditions is essential for diverse sectors, from agriculture and energy to water resources management and natural disaster prevention.One of the fundamental aspects in this process is precipitation forecasting, which plays a crucial role in understanding weather patterns and making informed decisions (BABA et al., 2014).
In this context, a better understanding of a region's rainfall regime is essential for making strategic decisions, especially in urban environments.In particular, the ability to anticipate intense precipitation and floods becomes a vital tool for society, allowing the implementation of preventive measures and the significant reduction of negative impacts associated with extreme weather events (TAVARES DINIZ, 2013).With the advancement of artificial intelligence technologies, the application of Machine Learning and Deep Learning algorithms has proven to be a promising approach to improving the accuracy of precipitation forecasts.
Rainfall stations, responsible for measuring and recording the amount of rainfall in certain regions, provide valuable historical data for climate analysis (INMET, 2011).However, interpreting these records can be a complex challenge due to the variable and non-linear nature of meteorological phenomena (SILVA, et al., 2010).It is in this scenario that Deep Learning stands out, allowing the development of models capable of capturing hidden patterns in historical data and providing more accurate and reliable predictions.
The architectures chosen to integrate deep learning experiments are typically used for object detection and image processing.However, they showed notable results when applied to time series processing, as they are classified as convolutional neural networks (CNN).This category is widely used in the field of time series classification, quite possibly due to its robustness and low computational training time compared to other more complex architectures (ISMAIL et al., 2019).
Deep learning, a subfield of Machine Learning, involves using deep artificial neural networks to learn complex representations of data.Deep neural networks, such as convolutional neural networks (CNNs) and recurrent neural networks (RNNs), have proven particularly effective in modeling temporal data sequences, such as historical rainfall station records.These networks are capable of learning long-term patterns, capturing temporal and spatial dependencies in the data, which contributes to more accurate precipitation prediction (GU et al., 2019;SOUSA et al., 2017).
In a similar study, an evaluation of the simulation of hydrological behavior was conducted in the Alto Canoas river basin, located in Santa Catarina, using artificial neural networks of the Multi Layer Perceptron (MLP) type.Twelve sets of treatments were explored, consisting of different combinations of variables, such as precipitation, evapotranspiration and flow, with the aim of determining the most suitable variables for modeling flow.The MLP was subjected to training, using part of the observed flow data.Furthermore, flows were simulated in open and closed mode during the test period.The treatment that presented the best performance used the daily precipitation recorded at four rain gauge stations, considering a response time of -2 days, together with the simulated flow from the previous day.Although the value of the mean squared error was low, a tendency to overestimate the flow modeled by MLP was observed (DEBASTIANI; SILVA; NETO, 2016).
Other studies in the field of water resources showed that results achieved with the application of the Recurrent Neural Network (RNN) model with the LSTM (Long Short Term Memory) architecture validate several works found in the literature, which served as the basis for this research.Thus, results found in the literature have demonstrated that models based on neural networks were able to capture the patterns present in the time series of meteorological station data, presenting satisfactory performance in terms of predicting true positives.An investigation focused on expanding the forecast time interval may be beneficial to obtain even better results with this method (DONINELLI; GRZYBOWSKI; SILVA, 2020).
In this work, the applications of Deep Learning are explored for the use of a computational model that acts in the prediction of precipitation (mm of rain) based on historical records of rainfall stations in Brazil, focusing on the municipality of Barra Mansa, Rio de Janeiro.Improving this technique has the potential to improve rainfall forecasting capacity and contribute to more efficient management of water resources.

DEEP LEARNING ARCHITECTURES FOR TIME SERIES
Artificial Neural Networks (ANN) are valuable tools in the decision-making process.They are seen as fundamental instruments for optimizing the use of available resources and data, and can be used in regression, classification and data compression problems.The information processing carried out by these networks resembles the functioning of the human brain, using the principle of organization of neurons.Therefore, artificial neural networks are presented as promising allies in addressing complex challenges in practical situations, highlighting their importance and versatility in different contexts (PINHEIRO; AZEVEDO DOS SANTOS; PASA, 2020).
Unlike usual convolutional neural networks (CNNs), which are designed for categorization tasks, FCNs (Fully Convolutional Network) are capable of generating a point-by-point output that allocates labels to each point of an input figure.This implies that FCNs are appropriate for semantic division tasks, where the objective is to allocate class labels to each point in the figure, highlighting areas of interest.The FCN architecture employs convolutional layers to learn hierarchical representations of a figure, followed by transposed convolution layers (also known as "deconvolution" or "upscaling") to upsample the output resolution and create a split map with the same resolution as the input figure (ZHOU et al., 2016).
The Resnet architecture, also known as Residual Network, aims to solve the challenge of weakening gradients in deep neural networks.When applied to rainfall forecasting, Resnet has the ability to learn deeper and more intricate representations of precipitation time series, which enables more accurate modeling of weather patterns.The use of residual connections in Resnet allows relevant information to flow more optimally throughout the network, helping to capture temporal dependencies and improve forecast performance (HE et al., 2016).
The ResCNN framework, also known as Residual Convolutional Neural Network, combines the principles of residual networks with traditional convolutions.This architecture enables the propagation of residual information through the convolutional layers, improving data flow and avoiding gradient smoothing issues.In the context of rainfall forecasting, ResCNN is capable of learning the representation of precipitation time series more effectively and capturing pertinent characteristics related to rainfall patterns, resulting in more accurate forecasts (LONG; YAN; LIANG, 2019).
The InceptionTime model is based on the idea of Inception blocks, which enable the extraction of information on multiple temporal scales.This approach is especially advantageous in predicting rainfall, as it allows the neural network to learn characteristics present in different periods, ranging from short-term patterns to long-term trends.The InceptionTime architecture is capable of capturing intricate connections in precipitation time series, providing an abundant and efficient representation for rainfall forecasting (SZEGEDY et al., 2015).
Meteorological forecasting is emerging as a widely explored field for the application of temporal sequence analysis.Several approaches are used to solve problems of this type, covering both traditional statistical methods, such as the ARIMA (autoregressive integrated moving average) family of models, as well as machine learning and deep learning techniques.In the context of the time series model adopted by ArcGIS Learn, state-of-the-art convolutional neural network backbones specially adapted to temporal datasets are used.Among them, InceptionTime, ResCNN, Resnet and FCN stand out.What makes temporal sequence modeling unique is that, in the classic ARIMA methodology, several hyperparameters need to be finely tuned before model fitting, whereas with the current deep learning approach, most parameters are learned by the model itself, based on the available data.
Figure 1 presents explanatory diagrams that describe, in a didactic way, the four neural network architectures included in this work.

METHODOLOGY
The database known as the HydroBR Library was created to facilitate access to hydro meteorological information from monitoring stations distributed throughout the country, managed and under the responsibility of the National Agency of Water and Basic Sanitation (ANA) and the National Institute of Meteorology (INMET).Data acquisition takes place in such a way that data downloads, including those grouped into historical series, are carried out automatically (CARVALHO, 2021).
The program used has the function of importing precipitation data from historical series from any Brazilian city that contains rainfall monitoring stations.It is essential to highlight that data entry by the user consists only of the name of the desired city, and it is necessary to enter the same characters registered with the HIDROWEB (ANA) system.Furthermore, the model also identifies other information relating to each station surveyed, such as the responsible body, the geographic coordinates and the start and end dates of historical series measurements.
When the user selects the municipality and the rainfall stations to be surveyed, the program gathers the maximum average monthly precipitation (sum of daily rainfall) of the respective stations and correlates it to identify and learn the existing patterns and execute the rainfall forecast Este é um artigo publicado em acesso aberto sob uma licença Creative Commons. in subsequent years.Deep learning was used in historical series between 1940 and 2023 (explanatory variables).Afterwards, forecasts of precipitation events occurring in three subsequent years were evaluated, that is, the 36 months between July/2020 and June/2023.
To evaluate the efficiency of different computational models in predicting precipitation events, four Deep Learning architectures responsible for deep learning of the behavior of time series were tested, namely: FCN, Resnet, ResCNN and InceptionTime.
In this article, the municipality of Barra Mansa (Rio de Janeiro) was selected to evaluate the historical precipitation series from all rainfall monitoring stations available in the HIDROWEB system.
For the analysis of historical series in the context of deep learning of artificial neural networks, such as those associated with historical rainfall records, the parameters RMSE (Root Mean Square Error), MAE (Mean Absolute Error) and R-Square (R²) were used, which are defined as metrics widely used to evaluate the performance and accuracy of models.These parameters are fundamental for evaluating the performance and effectiveness of deep learning models in predicting historical series.They allow comparison between different neural network architectures and help identify those that best adapt to the analyzed data.
The RMSE (root mean square error) represents a measure of the standard deviation of the residuals between the actual values and the model predictions.It corresponds to the square root of the mean of the squared errors, providing an estimate of how well the model fits the data.The lower the RMSE value, the greater the model fit in relation to real values.This metric is particularly sensitive to large errors and is suitable for identifying significant discrepancies between actual values and predictions.
The MAE (mean absolute error), in turn, is a metric that calculates the average of the absolute value of the errors between the actual values and the model predictions.It measures the average magnitude of errors, regardless of their direction.MAE provides an estimate of how close model predictions are to actual values.In the same way as RMSE, the lower the MAE value, the greater the model's accuracy.R-Square (R² or R-squared), also known as coefficient of determination, is a statistical measure that indicates the proportion of variability in real values explained by the model.It ranges from 0 to 1, with 0 being when the model does not explain any variability and 1 being when the model explains all the variability in the data.R-Square is a global measure of model fit, and values closer to 1 indicate superior fit.

RESULTS AND DISCUSSION
After inserting the name of the city in the first processing stage of the program ("BARRA MANSA"), the model is capable of automatically identifying the number of rainfall monitoring stations associated with the entered municipality and their respective basic information, as can be seen in Figure 3.In the municipality of Barra Mansa/RJ, there are 10 (ten) pluviometric stations with precipitation data available, which vary between the years 1940 and 2023, that is, an interval of 80 years of monitoring at points distributed across the city.Collecting maximum monthly rainfall data allowed the program to create a general historical series of maximum values recorded for rainfall in the municipality of Barra Mansa/RJ.The maximum historical rainfall records, collected from the list of stations shown in Figure 3, can be viewed in the graph contained in Figure 4.It is possible to display the training results using the show_results() command, which is a way to evaluate the quality of the trained model and calculate the corresponding metrics.In the case of time series models, the show_results command will typically present two adjacent graphs.The graphs on the left show the actual terrain values, while the graphs on the right show the predictions made by the model after applying the validation data set.By comparing predictions to actual values or ground truth, you can get an indication of how the trained model is performing.For example, the model.show_results(rows=5)command provides a comparison between five target values and their respective predictions, as shown in Figure 5.  From the execution of the developed program, four deep learning architectures were tested (InceptionTime, Resnet, FCN and ResCNN), all suitable for processing of historical data series.The objective was to identify the correlation between these architectures and create a comparative chart.The main results obtained are presented in figure 7.
The metrics used to evaluate the performance of correlations in the tested architectures were the following: RMSE, MAE and R-Square (R-Square).The RMSE and MAE coefficients are responsible for measuring errors resulting from the comparison between real and predicted variables.In other words, the lower these values, the greater the model's ability to explain reality efficiently.The RMSE coefficient is particularly useful in situations where large magnitude errors are undesirable, unlike MAE. Figure 7 shows the results of applying the four deep learning architectures to predict precipitation events in Barra Mansa/RJ, between the years 2020 and 2023 (ULIANA et al., 2018).
With regard to the R-squared coefficient (R-Square/R²), it is a metric used to evaluate the distribution of data in graphs, with values varying between 0 and 1.In other words, the closer the R² is 1, the better the fit of the tested model/architecture to the collected data.In cases where the distribution of points differs significantly from a horizontal line, R² can assume a negative value, without violating mathematical principles (ULIANA et al., 2018).In the context under analysis, the time series of average maximum monthly precipitation present a theoretically unpredictable behavior, as evidenced by the graphs created.The values displayed in these graphs reveal highly irregular and random patterns, differing significantly from straight lines.
Through comparative analysis between the parameters that evaluate the performance of forecasting precipitation events in each of the deep learning architectures applied in the computational model, it was found that the FCN architecture presented the lowest RMSE error coefficients (102.5278) and MAE (76.1319), as well as the highest R-Square coefficient (0.69), in the analysis of precipitation data.

CONCLUSION
The computational model used, and its data processing methodology are in an initial stage.However, over time, is the aim is to demonstrate that Deep Learning techniques associated with Este é um artigo publicado em acesso aberto sob uma licença Creative Commons.
forecasting historical series and hydrometeorological variables have the potential to offer even more coherent and satisfactory results in precipitation forecasting.ANN (Artificial Neural Networks) presented promising results in predicting rainfall in the municipality of Barra Mansa/RJ.However, it is worth noting that the extreme values of actual precipitation, translated by the rain peaks contained in figure 7, were not predicted by the architectures evaluated.In general, these more discrepant data are more problematic in predicting data behavior, as they are far from the patterns learned by the program.The different ANN architectures used and the statistical analyses carried out to evaluate the performance of these networks are highlighted.Various artificial neural network architectures associated with Deep Learning were used to evaluate precipitation data predictions over time and determine their efficiency.The Deep Learning architectures included InceptionTime, Resnet, ResCNN and FCN, in which the FCN model resulted in the best coefficients that represent the accuracy performance in rain forecasting, based on actual data and on data predicted by the program.
These analyses were applied to rainfall data from Barra Mansa/RJ, covering the period from 1940 to 2023.However, they can be applied to any Brazilian city included in the historical records of HIDROWEB (ANA).Three coefficients for evaluating the performance of correlations in the tested architectures were considered: RMSE, MAE and R-Square.
Due to the best performance in terms of data prediction, the application of deep learning in the FCN architecture presented the lowest error coefficients, both MAE (76.1319) and RMSE (102.5278).Furthermore, the highest R-Squared value (0.69) was observed among the architectures tested, indicating a good performance in predicting real data for the years 2020 to 2023.

Figure 1 :
Figure 1: Diagrams explaining the learning principle of each network architecture used in the study.FCN: identifies each pixel of an image; Resnet: special memory to remember information; ResCNN: combination of FCN and Resnet; InceptionTime: analyzes the weather from different angles.

Figure 2
Figure 2 presents a flowchart of the work steps.

Figure 2 :
Figure 2: Flowchart explaining the steps taken to execute the program.The program steps were subjected to four neural network architectures: FCN, Resnet, ResCNN and InceptionTime.

Figure 3 :
Figure 3: Result of the survey of rainfall stations located in the municipality of Barra Mansa/RJ.

Figure 4 :
Figure 4: Time series created by the computational model, formed by the maximum monthly precipitation values in the municipality of Barra Mansa/RJ, between the years 1940 and 2023.

Figure 5 :
Figure 5: Target values x prediction values, for Deep Learning models.

Figure 6 :
Figure 6: Number of batches processed in the relationship between training and validation of the analyzed data.