## 3 Materials and Methods
Before starting the model training, it is essential to configure several key hyperparameters. A hyperparameter search technique should be applied to determine the parameters that optimize the model's predictive performance. The proposed study selected Grid Search for its comprehensiveness, simplicity, and reliability. The specific hyperparameter considered in this study was:  
* n_estimators: This refers to the number of trees in the forest. A higher number of trees enhances the model's performance by reducing variance. * max_features: This parameter specifies the number of features to consider when splitting each node. By using'sqrt', you ensure that each tree is trained on a distinct subset of characteristics, which enhances diversity and minimizes the risk of overfitting. * max_depth: This defines the maximum depth of each tree. A greater depth allows for the capture of more complex patterns, but intense trees can lead to overfitting. It is important to find a balance when selecting the depth. * min_samples_leaf: This parameter sets the minimum number of samples required to form a leaf. It helps prevent the creation of overly specific subdivisions that may contribute to overfitting. * min_samples_split: This indicates the minimum number of samples to split a node. Similarly to min_samples_leaf, this parameter aims to reduce excessive subdivisions. The rationale for choosing these hyperparameters is based on achieving a balance between model accuracy and computational efficiency. Increasing the number of trees (n_estimators) improves model performance by reducing variance, but too many trees can increase computation time without significant performance gains. A value of 300 was chosen as a good compromise between accuracy and computational efficiency. The limitation in its choice is dictated by computational constraints and the need to contain training times. Setting max_features to'sqrt' ensures that each tree is trained on a different subset of features, increasing diversity among the trees and reducing their correlation. This enhances the model's robustness. Selecting a max_depth of 30 enables the model to capture complex patterns while preventing overfitting. Min_samples_leaf and min_samples_split help prevent overly specific subdivisions, improving the model's generalization. The hyperparameter search was conducted using Grid Search, which explores all possible combinations of a predefined set of hyperparameters (Table 1). This technique ensures that no potentially optimal combination is overlooked. The study used the fit  
Figure 2: RF Model. method to train the model on different combinations of hyperparameters as part of the Grid Search process. This method is crucial because it enables the model to learn from the data and adjust its internal parameters to minimize prediction error. Cross-validation was used to evaluate the model's performance on different sections of the dataset. A 3-fold cross-validation was employed, dividing the dataset into three parts and training and validating the model three times for each combination of hyperparameters. The dataset consisted of spatial units (grid cells) characterized by environmental and topographic features: elevation, land use, lithology, and average rainfall. These features were extracted from LIDAR, CORINE Land Cover, and ARPACAL rainfall data (2014-2024). The target variable (predictand) was the flood risk class assigned to each unit, categorized into four ordinal levels (low, moderate, high, very high), derived from PCA-based classification. The expression \"different sections\" refers to the three subsets created during 3-fold cross-validation. The dataset was randomly partitioned into three equal parts. In each iteration, two-thirds were used for training and one-third for validation, rotating the folds across three runs. After completing the Grid Search, the best-performing model is selected based on the chosen evaluation metric, which in this case was accuracy, equal to 0.87 during the hyperparameter optimization phase.