Spatial prediction of flood-susceptible zones in the Ourika watershed of Morocco using machine learning algorithms Floods prediction in the Ourika watershed

Purpose – The purpose of the paper is to predict mapping of areas vulnerable to flooding in the Ourika watershed in the High Atlas of Morocco with the aim of providing a useful tool capable of helping in the mitigation and management of floods in the associated region, as well as Morocco as a whole. Design/methodology/approach – Four machine learning (ML) algorithms including k-nearest neighbors (KNN), artificial neural network, random forest (RF) and x-gradient boost (XGB) are adopted for modeling. Additionally, 16 predictors divided into categorical and numerical variables are used as inputs for modeling. Findings – The results showed that RF and XGB were the best performing algorithms, with AUC scores of 99.1 and 99.2%, respectively. Conversely, KNN had the lowest predictive power, scoring 94.4%. Overall, the algorithms predicted that over 60% of the watershed was in the very low flood risk class, while the high flood risk class accounted for less than 15% of the area. Originality/value – There are limited, if not non-existentstudies on modelingusing AI tools including ML in the region in predictive modeling of flooding, making this study intriguing.


Introduction
Natural disasters, including floods, pose a real threat to human life and can result in significant human losses and devastating economic consequences [1]. The potential magnitude of damage caused by floods has led some authors to consider them the most widespread and damaging of natural hazards [2]. Between 2000 and 2008, floods affected over 99 million people worldwide [3]. Due to heavy rainfall causing water to overflow into riverbeds, floods damage both natural ecosystems and infrastructure, including the transportation system [4].
Floods are the most widespread natural disaster in Morocco. They rank second only to earthquakes in terms of the number of victims and injured individuals [5]. The watersheds of the Moroccan High Atlas are highly vulnerable to flood risks [6]. Indeed, the Ourika watershed has experienced flooding due to scouring in the valley, killing more than 200 people in 1995 [5]. In 2002, torrential rains resulted not only in the loss of more than 60 lives but also in significant property damage in the Ourika Valley [5]. Similarly, flooding in the Tougha Gorge resulted in two deaths and the partial and total destruction of 26 and 114 houses, respectively.
In the Ourika watershed, flood hazards are caused by rising waters and overflowing rivers that originate in the High Atlas Mountains. After the widespread devastation caused by the 1995 floods, the Moroccan government took steps to reduce the impact of flooding. These measures include improved weather observations and forecasts, the establishment of monitoring systems, measures to protect land uses, measures to combat water erosion and the construction of anti-erosion structures. Nevertheless, flood susceptibility mapping is critical to addressing flood risks in the Ourika watershed.
To develop flood susceptibility maps, geospatial analysis techniques based on geographic information system (GIS), remote sensing (RS) and statistics have been extensively used [7,8]. Additionally, hydrological models such as Soil & Water Assessment Tool [9] and HYDROTEL [10], combined with GIS and RS have been employed for analyzing the various flood predisposing factors. A review of the literature shows the popularity of bivariate statistical methods, such as frequency ratio, value of information, weight of evidence and multivariate statistical methods, including logistic regression and multivariate adaptive spline regression, as approaches used in predictive mapping of natural disasters [11][12][13][14]. For flood prediction, Franci et al. [15] used high-resolution satellite imagery, GIS, and then multi-criteria analysis to produce flood risk maps with satisfactory results in Cyprus. In an alternative approach, Ziarh et al. [16] explored a data-driven multi-criteria decision analysis incorporating catastrophe and entropy theories in an effort to provide an unbiased assessment of flood risk distribution in Peninsular Malaysia.
While physical and statistical approaches may be sufficient in some cases, they remain limited for assessing the complex processes and interactions that influence natural phenomena such as floods. The recent success of machine learning (ML) models lies in their ability to not only account for nonlinearity issues related to physical processes, but also make it easier to model them at reduced costs [17]. Recent advances in ML techniques have made a considerable contribution to the enhancement of predictive flood hazard mapping [18]. Using ML algorithms, the limitations of traditional approaches can be addressed and the accuracy of predictions greatly improved [19]. Traditional techniques struggle to translate physical processes into mathematical terms [20]. Several ML algorithms have been successfully used to predict flood risks. These include artificial neural network (ANN), which is one of the most widely used ML algorithms for flood risk prediction [21][22][23][24][25][26][27]. Other ML algorithms have been used to predict flood risk such as support vector machine [28][29][30], random forest (RF) [17,31,32], logistic regression [7], adaptive neuro-fuzzy inference system [33] and Long Short-term Memory [34,35].
Due to the high vulnerability of the Ourika watershed to flood hazards [5] and the lack of predictive flood hazard mapping in the region, this study is aimed at using ML algorithms such as K-nearest neighbors (KNN), ANN, RF and extreme gradient boost (XGB) to predict flash floods and subsequently generate a flood susceptibility map of the Ourika watershed. Additionally, this study aims to compare the performance and results of the models. This will be done by (1) identifying the flood predisposing factors, (2) comparing the accuracy of the models, (3) producing the flood susceptibility map using ML algorithms and (4) comparing the model results. The susceptibility maps developed will serve as useful tools in flood prevention and mitigation in the Ourika watershed.

Materials and method 2.1 Study area
The Ourika watershed is located about 40 km south of Marrakech and covers an area of 576 km 2 ( Figure 1). The mean annual rainfall is about 541 mm, with a coefficient of variability of 34%. This variability depends largely on the month and the season, and can reach monthly and seasonal coefficients of about 55% and 50%, respectively. Geologically, the area is mainly made up of magmatic rocks in its upstream section and sedimentary rocks downstream. The land use of the watershed is characterized by a highly diversified vegetation cover.

Data acquisition
Analysis of past flood events is crucial to predicting future floods. In this study, data on historical flooding in the Ourika watershed were provided by the Agence du Bassin Hydraulique du Tensift. The flood points represented as polygons of areas that experienced flooding in past covered 1076 pixels each measuring 30m by 30m. Additionally, non-flood points were randomly selected from the watershed map in areas with a slope greater than 50%, covering a similar number of pixels (1076), resulting in a total of 2152 pixels for both flooded and non-flooded polygons. The 30 m resolution digital elevation model (DEM) used in this study was obtained from the ASTER GDEM website (https://asterweb.jpl.nasa.gov/gdem.asp).

Floods parameters and conditioning factors
Selecting flood conditioning factors to be used in predicting floods is often challenging, making it imperative to select the most suitable ones for flood susceptibility mapping [29,36]. The factors identified as numerical variables include: curvature, elevation, distance to rivers, drainage density, flow accumulation, rainfall, slope, topographic wetness index (TWI), normalized difference vegetation index (NDVI), stream power index (SPI) and wetness index (WI). Conversely, the categorical variables selected for this study include: aspect, flow direction, geology, land use and substrate erodibility. Detailed descriptions of both numerical and categorical variables as well as their spatial representation in the study area are included as supplementary material.

Machine learning algorithms used
Four algorithms were used for the modeling of flood susceptibility in the Ourika watershed. They include RF, extreme gradient boost (XGB), ANN and KNN. A detailed description of the algorithms has been included in the supplementary material. Four models were developed corresponding to each of the four selected algorithms. Thus, 16 models were used for prediction in this study. For a given algorithm (e.g. KNN), the created models were as follows: (1) KNN: neither one-hot encoding nor variable selection was performed

Cross-validation and feature selection
Feature selection involves identifying and selecting a subset of variables from the original data set, to use as inputs of ML models. It helps tackle the issue of overfitting and makes the models simpler to interpret while shortening training times, which reduces the computational cost. Feature selection is accomplished using wrapper methods, which help examine possible feature combinations to identify the optimal feature set. Using these methods, features are removed one at a time, or are added one at a time, an ML model is built and the performance is determined. The selection procedure ends when the best performing model is found. In this study, forward feature selection together with the leave-one-out cross-validation (LOOCV) method was adopted to filter out variables that cause overfitting. The CAST package for R was used as a wrapper for forward feature selection.

Handling of categorical variables
Real-world data often involve discrete variables including categorical variables. The nonnumerical nature of these variables presents several challenges when applying an ML algorithm. Thus, it is necessary to find a way to transform the data into numerical values. One-hot encoding is the most popular method for transforming a categorical variable into a numerical variable. Its popularity lies mainly in the ease of application. Moreover, for many problems, it yields good results. Consider a categorical variable X which has K modalities m 1 , m 2 , [. . .], m K . One-hot encoding involves creating K indicator variables such that a vector of size K has 0 values everywhere and 1 at position i corresponding to modality m i . Thus, the categorical variable is replaced by K numerical variables.

Models performance assessment
It is essential to assess the accuracy and overall performance of ML models. In this study, data splitting was used to separate the data into two distinct data sets: training and validation sets. From 2,152 data points, a subset of 70% of the data corresponding to 1,506 points was selected as the training data. The remaining 30% corresponding to 646 points were used to ACI evaluate performance. The model was trained through input of factor-flooding relationships and the resulting model applied to the entire watershed. The ROC-AUC curve was used to measure model performance. Receiver operating characteristic (ROC) is a graph illustrating the performance of a classification model at all classification thresholds while area under the curve (AUC) measures the entire two-dimensional area underneath the ROC curve and represents the degree of separability. Five AUC classes were highlighted in this study: poor (0.5-0.6), medium (0.6-0.7), good (0.7-0.8), very good (0.8-0.9) and excellent (0.9-1).

Flood susceptibility mapping
Based on the evaluation and correlations between each conditioning factor and the occurrence of floods in the Ourika watershed, and after validation of the models, the estimation of flood susceptibility values was carried out. Subsequently, the latter were reclassified into five susceptibility classes: very low, low, moderate, high and very high. This resulted in 16 flood susceptibility maps being producedone for each of the four different models of the four ML algorithms employed.

Model similarity assessment
An important concept in modeling is the assessment for similarities and dissimilarities between results. Indeed, these are expected when working with models that differ in accuracy and overall performance. Identifying these points of divergence is critical because it underscores the confidence in the model predictions of flood-prone areas. To determine areas of similarity and dissimilarity in the model results, spatial comparisons of the model results were performed by overlaying the 16 susceptibility maps developed for each of the four models of the four ML algorithms used.  Table 1. Drainage density, rainfall and distance to river were the predominant predisposing factors in the Ourika watershed. Drainage density was selected as input for all models while rainfall was selected for all models except XGB.TR.SE. Distance to rivers was selected for all models but ANN.SE and XGB.TR.SE.
3.1.2 Variables importance. Figure 2 shows the importance of variables for each model. Rainfall and slope were among the most important variables in all models, presenting scores above 90% and 65%, respectively, in all models. Drainage density was a significant predictor for the RF and KNN models with scores of 98.5% and 90.9%, respectively, while DEM was an

Model performance analysis
The evaluation of a model's performance is an integral step in modeling. In this study, the ROC-AUC curve was used to assess model accuracy. The resulting AUC scores for each model are shown in Table 2. A 10-factor cross-validation with three replications was used for training control. The hyperparameters of the different prediction models and the optimal parameters revealed during parameter tuning are included as part of the supplementary material. The most accurate models were under the RF (RF and RF.SE) and ANN (ANN and ANN.SE) algorithms, each recording AUC scores of 99.9%. Nevertheless, on average, RF and XGB were the best performing algorithms, with average AUC scores of 99.1% and 99.2% for their respective models. Conversely, KNN was on average the worst performing algorithm, with an AUC score of 94.4%. Indeed, the worst performing model across all algorithms was KNN, with KNN.TR recording an AUC score of 86.3%. Overall, the highest scores were observed for models that did not undergo one-hot encoding and for which variable selection was performed (ANN, RF, KNN and XGB), and for models associated with variable selection alone (ANN.SE, RF.SE, KNN.SE and XGB.SE). The models were sufficiently accurate, as evidenced by their AUC scores, which were above the prediction rate of 80% for the test data.
The overall classification accuracy of the models is included as supplementary material. Consistent with the AUC scores, XGB and RF exhibited the highest average accuracy values at 96.4% (Kappa 5 92.7%) and 91.8% (Kappa 5 83.6%), respectively. Conversely, ANN had the lowest average accuracy at 90.3% (Kappa 5 80.5%). Additionally, the sensitivity and specificity results of the models are included as supplementary material.

Floods susceptibility mapping
The resulting 16 flood susceptibility maps for the Ourika watershed for each model of the four ML algorithms employed are presented in Figure 3, while the susceptibility classes are shown in Table 3.
As expected, most high-risk areas for flooding are located near rivers. In addition, they are more concentrated near the watershed outlet in the NW section. These areas represent the low-lying areas of the watershed. The majority of the watershed area is classified in the very low susceptibility class (Table 3). Indeed, the very low class accounted for 95.87%, 81.73%, 61.99% and 96.72% of the watershed area for RF, ANN, KNN and XGB, respectively. KNN showed the most flood-prone areas, with most of the high (9.11%) to very high (13.77%) classes predicted by the model. Overall, the southern region of the watershed was predicted to be the least flood-prone, with the ANN, KNN and RF models showing virtually no areas susceptible to flooding (Figure 3). For the most part, the built-up areas belong to the very low sensitivity class (81.07%). However, a significant part of the built-up areas (14.91%) is located in areas of very high flood vulnerability. Figure 4 shows the areas of the Ourika watershed with similar observations for the very low and very high flood risk classes, as well as the areas where model predictions were inconsistent. Additional information corresponding to these areas across the watershed is included as supplementary material.

Models results comparison
For the lowest performing algorithm, KNN, the corresponding models (KNN, KNN.TR, KNN.SE and KNN.TR.SE) were consistent in predicting the same areas of the watershed as being classified as very low (55.16% of the total area) and very high (1.20% of the total area) risk of flooding. By contrast, varying predictions across the four models were observed over the remaining 43.64% of the watershed area. For RF, which was the best performing algorithm, the corresponding models (RF, RF.TR, RF.SE and RF.TR.SE) were consistent in predicting 95.79% and 0.24% of the watershed as belonging to the very low and very high susceptibility classes, respectively. Conversely, inconsistencies in prediction were observed for the remaining 3.97% of the watershed. Overall, the 16 models were consistent in predicting 53.79% and 0.11% of the watershed as belonging to the very low and very high flood risk classes, respectively, while inconsistencies were observed for the remaining 46.10%.   A total of 11 flood-conditioning factors, including curvature, elevation, distance to river, drainage density, slope, flow accumulation, precipitation, TWI, NDVI, SPI and WI, were selected as numerical variables, while five factors, including aspect, flow direction, geology, substrate resistance to erosion, and land use, were identified as categorical variables in mapping flood susceptibility based on the literature [30,[36][37][38][39][40][41][42][43][44][45].
The final susceptibility maps did not show considerable variation and were spatially consistent between models, with the exception of KNN, which predicted the greatest areas of the Ourika watershed as being susceptible to flooding. Indeed, RF, ANN and XGB predicted that the central and northwestern part of the watershed would be moderately to highly susceptible to flooding, while almost the entire southern half was predicted to be the least susceptible. Moderately to highly prone areas are dominated by substrates that have low resistance to erosion while being dominated by human activities such as agriculture and construction. These are likely to create conditions that favor hydrologic processes such as runoff, thereby increasing the likelihood of flood events. Overall, most of the study area was classified as being at very low risk of flooding. However, a significant portion was predicted by ANN and KNN to be very highly prone to flooding, with the distribution of built-up areas revealing that nearly 15% of these areas fall into this class. This highlights the potential impact of urbanization in influencing flooding in the watershed. Indeed, urbanization has been confirmed as a driving factor in its role in increasing in flood risk [46][47][48]. It leads to a significant increase in impervious surface, which generally reduces the hydrologic response time and thus increases the risk of flooding [49]. Moreover, studies conducted by Al-Ghamdi et al. [50] and Zhao et al. [51] have noted its role in significantly increasing peak flood events. The models used in this study presented satisfactory results and were considered appropriate for the establishment of flood susceptibility maps for the Ourika watershed. Indeed, the lowest AUC score was recorded for the KNN algorithm at 86.3%. XGB and RF were found to be the most reliable for predicting flooding, with AUC scores above 99%. The superior performance of RF in particular over other algorithms has been highlighted in other studies [52][53][54][55][56]. Indeed, it has been shown to be robust to noise and outliers, which are some of the common problems in flood susceptibility modeling. RF is not only capable of predicting the role of input factors in the modeling process, but also of handling huge data composed of varying inputs without factor suppression [54,55]. This was observed in the study on multi hazard mapping conducted Salzburg (Austria) by [57] where it performed in flood prediction compared to support vector machines. As for the equally strong performance by XGB, Rampali et al. [58] obtained comparable results, finding it to have the highest predictive power in their work on flood risk assessment in India. Correspondingly, Abedi et al. [56] in their study in Romania also noted its high performance, although, much like in our study, better than RF. These results are in line with our observations, showing that the selected algorithms can provide sufficiently accurate models for flood prediction in the region.
In order to remedy the devastating situation caused by floods, the improvement of flood forecasting and prevention remains an essential step. Better information of the exposed populations and the reduction of the vulnerability of the goods located in the floodable zones are to be privileged. Although the application of ML methods for flood susceptibility modeling often comes with inherent challenges such as the selection of appropriate model inputs, the algorithms used, their power, ease of application and relatively low cost compared to traditional methods can be leveraged effectively, making them a useful tool in flood risk management.

Conclusions
Floods are one of the most devastating and damaging events. In the Mediterranean region, the extent of past floods and the forecast of an increase in their frequency require that the risk of flooding be taken into consideration by local planners and decision makers. In this context, the determination of areas likely to be affected by floods and the subsequent elaboration of flood susceptibility maps is essential for a better management of this risk.
Our approach offers a tool for flood risk assessment at the watershed scale. It is based on the identification and analysis of factors influencing flooding followed by use of ML techniques to predict floods. Thus, models based on the four ML algorithms were used to develop flood susceptibility maps, with XGB and RF exhibiting the highest predictive power. Overall, the models were highly accurate, thus showing they can be applied with confidence in the region.
Although flood susceptibility modeling remains a challenging endeavor with many inherent complexities, our results can help regional planners and decision makers to implement mitigation and development strategies that would be useful for optimal flood management, not only in the region, but also in the Moroccan and ultimately Mediterranean contexts.