## 3 Materials and Methods
An important concept in Markov models is absorbent states, which represent situations in which, once reached, the system remains indefinitely, such as extreme flood risk scenarios. Markov chains can be classified as regular or ergodic:  
* Regular chains ensure that any state can be reached within a finite number of steps. * Ergodic chains exhibit stable long-term behavior, converging toward a unique stationary distribution, irrespective of the initial state. For further details, please refer to Appendix B. The Long Short-Term Memory (LSTM) model was used as a benchmark comparator to evaluate the predictive performance of RF against a more complex, sequence-oriented deep learning model. Our goal was to compare the following two fundamentally different approaches:  
* Random Forest: a robust, interpretable, and computationally efficient model, well-suited for heterogeneous environmental data. * LSTM: a deep learning model capable of capturing temporal dependencies, but more computationally intensive and less interpretable. This comparison enabled us to highlight the strengths and limitations of each model in the context of flood risk prediction. The results showed that RF achieved higher accuracy (0.89 vs. 0.85), better precision and recall, and significantly faster training times, confirming its suitability for the task, especially when interpretability and efficiency are important. LSTM is a specialized recurrent neural network (RNN) designed to process sequential data while overcoming the limitations of traditional RNNs in capturing long-term dependencies. This capability makes LSTM particularly effective for analyzing time series, such as meteorological and hydrological forecasts. Its architecture incorporates memory cells that regulate data retention through the following three fundamental components:  
- Input gate--which updates the cell state with relevant new information. - Forget gate--which discards unnecessary data. - Output gate--which selects the most relevant information for prediction. By integrating multimodal data sources (e.g., satellite imagery, meteorological records, and hydrological datasets), LSTM enhances predictive accuracy by reducing biases and errors. Training the model involves Backpropagation Through Time (BPTT), an advanced optimization method that unrolls the network over time, mitigating vanishing and exploding gradients issues common in traditional RNNs. Despite its effectiveness, LSTM is computationally demanding and requires careful hyperparameter tuning to achieve optimal performance. In this study, the LSTM model was not used with default parameters. Instead, it was systematically optimized using GridSearchCV in combination with TimeSeriesSplit cross-validation. The following hyperparameters were explored:  
Batch size: [16; 32; 64]. Epochs: [50; 100]. Optimizers: ['adam', 'rmsprop']. Dropout rates: [0.2, 0.3, 0.4]. This resulted in a total of 36 combinations, each evaluated using 5-fold time series cross-validation, for a total of 180 training runs. The model was wrapped using KerasRegressor to ensure compatibility with GridSearchCV. The best-performing configuration was selected based on validation loss, and the final model was retrained using the optimal parameters. The training and performance metrics (MSE, RMSE, R2) were computed and visualized accordingly. The architecture of the optimized network, illustrated in Figure 3, includes several layers. **Input Layer**: Input Shape: (60, 1)  
This means that the model takes as input sequences of 60 timesteps, each with a single characteristic. **First Layer**: LSTM Units: 50  
Figure 3: LSTM architecture. return_sequences=True: This parameter indicates that the LSTM layer returns the entire output sequence for each timestep input, which is used as input for the next LSTM layer. **First Layer Dropout**: Dropout Rate: 0.2  
This layer helps prevent overfitting by randomly turning off 20% of neurons during training.