Water quality deterioration poses a critical threat to ecological security and sustainable development, particularly in rapidly urbanizing regions. To enable proactive environmental management, this study develops a novel hybrid deep learning model, the NGO-CNN-GRU, for high-precision time-series water quality prediction in the Xijiang River Basin, China. The model integrates a Convolutional Neural Network (CNN) for spatial feature extraction and a Gated Recurrent Unit (GRU) for temporal dependency modeling, with hyperparameters optimized via the Northern Goshawk Optimization (NGO) algorithm. Using historical water quality (pH, DO, CODMn, NH3-N, TP, TN) and meteorological data (precipitation, temperature, humidity) from 11 monitoring stations, the model achieved exceptional performance: test set R2 > 0.986, MAE < 0.015, and RMSE < 0.018 for total nitrogen prediction (Xiaodong Station case study). Across all stations and indicators, it consistently outperformed baseline models (GRU, CNN-GRU), with average R2 improvements of 12.3% and RMSE reductions up to 90% for NH3-N predictions. Spatiotemporal analysis further revealed significant pollution gradients correlated with anthropogenic activities in the Pearl River Delta. This work provides a robust tool for real-time water quality early warning systems and supports evidence-based river basin management.
Excessive total nitrogen (TN) in water bodies leads to eutrophication, algal blooms, and hypoxia, which pose significant risks to aquatic ecosystems and human health. Accurate real-time TN prediction is crucial for effective water quality management. This study presents an innovative approach that combines the distance correlation coefficient (DCC) for feature selection with a coupled Attention-Convolutional Neural Network-Bidirectional Long Short-Term Memory (At-CBiLSTM) model to predict TN concentrations in the Dongjiang River in China. A dataset of 28,922 time-series data points was collected from seven sampling sites along the Dongjiang River, spanning from November 2020 to February 2023. The DCC method identified conductivity, Permanganate Index (CODMn), and total phosphorus as the most significant predictors for TN levels. The At-CBiLSTM model, optimized with a time step of three, outperformed other models, including standalone Long Short-Term Memory (LSTM), Bi-directional LSTM (Bi-LSTM), Convolutional Neural Network LSTM (CNN-LSTM), and Attention-LSTM variants, achieving excellent performance with the following metrics: mean absolute error (MAE) = 0.032, mean squared error (MSE) = 0.005, mean absolute percentage error (MAPE) = 0.218, and root mean squared error (RMSE) = 0.045. Importantly, increasing the number of input features beyond three variables led to a decline in model accuracy, underscoring the importance of DCC-driven feature selection. The results highlight that combining DCC with deep learning models, particularly At-CBiLSTM, effectively captures nonlinear temporal dependencies and improves prediction accuracy. This approach provides a solid foundation for real-time water quality monitoring and can inform targeted pollution control strategies in river ecosystems.