## 3 Materials and Methods
This value represents the proportion of correctly predicted flood risk classes across the validation folds and was used exclusively to guide the selection of the optimal parameter combination during Grid Search. The optimal parameters identified were n_estimators = 300, max_depth = 30, min_samples_split = 2, min_samples_leaf = 1 and max_features ='sqrt' (Table 2). The total number of hyperparameter combinations is calculated as the product of the number of candidate values for each parameter:  
n_estimators: 3 values ([100, 200, 300])  
max_depth: 4 values ([None, 10, 20, 30])  
min_samples_split: 3 values ([2, 5, 10])  
min_samples_leaf: 3 values ([1, 2, 4])  
max_features: 2 values ([log2,'sqrt'])  
The total number of combinations would be: 3 \(\times\) 4 \(\times\) 3 \(\times\) 3 \(\times\) 2 = 216. The parameter'sqrt' in the context of Random Forest refers to the number of features to consider when looking for the best split;'sqrt' indicates that the number of features considered in each split is the square root of the total number of features. This approach balances the diversity of individual trees and the reduction of overall model variance. The log2 parameter indicates that, for each split of a tree, the maximum number of features to consider is the base 2 logarithm of the total number of available features. This value reduces the number of features evaluated at each node, increasing diversity between trees and improving model \begin{table}
\begin{tabular}{c c c c} \hline n\_estimators & max\_depth & min\_samples\_split & min\_samples\_leaf \\ \hline
100 & 10 & 2 & 1 \\
200 & 20 & 5 & 2 \\
300 & 30 & 10 & 4 \\ \hline \end{tabular}
\end{table} 
Table 1: Considered parameters. \begin{table}
\begin{tabular}{c c c c} \hline n\_estimators & max\_depth & min\_samples\_split & min\_samples\_leaf \\ \hline
300 & 30 & 2 & 1 \\ \hline \end{tabular}
\end{table} 
Table 2: Identification of optimum parameters. generalization. These are standard options in the Random Forest implementation in Python and are used to control the number of features considered at each split, balancing model diversity and variance reduction. To ensure reproducibility, we have made the full dataset structure, preprocessing steps, and model code publicly available at: [[http://github.com/Luigi2020357/Flood-Forecast](http://github.com/Luigi2020357/Flood-Forecast)]([http://github.com/Luigi2020357/Flood-Forecast](http://github.com/Luigi2020357/Flood-Forecast)). This includes the scripts used for feature extraction, model training, and evaluation. For further details, please refer to Appendix A.  
Markov chains are widely used for modeling probabilistic systems that evolve over time, providing insights into environmental and anthropogenic interactions [31]. In flood forecasting, each state represents a different level of risk, transitioning probabilistically based on current conditions rather than past history, an attribute known as the Markov property or \"short memory\" [32; 33]. A transition matrix \(P\) is used to describe these transitions mathematically. Each element of the matrix, \(P_{ij}\), indicates the probability of moving from state \(i\) to state \(j\) in a single step. The transition matrix is defined as follows:  
\[P=\left[ \begin{array}{ccc}P_{11}&\ldots&\ldots&P_{1n}\\ \ldots&\ldots&\ldots&\ldots\\ P_{n1}&\ldots&\ldots&P_{nn}\end{array} \right] \tag{1}\]  
where \(P_{ij}\) is the probability of transition from state \(i\) to state \(j\). The sum of the probabilities of transition from a state must be equal to 1, i.e.,  
\[\sum_{j=1}^{n}P_{ij}=1\text{ for each} \tag{2}\]  
In homogeneous Markov chains, (\(P\)) remains constant, and the stationary probability distribution \(\pi\) satisfies the equation \(\pi P=\pi\), ensuring equilibrium over time. Conversely, non-homogeneous Markov chains allow for transition probabilities to vary over time or due to external influences [34]. This adaptability enables the definition of multiple transition matrices (\(P\_t\)) for different time intervals, reflecting environmental changes.