## 3 Materials and Methods
### Integration of RF and Markov Chain Models
The flood risk forecasting process is structured into several phases, incorporating machine learning techniques, geospatial analysis, and stochastic modeling:  
* CSV files containing daily rainfall data from the ARPACAL gauge network (Calabria, Italy) were collected for the period 2014-2024. The original data, recorded at hourly intervals, were aggregated to daily totals. Non-numeric values (e.g., sensor errors, missing transmissions) were converted to NaN. Approximately 7.3% of the data were missing, with spatial and temporal variability. Rows with simultaneous NaNs across multiple stations were removed, while isolated gaps were filled using linear temporal interpolation. Stations with excessive missing data were excluded. TIFF files containing elevation data (DEM) are loaded and resized to increase resolution. Land use and lithology maps are loaded and resized to increase resolution. StandardScaleris used, which is a scikit-learn module used to standardize the characteristics of a dataset before being used for model training. * Feature extraction. Feature extraction was performed by combining spatial data on elevation, land use, lithology, and long-term average rainfall. Rainfall data were averaged by first computing the annual mean daily precipitation for each station over the period 2014-2024. These values were then spatially interpolated using ordinary kriging to generate a continuous raster of average rainfall. Each pixel in the study area was assigned the corresponding interpolated rainfall value. All features were then transformed into a structured array for model input. This data is then transformed into an array of features. * To reduce redundancy and improve computational efficiency, Principal Component Analysis (PCA) was applied to the input feature matrix, which included elevation (from LIDAR-derived DEM), land use (from Copernicus CORINE), lithology (from geological maps), and long-term average rainfall (from ARPACAL data). Each raster was spatially aligned and flattened, resulting in a dataset of 84,656 spatial units (pixels), each described by four standardized variables. * PCA was applied globally to the entire feature matrix, rather than separately by feature group, in order to capture the joint variance structure and potential interactions among topographic, geological, and meteorological variables. The transformation was performed after standardization using StandardScaler, ensuring equal contribution from all features regardless of scale. * The number of principal components was determined by setting n_components=0.95, retaining only those components necessary to explain at least 95% of the total variance. This resulted in the retention of seven principal components. The first three components alone accounted for approximately 95% of the variance, with PC1 dominated by lithological variables (especially clay and sandstone), PC2 by limestone, and PC3 by land use classes (notably forest and urban areas). * The Parallel function of joblib is applied to perform operations in parallel, leveraging multiple processors or threads to improve performance and reduce execution time. * Creating the machine learning model. A Random Forest model is trained on training data (80%) to classify areas into different risk classes. * Implementation of the Markov model. A Markov chain is created to predict transitions between risk classes. * Flood risk classification. * Creation of the flood susceptibility map. The model's forecasts are used to generate a flood risk map, with different risk classes (Low, Moderate, High, Very High). * Maps view. The map is displayed using a color map to highlight the different risk classes. Figure 4 illustrates the development phases of the RF-Markov model. Figure 4: RF-MARKOV Model. Predicting the evolution of flood risk over time is crucial for emergency management and resource allocation. The integrated model provides valuable insights for developing effective mitigation and response strategies, supporting decision-making to protect communities and minimize impacts.