Machine learning models to predict nitrate concentration in a river basin


 Aquifer-stream interactions affect the water quality in Mediterranean areas; therefore, the coupling of surface water and groundwater models is generally used to solve water-planning and pollution problems in river basins. However, their use is limited because model inputs and outputs are not spatially and temporally linked, and the data update and fitting are laborious tasks. Machine learning models have shown great potential in water quality simulation, as they can identify the statistical relationship between input and output data without the explicit requirement of knowing the physical processes. This allows the ecological, hydrological, and environmental variables that influence water quality to be analyzed with a holistic approach. In this research, feature selection (FS) methods and algorithms of artificial intelligence— random forest (RF) and eXtreme Gradient Boosting (XGBoost) trees—are used to simulate nitrate concentration and determine the main drivers related to nitrate pollution in Mediterranean streams. The developed models included 19 inputs and sampling of nitrate concentration in 159 surface water quality-gauging stations as explanatory variables. The models were trained on 70 percent data, with 30 percent used to validate the predictions. Results showed that the combination of FS method with local knowledge about the dataset is the best option to improve the model’s performance, while RF and XGBoost simulate the nitrate concentration with high performance (r=0.93 and r=0.92, respectively). The final ranking, based on the relative importance of the variables in the RF and XGBoost models, showed that, regarding nitrogen and phosphorus concentration, the location explained 87 percent of the nitrate variability. RF and XGBoost predicted nitrate concentration in surface water with high accuracy without using conditions or parameters of entry, and enabled the observation of different relationships between drivers. Thus, it is possible to identify and delimit zones with a spatial risk of pollution and approaches to implementing solutions.