3.1. Statistical Summary of Physicochemical Parameters
Descriptive statistics for the measured water-quality parameters are presented in
Table 3. pH ranged from 6.43 to 9.22 (mean = 7.34 ± 0.38), indicating predominantly neutral to slightly alkaline conditions, whereas EC ranged from 400 to 5160 µS/cm (mean = 1570.10 ± 817.60 µS/cm), indicating substantial variability in groundwater mineralization. Both parameters showed positive skewness (1.363 and 1.492, respectively), reflecting a limited number of relatively high values.
The major cations also exhibited considerable variability. Ca2+ had a mean concentration of 142.43 ± 101.48 mg/L and pronounced positive skewness (2.499), while Mg2+ and Na+ averaged 28.33 ± 32.82 and 167.18 ± 51.74 mg/L, respectively. K+ showed the strongest skewness (4.488) and highest kurtosis (19.387), with a mean of 13.78 ± 28.83 mg/L, indicating a small number of exceptionally high concentrations. Among the major anions, Cl− and HCO3− had relatively high mean concentrations of 350.97 ± 134.94 and 310.06 ± 123.63 mg/L, respectively, while SO42− averaged 116.77 ± 111.19 mg/L. The positive skewness observed for HCO3− (2.053) and SO42− (2.997) further indicates considerable spatial heterogeneity.
Turbidity ranged from 0.13 to 39.30 NTU (mean = 4.72 ± 5.80 NTU) and showed strong positive skewness (3.25) and kurtosis (14.10), indicating mostly low values with a limited number of highly turbid samples. Total hardness ranged from 92.24 to 1755.28 mg/L as CaCO3 (mean = 472.33 ± 295.21 mg/L), while temperature and dissolved oxygen averaged 15.56 ± 1.95 °C and 4.92 ± 2.69 mg/L, respectively.
Overall, the relatively high EC, together with the elevated Cl
− and HCO
3− concentrations, is consistent with substantial water–rock interaction and evaporative concentration under semi-arid conditions, particularly in aquifer systems influenced by carbonate and evaporite mineral dissolution [
2,
3]. Similar hydrochemical characteristics have been reported for semi-arid Algerian groundwater systems, including the Bouhamdane Basin [
49] and the M’sila region [
16]. The pronounced positive skewness observed for several parameters indicates a limited number of high-concentration observations and highlights the spatial heterogeneity of groundwater chemistry. These observations were retained because elevated concentrations may represent genuine hydrochemical variability relevant to irrigation-water quality and subsequent IWQI reconstruction. Therefore, observations were not excluded solely on the basis of their distributional characteristics; instead, their influence was considered within the subsequent modelling framework through the predefined validation and feature-selection procedures.
3.3. Pearson Correlation and Multicollinearity Analysis
Pearson correlation analysis was performed to assess linear associations between the 14 candidate physicochemical predictors and IWQI across the 100 groundwater observations (
Figure 6). Because IWQI is a deterministic composite index derived from several hydrochemical parameters, these correlations were interpreted as statistical associations rather than independent evidence of predictive importance or hydrogeochemical causality. EC, Na
+, Cl
−, HCO
3−, and SAR are directly incorporated into the IWQI formulation (
Table 2), whereas TH is not [
5].
The strongest negative correlations with IWQI were observed for HCO3− (r = −0.691), TH (r = −0.680), EC (r = −0.647), Ca2+ (r = −0.625), and Cl− (r = −0.589). SO42− (r = −0.526), Na+ (r = −0.351), and Mg2+ (r = −0.312) also showed negative associations. In contrast, pH and temperature exhibited weak positive correlations (r = +0.22 for both), while SAR showed a weak positive and non-significant correlation (r = +0.157, p = 0.120). O2, turbidity, and K+ showed negligible linear associations with IWQI (r = −0.01, +0.09, and −0.04, respectively). The weak Pearson correlation of SAR does not necessarily indicate low predictive relevance, as its contribution to IWQI is governed by the predefined quality-rating and weighting functions and may involve nonlinear or threshold-dependent behaviour.
Strong inter-predictor correlations were observed among salinity- and mineralization-related variables. EC correlated strongly with Cl− (r = 0.82), SO42− (r = 0.75), TH (r = 0.75), and Na+ (r = 0.72), reflecting their co-occurrence in the mineralized groundwater system. VIF analysis identified perfect multicollinearity among Ca2+, Mg2+, and TH (VIF = ∞), consistent with the mathematical derivation of TH from Ca2+ and Mg2+ concentrations (Equation (2)). Consequently, Ca2+ and Mg2+ were excluded from the subsequent RFECV candidate pool, while TH was retained as the composite hardness indicator. Overall, these results highlight substantial predictor interdependence and support the use of nonlinear machine-learning models to capture relationships and interactions not adequately represented by pairwise linear correlations.
VIF analysis within the training partitions revealed perfect collinearity among Ca2+, Mg2+, and TH (VIF = ∞), consistent with the mathematical derivation of TH from Ca2+ and Mg2+ concentrations (Equation (2)). Consequently, Ca2+ and Mg2+ were excluded from the subsequent RFECV candidate pool, while TH was retained as the composite hardness indicator. No other predictor exhibited perfect multicollinearity.
3.4. Feature Selection via Nested RFECV
Nested Recursive Feature Elimination with Cross-Validation (RFECV) was performed independently within the four LOCO training partitions to identify a parsimonious predictor set for IWQI reconstruction. Although the selected subsets varied slightly among folds, EC, Na+, Cl−, HCO3−, and SAR were consistently retained across all four LOCO folds, forming a stable five-predictor core.
Following multicollinearity screening, Ca2+ and Mg2+ were excluded from the RFECV candidate pool, while TH was retained as the composite hardness indicator. Although TH showed a strong correlation with IWQI (r = −0.680), it was not consistently selected across the four LOCO folds, which may reflect redundancy with other mineralization-related predictors and its derivation from Ca2+ and Mg2+ concentrations.
The consistent selection of EC, Na
+, Cl
−, HCO
3−, and SAR is partly expected because these variables are direct components of the computed IWQI. Their repeated selection therefore indicates stable predictive relevance for reconstructing the deterministic index rather than independent evidence of causal hydrochemical control. This predictor core is broadly consistent with previous ML-based IWQI studies in semi-arid environments. Azlaoui et al. [
11] identified EC, Na
+, and SAR among the most important predictors in an XGBoost-SHAP framework, while Hussein et al. [
14] reported Na
+ and EC as dominant predictors across multiple ML algorithms.
The final five-predictor configuration provides a parsimonious representation of the original 14-variable candidate pool while retaining routinely measured or readily derived parameters, supporting its practical use in groundwater monitoring and IWQI reconstruction. This reduction in dimensionality is also consistent with the principle of parsimonious model design in environmental modelling [
40]. Accordingly, EC, Na
+, Cl
−, HCO
3−, and SAR were retained for subsequent model comparison and SHAP-based interpretation.
3.5. Machine-Learning Performance Under LOCO Validation
All machine-learning performance values reported in this section correspond to out-of-sample results obtained from the held-out test campaign of each LOCO fold (n = 25), rather than to training-set performance or to a random 80/20 split. Within each outer LOCO fold, preprocessing, VIF-based multicollinearity screening, RFECV feature selection, scaling, hyperparameter optimisation, and model fitting were carried out entirely within the corresponding training partition (n = 75); the held-out campaign was excluded from every stage of model development. LOCO was therefore adopted as the primary evaluation framework, assessing model generalisation to an unseen sampling campaign within the observed study period, rather than universal generalisation, transferability to other aquifers, or operational readiness.
Fold-level LOCO R
2 values for all six models are presented in
Table 4. XGBoost obtained the highest R
2 in three of the four held-out campaigns, ranging from 0.624 (December 2023) to 0.879 (May 2024); the exception occurred in December 2023, when SVR (R
2 = 0.769) numerically exceeded XGBoost. Gradient Boosting followed a pattern broadly similar to XGBoost, whereas KNN, Random Forest, and SVR displayed comparatively larger fold-to-fold fluctuations. MLR showed the widest range of all models, from R
2 = 0.112 (February 2023) to R
2 = 0.755 (December 2023), reflecting pronounced instability of the linear reconstruction across campaigns.
Averaged across the four held-out campaigns, XGBoost showed the highest mean LOCO performance (R
2 = 0.732 ± 0.109; RMSE = 5.075 ± 1.403; MAE = 3.822 ± 0.998;
Table 5). Gradient Boosting and KNN achieved similar mean R
2 values (0.689 ± 0.142 and 0.690 ± 0.079, respectively), closely followed by Random Forest (0.681 ± 0.103), whereas SVR (0.614 ± 0.175) and MLR (0.563 ± 0.304) obtained the lowest mean R
2 values. Because only four outer folds were available, these values should be regarded as descriptive statistics summarising variability across the observed campaigns rather than as estimates of population-level uncertainty, and no significance testing was performed. Accordingly, XGBoost is described as the numerically strongest-performing model, showing the highest mean LOCO performance among the evaluated algorithms, rather than as statistically superior to its competitors.
Campaign-level variability was not restricted to XGBoost. SVR ranged from R2 = 0.364 (February 2023) to 0.769 (December 2023), corresponding to a spread of 0.405 R2 units, whereas MLR displayed the largest fold-level range among the evaluated models (0.643 R2 units). These fluctuations indicate that model performance and relative ranking were not fully consistent across campaigns. Such variation may plausibly reflect differences in the hydrochemical composition of the held-out campaign relative to the corresponding training data; however, this interpretation remains a plausible explanation rather than an established causal effect.
Because IWQI is a deterministic composite index computed from a fixed set of hydrochemical parameters, the task addressed in this section represents surrogate reconstruction of a mathematically derived index rather than prediction of an independent environmental outcome. The IWQI scoring procedure applies piecewise quality-rating functions (qi) across predefined parameter-quality ranges (Equation (4)), resulting in nonlinear and threshold-like relationships between the hydrochemical inputs and the resulting index. The relatively narrow performance range among the four nonlinear models (mean R2 = 0.681–0.732), compared with the substantially lower mean R2 obtained by MLR (0.563), is consistent with the piecewise structure of the IWQI formulation. A single linear combination of the five input variables may therefore not fully represent the threshold-dependent relationships embedded in the index. This finding does not imply that MLR is inherently unsuitable; rather, MLR provides a meaningful linear baseline using the same five predictors, whereas the underlying mathematical structure of IWQI is not necessarily well represented by a simple linear function.
The comparable performance of KNN (mean R
2 = 0.690) and Random Forest (0.681) relative to XGBoost (0.732) indicates that instance-based and bagging ensemble methods were also able to capture nonlinear structure in the predictor space, although with somewhat lower mean performance and/or cross-fold consistency. KNN’s sensitivity to local sample density [
17] may partly explain its fold-level variability when campaign-specific hydrochemical shifts altered the distribution of nearest neighbours in the held-out set. Random Forest, which relies on bootstrap aggregation and randomized feature selection, also captured nonlinear relationships but showed a lower performance ceiling than the boosting-based models [
9]. SVR showed lower and more variable performance (mean R
2 = 0.614; range = 0.364–0.769), which may reflect the sensitivity of RBF-kernel SVR to kernel and regularization settings when modelling nonlinear, piecewise-structured targets, particularly under the relatively small outer training partition (n = 75).
The relative performance ordering observed in the present LOCO evaluation, XGBoost ≈ Gradient Boosting > KNN ≈ Random Forest > SVR > MLR, is broadly comparable with rankings reported in previous ML-based IWQI studies, although the magnitude of performance differences varies across datasets and validation designs [
14,
16]. Several previous studies reported substantially higher R
2 values (e.g., 0.85–0.97) using random train–test partitioning rather than grouped or campaign-level validation [
11,
14]. Because repeated observations from the same wells may be distributed across random training and test subsets, such partitioning can yield optimistic estimates of generalisation when observations within wells are not independent. Direct numerical comparison between the present LOCO-based results and these studies should therefore be interpreted with caution, given differences in validation strategy, dataset size, sampling design, predictor set, and IWQI formulation.
Within this context, the XGBoost model achieved a mean LOCO R2 of 0.732, compared with 0.563 for MLR, indicating an observed advantage of the nonlinear tree-based model for reconstructing the piecewise IWQI target from the available hydrochemical predictors under the present campaign-level validation framework. This advantage should be interpreted in relation to the specific dataset, predictor set, IWQI formulation, and validation strategy used in this study, rather than as evidence of universal superiority or broad generalisability.
Figure 7 illustrates the agreement between computed and reconstructed IWQI values for the six evaluated models under the LOCO validation framework.
Taken together, the fold-level and aggregate LOCO results support the selection of XGBoost as the final model for the SHAP-based interpretability analysis presented in the following section. XGBoost was selected as the final model because it achieved the highest numerical performance under the strict LOCO framework, but this result should be interpreted as evidence of comparatively better IWQI reconstruction within the present Sedrata dataset and validation design, not as proof of universal superiority or external generalisation.
Figure 8 further illustrates the distributional reproduction of IWQI values across the five nonlinear machine-learning models.
3.5.1. Statistical Comparisons
Paired t-tests based on the four fold-level LOCO R2 values were used as an exploratory comparison between XGBoost and the other evaluated models. Because only four paired folds were available and multiple pairwise comparisons were performed, these tests are exploratory rather than confirmatory, and the reported p-values are unadjusted for multiplicity. XGBoost showed a numerical advantage over Gradient Boosting (mean ΔR2 = +0.043), but this difference was not statistically significant (t = 1.833, p = 0.164). Differences between XGBoost and SVR (mean ΔR2 = +0.118, t = 1.147, p = 0.335), KNN (mean ΔR2 = +0.042, t = 1.092, p = 0.355), and MLR (mean ΔR2 = +0.169, t = 1.151, p = 0.333) were likewise not statistically significant. Only the comparison between XGBoost and Random Forest reached significance in the unadjusted paired t-test (mean ΔR2 = +0.051, t = 5.796, p = 0.010); given the small number of outer folds (df = 3) and the absence of correction for multiple comparisons, this result should be interpreted cautiously and not as evidence of general statistical superiority.
Accordingly, XGBoost is described as achieving the highest mean LOCO performance among the evaluated models; its numerical advantage was statistically significant only relative to Random Forest in the unadjusted paired comparison, and not relative to Gradient Boosting, KNN, SVR, or MLR. These results should not be interpreted as evidence that XGBoost is statistically superior to all competing models. Because only four outer LOCO folds were available (n = 4; df = 3), statistical power was limited, and the exploratory nature of these comparisons should be kept in mind throughout the remainder of this study.
Notably, MLR outperformed XGBoost in the December 2023 held-out campaign (R2 = 0.755 vs. 0.624), illustrating pronounced campaign-to-campaign variability in relative model performance. This observation indicates that the numerical advantage of XGBoost at the mean level does not guarantee superior performance in every individual campaign. The stronger performance of MLR in December 2023 may indicate that the linear structure was better aligned with the hydrochemical configuration of that specific campaign than the nonlinear models evaluated, although this interpretation remains observational rather than causally established. This pattern is consistent with the broader finding that campaign-specific conditions, rather than algorithmic complexity alone, can be an important factor shaping reconstruction accuracy in a given LOCO fold; it argues against selecting a single model based solely on mean performance and suggests that campaign-adaptive or ensemble strategies may warrant future investigation.
The paired
t-test results comparing XGBoost with the other evaluated models are presented in
Table 6.
3.5.2. Leave-One-Well-Out (LOWO) Validation Results
Leave-One-Well-Out (LOWO) cross-validation was performed as a secondary grouped validation analysis to complement the primary campaign-level LOCO results. Whereas LOCO evaluates model generalisation across held-out sampling campaigns, LOWO evaluates generalisation to monitoring wells that were entirely excluded from model development: in each of the 25 folds, all four observations from one monitoring well were held out, while observations from the remaining 24 wells were used for training. This design ensures that measurements from the same well are never simultaneously present in the training and test partitions. Because each held-out set contained only four observations, RMSE and MAE were treated as the primary fold-level error metrics, while fold-level R2 was interpreted with caution.
For XGBoost, the mean LOWO RMSE across the 25 held-out wells was 4.475 ± 2.943 IWQI units (median = 3.891; range: 0.298–9.847), with a mean LOWO MAE of 3.485 ± 2.387 IWQI units and an aggregate R2 of 0.914 calculated from all 100 held-out LOWO predictions. The other models produced mean LOWO RMSE values of 2.527 (Gradient Boosting), 2.712 (SVR), 2.780 (Random Forest), 2.807 (MLR), and 2.886 (KNN) IWQI units, with corresponding aggregate LOWO R2 values of 0.912, 0.825, 0.878, 0.900, and 0.868, respectively. Notably, Gradient Boosting 2.4.1 achieved a substantially lower mean LOWO RMSE (2.527 IWQI units) than XGBoost (4.475 ± 2.943 IWQI units), indicating that the best-performing algorithm depends on the validation strategy used. XGBoost is therefore identified as the best-performing model under the primary LOCO validation framework specifically, rather than as the universally optimal algorithm across all validation contexts.
Taken together, the LOCO and LOWO results provide complementary, though not equivalent, evidence regarding the internal transferability of the trained XGBoost surrogate within the Sedrata Plain dataset. LOCO evaluates campaign-level generalisation within the observed study period, the ability to reconstruct IWQI values for hydrochemical conditions associated with a held-out sampling campaign, whereas LOWO evaluates within-aquifer spatial generalisation to monitoring well locations not represented during model development. XGBoost’s mean RMSE under LOCO (5.075 ± 1.403 IWQI units) and under LOWO (4.475 ± 2.943 IWQI units) are numerically similar in central tendency; however, the substantially larger variability observed under LOWO (SD = 2.943 vs. 1.403) indicates that spatial generalisation to individual wells is considerably less consistent than campaign-level generalisation, and the two validation schemes should not be regarded as formally equivalent. This pattern of internal transferability is a necessary but not sufficient condition for broader applicability: it indicates that the model is not simply memorising training-set patterns, but it does not establish transferability to aquifer systems with different hydrochemical regimes, geological settings, or IWQI distributions. External transferability to geographically distinct datasets remains untested and is discussed further as a limitation in
Section 3.8 and
Section 3.9.
3.5.3. Secondary Reference: Random 80/20 Split
For comparison with previous studies that used conventional random data partitioning, a random 80/20 train–test split (random_state = 42) was performed as a secondary, descriptive reference analysis. Under this split, XGBoost yielded R2 = 0.698, RMSE = 4.791, and MAE = 3.474, while MLR produced R2 = 0.256, RMSE = 7.522, and MAE = 5.181. These results are reported solely as secondary reference values and should not be regarded as evidence of robust model generalisation. Because the dataset comprises repeated observations from the same 25 monitoring wells across four campaigns, observations from a given well can occur in both the training and test subsets under random splitting; this can produce optimistic performance estimates relative to the grouped LOCO framework, which explicitly prevents observations from the held-out campaign from contributing to model development or evaluation.
The random_state = 42 used for this random partition was independent of the fixed seed = 0 used for stochastic model procedures within the primary LOCO and secondary LOWO analyses: random_state = 42 controlled the train–test split, whereas seed = 0 ensured the reproducibility of stochastic algorithm behaviour. The two values therefore serve distinct methodological purposes and were not intended to be identical.
3.5.4. Comparison with Previous IWQI/WQI Machine-Learning Studies
To place the present LOCO-based results within the broader ML-based water-quality-index literature,
Table 7 consolidates the performance metrics reported in
Section 3.5.3 alongside comparable studies previously cited in this manuscript. This comparison is intended to make the methodological contrast between grouped, campaign-level validation and conventional random partitioning explicit and quantifiable, rather than only asserted narratively.
The XGBoost surrogate developed in the present study achieved a mean LOCO R
2 of 0.732 ± 0.109, which is numerically lower than the R
2 values reported by Azlaoui et al. [
11] (0.95) and Hussein et al. [
14] (≈0.97), as well as those reported in other semi-arid Algerian and Tunisian studies (≈0.85–0.97). This difference may be partly attributable to differences in validation design, as the cited studies predominantly relied on conventional or random train–test partitioning, under which repeated observations from the same monitoring wells may be allocated to both the training and test subsets. Such partitioning can yield optimistic estimates of model generalisation when observations from the same wells are not independent. In contrast, the present study used Leave-One-Campaign-Out (LOCO) validation as the primary evaluation strategy, ensuring that all observations from the held-out campaign were excluded from model training. The secondary random 80/20 split performed in the present study (
Section 3.5.3) yielded an XGBoost R
2 of 0.698, which was lower than the mean LOCO R
2 of 0.732, although the two values are not directly equivalent because they arise from different evaluation designs. The remaining differences relative to the literature values reported in
Table 8 may also reflect variation in dataset size, predictor set, sampling density, and IWQI formulation across studies.
The consistency of EC and Na
+, together with related salinity indicators such as SAR and Cl
−, as important predictors across Azlaoui et al. [
11], Hussein et al. [
14], and the present study (
Section 3.4) supports the relevance of the retained five-predictor set despite differences in absolute reconstruction accuracy across validation frameworks. Overall,
Table 8 indicates that the present results are broadly consistent with, although numerically more conservative than, previously reported ML-based IWQI/WQI studies. The lower performance values should therefore be interpreted in the context of the stricter campaign-level validation strategy, as well as differences in datasets, predictor sets, sampling designs, and IWQI formulations, rather than being interpreted as evidence of generally inferior model capability.
3.6. Baseline Performance Comparison
A baseline performance comparison was performed to place the machine-learning results within the context of the deterministic IWQI formulation. Direct IWQI calculation provides a deterministic reference, yielding R2 = 1.000, RMSE = 0, and MAE = 0 when the prescribed qiq_i values and weighting coefficients are applied according to Equations (4) and (5), because IWQI is defined as a fixed mathematical function of its five input components rather than as an independently measured environmental outcome. In comparison, XGBoost achieved a mean LOCO R2 of 0.732 ± 0.109 (RMSE = 5.075 ± 1.403; MAE = 3.822 ± 0.998 IWQI units), whereas MLR using the same five IWQI-related predictors showed lower LOCO performance (R2 = 0.563 ± 0.304; RMSE = 6.188 ± 1.276; MAE = 4.568 ± 0.988 IWQI units).
Framed against this deterministic reference, the lower performance of the machine-learning models should be interpreted as reflecting the challenge of reconstructing a deterministic, piecewise composite index from raw hydrochemical concentrations rather than as evidence of poor predictive performance for an independent environmental outcome. The difference between the deterministic IWQI reference (R
2 = 1.00) and the best-performing ML surrogate (XGBoost mean LOCO R
2 = 0.732) may have several non-exclusive explanations. First, the IWQI formulation combines multiple parameter-specific quality-rating functions and weighting terms, including piecewise relationships across predefined quality bands (
Table 1), resulting in a nonlinear mapping that must be approximated from a finite set of observations. Second, the LOCO framework deliberately withholds an entire sampling campaign from model training, so the surrogate must generalize to hydrochemical conditions that may differ from those represented in the training campaigns. The deterministic IWQI equation, in contrast, can be applied directly to the held-out observations without requiring statistical generalization.
The mean LOCO RMSE of 5.075 IWQI units corresponds to approximately 5.1% of the full 0–100 IWQI scale. Because IWQI restriction classes span intervals of different widths, whether a reconstruction error changes the assigned water-quality class depends on the proximity of the true IWQI value to a class boundary rather than on RMSE alone. No class-reassignment analysis was performed in the present study; therefore, the implications of the observed reconstruction error for categorical irrigation-water classification should be considered a potential direction for future work rather than an established finding.
Overall, the XGBoost surrogate achieved substantially better LOCO performance than the linear baseline while remaining below the deterministic reference, as expected for an approximate statistical reconstruction of a mathematically defined index. The model may therefore have potential for rapid screening of IWQI from EC, Na+, Cl−, HCO3−, and SAR measurements. However, this potential remains provisional and requires independent external validation across additional sampling campaigns, wells, and hydrogeological settings before transferability beyond the present dataset can be established.
3.7. Model Interpretability via SHAP Analysis
To interpret the final XGBoost model and quantify the relative contribution of the selected predictors to IWQI reconstruction, SHAP (SHapley Additive exPlanations) values were computed for the model refitted on all 100 observations using the five retained predictors: EC, Na
+, Cl
−, HCO
3−, and SAR. Because refitting used the complete dataset, including the campaigns held out during LOCO evaluation, the SHAP analysis characterises the behaviour of the final fitted model rather than providing an out-of-sample explainability assessment; this distinction is acknowledged as a methodological limitation in
Section 3.8. Throughout this section, SHAP values are interpreted strictly as measures of model attribution and reliance, i.e., how strongly the fitted XGBoost model depends on each predictor when reconstructing IWQI, and not as evidence of independent causal hydrogeochemical relationships.
Figure 9 presents the SHAP beeswarm plot for the five predictors, ranked by mean absolute SHAP value; each point represents one observation, its horizontal position indicating the magnitude and direction of that predictor’s contribution to the predicted IWQI, and its colour indicating the corresponding feature value (blue = low, red = high) [
48]. Positive SHAP values push the prediction toward higher IWQI, negative values toward lower IWQI, and predictors positioned farther from zero exert greater influence on the model output.
Global feature importance (
Figure 10), based on mean absolute SHAP values, summarises the predictors’ average contribution to the predicted IWQI irrespective of direction, yielding the hierarchy Cl
− (5.760) > EC (3.435) > SAR (2.206) > HCO
3− (1.917) > Na
+ (0.337). This ranking is complementary to the feature-selection results reported in
Section 3.4: RFECV identifies which predictors are retained for modelling, whereas SHAP quantifies how strongly the final fitted XGBoost model relies on each retained predictor when generating its predictions.
The SHAP decision plot (
Figure 11) provides an observation-level view of how the five predictors jointly contribute to individual IWQI predictions, with each line tracing the cumulative contribution from the model’s expected value to the final prediction for one observation. Because positive and negative contributions from different predictors can partially offset one another, observations with similar final predicted IWQI values may follow different attribution pathways, reflecting the nonlinear, interaction-based structure of the XGBoost model and underscoring that individual predictions arise from the combined contribution of Cl
−, HCO
3−, EC, SAR, and Na
+ rather than from any single predictor acting independently.
Because several selected predictors are direct or indirect components of the IWQI formulation, high SHAP importance indicates that the XGBoost model relies strongly on a predictor when reconstructing IWQI values in the present dataset; it does not establish that predictor as an independent hydrogeochemical driver of irrigation-water quality. SHAP values quantify feature contributions to individual model predictions and can be aggregated to characterize global feature importance. The prominence of Cl− and EC is consistent with the importance of salinity-related variables in irrigation-water assessment, but this pattern should be interpreted as model attribution rather than evidence of a causal mechanism or of any single constituent independently controlling water quality.
The SHAP-derived hierarchy (Cl
− > EC > SAR > HCO
3− > Na
+) is broadly consistent with feature-importance patterns reported in comparable ML-based IWQI studies, although the specific ordering remains dataset- and model-dependent. Azlaoui et al. [
11] identified EC and Na
+ among the dominant contributors to XGBoost-based predictions in a semi-arid Algerian aquifer, while Li et al. [
52] reported a predominance of salinity-related variables in SHAP-based interpretation of XGBoost water-quality models. These comparisons support the relevance of salinity-related predictors while also indicating that their relative importance may vary among datasets and model configurations.
Cl− showed the highest mean absolute SHAP value in the present study (mean |SHAP| = 5.760). Its relatively high concentration (mean = 350.97 mg/L; range = 142–710 mg/L) provides substantial variation in the predictor space; however, concentration range alone does not determine SHAP importance, which also depends on the fitted model structure and interactions among predictors. Conversely, Na+ showed a comparatively low mean absolute SHAP contribution (mean |SHAP| = 0.337), despite being a direct component of the IWQI formulation. This may partly reflect its correlation with EC and Cl− (r = 0.72 and 0.76, respectively), indicating that information associated with Na+ may overlap with that represented by other predictors available to the model. This interpretation should be regarded as a possible explanation rather than evidence of an independent effect.
Similarly, the positive SHAP association observed for SAR despite its weak and non-significant Pearson correlation with IWQI (r = +0.157, p = 0.120) illustrates that SHAP attributions should not be interpreted as direct extensions of pairwise correlations. SAR enters the IWQI formulation through a parameter-specific quality-rating function, and its model contribution may therefore vary across observations and predictor combinations. The nonlinear tree-based structure of XGBoost can represent such relationships, whereas Pearson correlation summarizes only linear pairwise association. XGBoost is specifically designed as a tree-boosting framework capable of modelling nonlinear relationships through sequentially fitted decision trees.
Together, these findings demonstrate the complementary roles of RFECV-based feature selection and SHAP-based explainability in the present deterministic composite-index reconstruction task. RFECV identifies a parsimonious predictor set within the specified training procedure, whereas SHAP characterizes how the fitted XGBoost model distributes attribution among the retained predictors. These provide distinct but complementary forms of model interpretation and should not be regarded as evidence of independent hydrogeochemical causality.
Overall, the SHAP analysis provides an attribution-based description of the final five-predictor XGBoost model at both the global and observation levels. Because the same predictor configuration (EC, Na+, Cl−, HCO3−, and SAR) underlies the feature-selection, modelling, and SHAP stages, the resulting interpretation is internally consistent. Nevertheless, the SHAP results remain specific to the fitted model, dataset, predictor set, and validation framework and should not be interpreted as evidence of universal predictor importance across aquifers or datasets.
3.8. Limitations
Several limitations should be considered when interpreting the present results. The dataset comprised 100 groundwater observations from 25 open wells monitored during four campaigns over a 15-month period (February 2023–May 2024). Although this design captures seasonal variability within the Sedrata Plain, it does not represent longer-term inter-annual hydrochemical changes associated with climate variability, prolonged drought, aquifer depletion, or changes in agricultural practices. The sampled wells were also limited to shallow open wells (approximately 3–25 m), and therefore deeper confined or semi-confined aquifer horizons were not represented. Accordingly, the trained XGBoost surrogate should not be assumed to maintain its reconstruction accuracy under hydrochemical conditions substantially outside the range represented in the study dataset.
The validation results also have important scope limitations. The primary LOCO evaluation yielded R2 = 0.732 ± 0.109, RMSE = 5.075 ± 1.403, and MAE = 3.822 ± 0.998 IWQI units, whereas the secondary LOWO analysis yielded a mean RMSE of 4.475 ± 2.943 IWQI units. LOWO provides complementary evidence of within-aquifer generalisation, but each held-out well contained only four observations, making fold-level estimates sensitive to well-specific hydrochemical conditions. These results therefore support internal generalisation within the sampled Sedrata Plain rather than external generalisation to other aquifer systems. Transfer to aquifers with different lithological and hydrochemical characteristics, or to alternative IWQI formulations with different parameter bands and weighting schemes, would require local retraining and independent validation. External validation and formal applicability-domain assessment were not performed.
Finally, the target IWQI is a deterministic composite index derived partly from the same physicochemical variables used as predictors (EC, Na+, Cl−, HCO3−, and SAR); therefore, the ML task represents surrogate reconstruction of IWQI rather than prediction of an independent environmental outcome. Similarly, SHAP values describe model attribution and should not be interpreted as causal hydrogeochemical evidence. The RFECV procedure and predefined hyperparameter search cannot guarantee identification of the globally optimal predictor subset or model configuration. In addition, formal uncertainty quantification and prediction intervals were not estimated for individual reconstructions. Future studies should therefore evaluate the framework using larger multi-year datasets, independent external sites, broader applicability-domain analysis, and formal uncertainty-quantification approaches before considering wider transfer or operational use.
3.9. Future Research Directions and Recommendations
Future research should first evaluate the five-predictor XGBoost framework using larger, multi-year, and geographically independent datasets. Independent external validation across hydrogeologically comparable semi-arid aquifers in Algeria and the broader Maghreb region would provide a stronger assessment of model transferability and help determine whether the observed predictor-importance pattern is specific to the Sedrata Plain or is reproducible across comparable aquifer systems. Such evaluations should be accompanied by applicability-domain assessment to identify observations falling outside the chemical space represented in the Sedrata training data. Where substantial distributional shifts are identified, local retraining or domain-adaptation approaches may be preferable to direct model transfer.
Methodological development should also focus on formal uncertainty quantification, including conformal prediction or prediction-interval approaches, so that individual IWQI reconstructions can be accompanied by estimates of predictive reliability. Future studies should further assess the stability of the five-predictor configuration using alternative feature-selection criteria, such as permutation importance, SHAP-based selection, or mutual information. Given the four-campaign structure of the present dataset, additional sampling campaigns would also be required to investigate seasonally aware or time-series modelling approaches and to determine whether temporal information improves campaign-level generalisation. Incorporating relevant spatial covariates, such as water-table depth, soil characteristics, and proximity to agricultural areas, could additionally help represent spatial heterogeneity that is not fully captured by the five hydrochemical predictors.
Following successful external validation and uncertainty assessment, the framework could be further investigated for practical applications in groundwater monitoring and irrigation-water management. Potential applications include prioritising wells for detailed laboratory analysis, supporting spatial IWQI mapping, and integrating the surrogate with routine field or sensor-based measurements for preliminary screening. However, such applications should remain conditional on demonstrated external validity, applicability-domain reliability, and adequate uncertainty characterisation. Future work could also make the modelling pipeline publicly available to facilitate independent evaluation and adaptation in other data-scarce semi-arid aquifer systems.