## 2 Materials and Methods
### Methodology  
Modeling was conducted using neural networks whose architectures are recommended for time series analysis: MAGRU; LSTM; and ARIMA-LSTM. The parameters for the LSTM model were selected as follows:  
* First Layer: An LSTM layer with 50 units and the parameter \"return_sequences = True\", allowing the sequences to be passed to subsequent layers;
* Dropout Layer: Following the first LSTM layer, a Dropout layer was applied with a neuron dropout rate of 20% (0.2) to prevent overfitting;
* Second Layer: Another LSTM layer with 50 units, where \"return_sequences = False\", ensuring that only the final output sequence is passed to the next layer;
* Second Dropout Layer: Another Dropout layer with a 20% probability of stabilizing the training process;
* Dense Layer: A fully connected (Dense) layer with 25 neurons to provide additional representation and transformation of features following the LSTM layers;  
Figure 5: Characteristics of the timeline: (**a**) trend of BOD\({}_{5}\) values over time after resampling; (**b**) seasonal component of BOD\({}_{5}\) values over time after resampling. Figure 6: The Autocorrelation Function (ACF) plot. The shaded region represents the confidence intervals for the chosen significance level. Bars extending beyond these intervals indicate statistically significant autocorrelation, while bars remaining within suggest that any observed correlation is likely due to random noise. * Output Layer: A final Dense layer with one neuron for predicting the target value, as the task involves forecasting a single output parameter;
* Compilation: This model was compiled using the Adam optimizer and the Mean Squared Error (MSE) loss function, which ensured the optimization of prediction accuracy for regression tasks;
* Training Parameters: A batch size of 32 samples and 100 epochs were selected for model training. The data were divided into training and testing sets in an 80/20 ratio using the \"train_test_split\" function. This model was trained on the training set, while the quality was assessed on the testing set;
* Normalization: All input features and target values were normalized to a range of 0 to 1 using \"MinMaxScaler\" to enhance the quality of training. The potential to enhance the efficiency of the LSTM model through the implementation of a model incorporating an attention mechanism--Multi-head Attention Gated Recurrent Unit (MAGRU)--was explored. This model combines a multi-head attention mechanism with Gated Recurrent Unit (GRU) layers, enabling it to effectively capture both temporal dependencies and the significance of individual features in the data (with significant features being defined as the month of the year in this context) [25, 26, 27]. The parameters of the MAGRU model are as follows:  
* This model begins with a multi-head attention layer featuring four heads. The size of the keys for each head is equal to the number of input features (22), allowing each head to focus on different aspects of the input data. This architecture enables the network to identify important dependencies among features across various time steps, thereby enhancing the extraction of temporal relationships;
* Following the multi-head attention layer, a Dropout layer with a dropout rate of 20% is included to prevent overfitting and improve the model's generalization capability. Additionally, layer normalization with a small epsilon value (\(1\times 10^{-6}\)) is applied to stabilize the network by normalizing the output of the attention layer;
* This model incorporates a residual connection that adds the original input data to the attention layer's input. This retains the original representation of the data while complementing it with the attention results to enhance feature characteristics;
* Two consecutive GRU layers, each with 64 units, are utilized for further processing of the temporal sequence. The first GRU layer returns sequences (\"return_sequences = True\"), while the second GRU layer outputs only the final hidden state.