$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Water quality monitoring is essential for protecting public health, sustaining aquatic ecosystems, and ensuring compliance with environmental regulations. Traditional water quality models, such as the Soil and Water Assessment Tool (SWAT), the mechanistic QUAL model, and statistical forecasting approaches, often struggle to capture the highly nonlinear, multivariate, and temporally irregular nature of water systems influenced simultaneously by chemical, biological, hydrological, and meteorological factors1,2,3,4,5,6. Therefore, improving anomaly detection in water-quality data remains a pressing challenge.
In practical terms, the proposed framework is designed for multi-parameter water quality sensing networks that measure variables such as potential of hydrogen (pH), dissolved oxygen (DO), total nitrogen (TN), total phosphorus (TP), and permanganate index (CODMn), turbidity, and conductivity, with typical sampling intervals ranging from 15 to 60 min. This model tolerates irregular sampling and missing observations, making it suitable for real-world deployment in surface water and reservoir monitoring systems.
Application of machine learning in water quality anomaly detection
In recent years, machine learning (ML) and deep learning (DL) methods have gained traction for water quality applications. For example, Wang et al.7 introduced a Long Short-Term Memory Autoencoder with Attention (LSTMA-AE) combined with mechanistic constraints to improve accuracy and reduce false alarms in anomaly detection of water injection pump operations, achieving significantly better performance than the interpolation, random forest, or LSTM-AE methods.
Similarly, Zhao et al.8 proposed a Gated Recurrent Unit with Physics-Informed Neural Network (GRU-PINN) model that incorporates physical constraints into the loss function, significantly boosting interpretability and the F1-score in water quality anomaly detection tasks. ElShafeiy et al.9 developed a Multivariate Convolutional Network-LSTM (MCN-LSTM) architecture, combining Multivariate Convolutional Networks with LSTM for real-time anomaly detection in water quality sensor data, demonstrating enhanced detection capabilities in field environments. Another advancement is the Gated-Liquid Neural Network (Gated-LNN) model10, which fuses gating mechanisms into Liquid Neural Networks to accurately predict the Water Quality Index (WQI) and classify water quality, achieving R2 ≈ 0.9995 and classification accuracy of 99.74% on Indian datasets.
Time series anomaly detection
Beyond DL-specific applications, time-series anomaly detection has seen rapid development across various domains. Time-series anomaly detection has become a key technique for improving water quality monitoring and early warning. Traditional statistical methods often fail to capture the nonlinear and dynamic characteristics of water quality data, thereby prompting the application of deep learning models. For instance, Zhang et al.11 combined Empirical Mode Decomposition (EMD) with LSTM to better handle non-stationary signals, significantly improving prediction accuracy of Chemical Oxygen Demand (COD), Biochemical Oxygen Demand (BOD₅), Total Phosphorus (TP), Total Nitrogen (TN), and Ammonia Nitrogen (NH₃-N). Building on this, Wang et al.12 proposed an LSTM-based fluctuation analysis method using Approximate Entropy, which enhances real-time anomaly detection performance.
Recent advances have emphasized attention mechanisms and hybrid frameworks. Arepalli et al.13 introduced a lightweight spatially shared attention LSTM for hypoxia detection in aquaculture, achieving 99.8% accuracy, while Zhang et al.14 showed that spatial and temporal attention significantly improved CNN-LSTM prediction of Dissolved Oxygen (DO) and NH₃-N. Similarly, Long et al.15 integrated Complete Ensemble Empirical Mode Decomposition with Adaptive Noise-Variational Mode Decomposition (CEEMDAN-VMD) with attention-enhanced LSTM, achieving Nash-Sutcliffe Efficiency (NSE) values up to 0.99 across multiple indicators. At the application level, Xie et al.16 demonstrated a mobile LSTM-sequence-to-sequence (Seq2Seq) system for operational, real-time water quality prediction across river basins.
Overall, these studies highlight a clear trend in LSTM-based baselines, attention-augmented hybrid models, and system-level applications. Although accuracy has improved substantially, challenges remain in interpretability, robustness under noisy conditions, and generalization across diverse monitoring networks.
Application of graph neural networks and spatiotemporal models in environmental monitoring
Graph neural networks (GNNs) and spatiotemporal deep learning models have recently demonstrated significant potential in environmental monitoring by capturing both spatial correlations among monitoring sites and temporal dependencies in water quality dynamics. For example, Wu et al.17 proposed a pre-training enhanced Spatio-Temporal Graph Neural Network (PT-STGNN) for wastewater treatment plants, integrating transformer-based pre-training and graph structure learning to improve long-term prediction of COD, NH₃-N, TP, TN, pH, and flow rate. Similarly, Wan et al.18 developed a Spatio-Temporal Feature GNN (STF-GNN) that combined graph convolution, GRU, and attention mechanisms, significantly improving Dissolved Oxygen (DO) and TN predictions while demonstrating robust cross-basin generalization.
Hybrid frameworks have emerged beyond purely data-driven designs to enhance generalization. Mu et al.19 introduced the spatiotemporal graph physics-informed neural network (ST-GPINN), which embeds hydraulic principles into Graph Neural Network (GNN)-based models for water distribution systems. By coupling graph representations with physics-informed constraints, ST-GPINN achieves state-of-the-art accuracy while scaling effectively from small to large networks. Together, these studies highlight the growing role of spatio-temporal GNNs in environmental monitoring, advancing predictive accuracy, interpretability, and robustness, and laying the foundation for next-generation intelligent water management systems.
Advantages and potential of liquid neural networks
Liquid Neural Networks (LNNs), also known as Liquid Time-Constant networks, uniquely model continuous-time dynamics using input-dependent, learnable time constants. Hasani et al.20 introduced LNNs and demonstrated their expressive power, stability, and efficiency in time-series tasks. Their brain-inspired adaptability makes them promising candidates for modeling dynamic environmental phenomena such as water quality, yet their integration with attention mechanisms remains underexplored.
Attention mechanisms, especially attention gates, are powerful tools for focusing on relevant features and enabling interpretability. Although widely used in medical imaging, Attention U-Net sets a foundation for selective feature refinement via learnable attention gates. Attention has also been applied in sensor-based anomaly detection frameworks, such as LSTMA-AE7 and GRU-PINN8, enhancing sensitivity to critical patterns and improving model transparency.
Taken together, these observations indicate the need for a hybrid architecture that synergizes continuous-time adaptability with interpretable attention mechanisms. Hence, we propose an Attention-Gated Liquid Neural Network (AG-LNN) that integrates the dynamic modeling capabilities of Liquid Neural Networks (LNNs) with attention gates that focus on salient inputs or temporal segments. This architecture aims to enhance robustness to sensor noise and irregular sampling, improve sensitivity to short-duration anomalies, and offer interpretability through attention heatmaps and adaptive time-constant trajectories. The AG-LNN was evaluated on real-world multivariate water quality datasets and benchmarked against LSTM, Transformer, pure LNN, and traditional ML baselines. Both quantitative (Precision, Recall, F1, AUC) and qualitative (attention visualizations, time-constant dynamics) analyses demonstrated the effectiveness and transparency of the proposed model.