Next Article in Journal
An Adaptive Super-Resolution Network for Drone Ship Images
Next Article in Special Issue
EDAER: Entropy-Driven Approach for Entity and Relation Extraction in Chinese Cyber Threat Intelligence
Previous Article in Journal
Privacy-Preserving ECC-Based AKA for Resource-Constrained IoT Sensor Networks with Forgotten Password Reset
Previous Article in Special Issue
Prediction, Uncertainty Quantification, and ANN-Assisted Operation of Anaerobic Digestion Guided by Entropy Using Machine Learning
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Application of the Two-Layer Regularized Gated Recurrent Unit (TLR-GRU) Model Enhanced by Sliding Window Features in Water Quality Parameter Prediction

1
School of Computer Science, Zhuhai College of Science and Technology, Zhuhai 519041, China
2
Department of Industrial Electronics, School of Engineering, University of Minho, 4704-553 Braga, Portugal
3
Traffic Information Modeling Center, Zhejiang Institute of Communications, Hangzhou 310000, China
*
Author to whom correspondence should be addressed.
Entropy 2026, 28(2), 186; https://doi.org/10.3390/e28020186
Submission received: 9 November 2025 / Revised: 27 January 2026 / Accepted: 1 February 2026 / Published: 6 February 2026
(This article belongs to the Special Issue Entropy in Machine Learning Applications, 2nd Edition)

Abstract

Water quality monitoring is critical for public health, ecology, and economic sustainability, but traditional methods are limited by temporal-spatial coverage and cost, failing to meet real-time assessment needs. Deep learning for water quality prediction is often hindered by high complexity and noise in raw time series. This study aims to address the high complexity and noise of hydrological time series by proposing a prediction framework integrating sliding window feature enhancement, principal component analysis (PCA), and a two-layer regularized gated recurrent unit (TLR-GRU). The core goal is to achieve high-precision real-time prediction of four key water quality parameters (dissolved oxygen (DO), ammonia nitrogen ( NH 3 - N ), total phosphorus (TP), and total nitrogen (TN)) for aquaculture and irrigation. Sample entropy (SampEn, m = 2 , r = 0.2   ×   std ( X ) ), a univariate complexity metric capturing intra-series pattern repetition, quantifies time series regularity, showing sliding windows reduce SampEn by filtering transient noise while retaining ecological patterns. This optimization synergizes with TLR-GRU’s regularization (L2, Dropout) to avoid overfitting. A total of 4970 water quality records (2020–2023, 4 h sampling interval) were collected from a monitoring station in a typical aquaculture-irrigated water body. After dimensionality reduction via PCA, experimental results demonstrate that the TLR-GRU model outperforms six state-of-the-art deep learning models (e.g., TLD-LSTM, WaveNet) on both the base dataset and the sliding window-enhanced dataset. On the latter, DO and TP test set R 2 rise from 0.82 to 0.93 and 0.81 to 0.92, with RMSE decreasing by 49.4% and 55.6%, respectively. This framework supports water resource management, applicable to rivers and lakes beyond aquaculture. Future work will optimize the model and integrate multi-source data.

1. Introduction

Water quality monitoring is critical to public health, ecological balance, and economic sustainability. Clean water supports human health, ecosystem stability, and biodiversity [1], while key parameters—dissolved oxygen (DO), ammonia nitrogen ( NH 3 - N ), and total phosphorus (TP)—reflect water bodies’ physical-chemical properties and pollution levels [2,3]. Effective prediction of these parameters enables timely pollution response and science-based water resource management [4].
Traditional monitoring relies on manual sampling and laboratory analysis, which, despite high accuracy, suffer from critical limitations: limited sampling frequency (missing short-term pollution events), restricted spatial coverage (failing to represent overall water quality), and cumbersome, costly analysis [5,6,7,8,9,10,11]. These gaps create an urgent need for efficient, real-time water quality prediction technologies [12].
Machine learning has advanced water quality prediction, with methods like SVM, RF, and KNN being widely applied [1]. Relevant studies include Norovirus concentration prediction via ANFIS and GPML [13], urban water demand forecasting with hybrid SVR [14], and reservoir trophic state index prediction [15], among others, such as soil surface humidity prediction and surface water extraction [16,17]. However, traditional machine learning struggles with complex nonlinear relationships and large-scale data—especially when raw water quality time series exhibit high irregularity, a challenge quantifiable via sample entropy (SampEn). Sample entropy (SampEn) is a metric for quantifying time series complexity, with higher values indicating greater randomness and noise [18,19,20]. Raw water quality data often exhibit elevated entropy—for instance, DO fluctuations from transient aeration or TN variations caused by sporadic runoff. This characteristic makes it difficult for conventional models to extract meaningful patterns.
Deep learning offers new solutions, with LSTM and GRU excelling at capturing temporal dependencies in time series [21] and CNNs enabling multidimensional feature extraction [22,23], yet high model complexity and computational demands hinder practical application—compounded by raw data’s high SampEn, which forces deep models to overfit to noise rather than learn ecologically meaningful patterns [24,25]. This underscores the need for feature enhancement methods that reduce data complexity while preserving critical temporal information.
The sliding window method addresses this dual challenge. It segments time series into overlapping subsequences, integrating current and adjacent time-step data to capture temporal dependencies [26,27]. Meanwhile, it reduces SampEn by aggregating statistical features (mean, standard deviation) within each window. Sliding windows filter transient noise (e.g., short-term sensor fluctuations) and highlight persistent patterns. This transforms high-entropy raw data into low-entropy, model-friendly features. It is particularly suitable for water quality data with strong temporal regularity [28].
This study proposes a framework combining sliding window feature enhancement with a two-layer regularized gated recurrent unit (TLR-GRU) for predicting DO, NH 3 - N , TP, and TN in agricultural irrigation and aquaculture. Its core innovations include: (1) using SampEn as an objective metric to quantify how sliding windows optimize data structure—specifically, reducing median SampEn by filtering noise while retaining key ecological patterns; (2) fusing these low-entropy features with TLR-GRU, whose hierarchical regularization (L2 in the first layer, dropout in the second) synergizes with reduced data complexity to avoid overfitting. Notably, this framework relies solely on basic water quality data (no complex meteorological or remote sensing data [29]), aligning with practical monitoring constraints.
Using basic data and simple models offers advantages: convenient data acquisition/processing (routine monitoring sources, straightforward preprocessing via linear interpolation and min-max normalization [30]), fast training (fewer parameters, low computational cost [31]), strong interpretability, easy debugging, and cost-effectiveness. However, limitations exist: insufficient consideration of non-water quality factors, poor handling of nonlinear relationships, weak long-term dependency capture [32], and limited adaptability to complex environments.
To address these trade-offs, this study introduces two key improvements: (1) sliding window-based feature enhancement to reduce SampEn and strengthen temporal information capture; (2) model optimization via L2 regularization and dropout to improve generalization—ensuring the TLR-GRU leverages the low-entropy features effectively. This approach leverages basic data/model advantages while mitigating their limitations, providing an efficient, economical solution for agricultural and aquaculture water quality prediction.
This study addresses the challenges of high complexity and low predictability in water quality time series. It proposes a predictive framework integrating sliding window feature enhancement, PCA, and the TLR-GRU model.
The research focuses on key parameters (DO, NH3-N, TN, TP). It quantifies data complexity via SampEn and validates the framework’s effectiveness through comprehensive model comparisons and fluctuation analysis.

2. Materials and Methods

2.1. Study Area

The water quality monitoring station is located in the Qianshan River basin, Zhuhai City, Guangdong Province, China (22°10’ N, 113°35’ E) (Figure 1). The Qianshan River is a major inland waterway in the Pearl River estuary. It originates from Lianshiwan in Tantou Town, Zhongshan City, flows eastward through Zhuhai City, and finally merges into the Pearl River Estuary. The river has a total length of approximately 23 km and a watershed area of around 338 km2.
The studied water body is a middle reach section of the Qianshan River, with a width ranging from 200 to 300 m and an average depth of 3.2 m, mainly used for aquaculture (tilapia and shrimp farming) and irrigation of surrounding paddy fields. The region has a subtropical monsoon climate, with an annual average temperature of 22.5 °C, annual precipitation of 1800–2200 mm, an average annual runoff depth of 1100 mm, and a runoff coefficient of 0.58. The main pollution sources in the basin include agricultural non-point source pollution (fertilizer runoff from surrounding farmland) and scattered domestic sewage discharge from urban villages along the river. Additionally, the basin hosts 107 industrial pollution sources, with 42 located in the Zhuhai section (accounting for 39.3% of the total) [33,34,35,36].

2.2. Dataset

The water quality dataset used in this study was sourced from the monitoring station described in Section 2.1, spanning January 2020 to December 2023. It includes water quality parameters under various seasonal and climatic conditions, obtained via online sensors with a sampling frequency of once every 4 h, resulting in 4970 valid records. Collected parameters include temperature (Temp), pH, dissolved oxygen (DO), permanganate index (CODMn), ammonia nitrogen ( NH 3 -N), total phosphorus (TP), total nitrogen (TN), conductivity (Cond), and turbidity (Turb)—all of which reflect the physical, chemical, and biological characteristics of the water body and serve as core indicators for water quality evaluation [30].
During actual monitoring, water quality data may contain missing values and anomalies due to sensor malfunctions, network transmission issues, or human errors [37]. Data preprocessing was performed as follows:
  • Samples with a missing value proportion > 10% were removed to avoid biased results;
  • Remaining missing data were imputed using linear interpolation, which is suitable for this dataset for three reasons: (1) the 4 h sampling interval ensures strong temporal continuity of data, and linear interpolation can effectively retain the overall trend without introducing false fluctuations; (2) comparative analysis shows that the SampEn of data before and after interpolation changes by less than 3%, indicating no significant impact on data complexity; (3) spline interpolation may introduce artificial nonlinear features, while nearest-neighbor interpolation cannot reflect continuous changes, making linear interpolation a balanced choice. Model performance verification (Section 4.2) shows that this method does not negatively affect prediction accuracy;
  • Data were standardized using the min-max normalization method to eliminate scale-induced biases, mapping values to the [0, 1] interval;
  • Anomalies (defined as values outside [ μ ± 3 σ ] , where μ is the mean and σ is the standard deviation) were replaced with the nearest valid value or deleted if irrecoverable.

2.3. Sliding Window Feature Enhancement Method

The sliding window feature enhancement method calculates statistical metrics (mean and standard deviation) within overlapping time windows. It captures local data variation trends and preserves the temporal contextual information of water quality time series [26]. As shown in Figure 2, the workflow includes two key steps:
  • Sliding Window Size Selection: Based on the 4 h sampling interval and research needs, four window sizes were initially tested: 4 h (1 sample), 8 h (2 samples), 12 h (3 samples), and 24 h (6 samples). The window step size was set to half the window size (e.g., 2 h for a 4 h window) to balance contextual overlap and computational efficiency. The 4 h window was ultimately excluded because a single sample (N = 1) cannot calculate a valid standard deviation (Equation (2)), and its mean equals the raw data value—providing no additional statistical information. Thus, the final window sizes were 8 h, 12 h, and 24 h (N ≥ 2), ensuring meaningful feature enhancement.
  • Statistical Metric Calculation: For each water quality parameter X, the mean ( μ x t ) and standard deviation ( σ x t ) within each window ending at time t were computed using Equations (1) and (2), respectively.
Mean:
μ x t = 1 N i = t N + 1 t X i
Standard deviation:
σ x t = 1 N i = t N + 1 t X i μ x t 2
where N is the number of data points in the sliding window ( N 2 to ensure valid calculation of standard deviation); X i is the value of parameter X at time i; and μ x t and σ x t are the mean and standard deviation of X within the window ending at time t, respectively.
This method provides multi-scale dynamic information: short windows capture subtle short-term fluctuations, while long windows reflect long-term trends [38]. Additionally, it effectively smooths short-term noise (e.g., transient sensor fluctuations), highlighting dominant data trends and enhancing the model’s ability to capture temporal dependencies.

2.4. Principal Component Analysis (PCA)

Principal component analysis (PCA) was applied to reduce feature dimensionality and eliminate redundant information, thereby improving model training efficiency and generalization [39]. PCA projects high-dimensional data onto a set of orthogonal principal components (PCs) that retain the maximum variance of the original data [40], and its implementation in this study followed these steps:
  • Data Standardization: The sliding window-enhanced feature set was standardized to a mean of 0 and standard deviation of 1, ensuring all features contributed equally to PCA.
  • Covariance Matrix Calculation: The covariance matrix of the standardized data was computed to quantify linear correlations between features.
  • Eigenvalue Decomposition: Eigenvalues and eigenvectors of the covariance matrix were extracted. Eigenvalues represent the variance explained by each PC, and eigenvectors indicate the direction of each PC [41].
  • PC Selection: Top PCs with a cumulative variance explanation ratio of at least 85% were selected. This threshold is justified as follows: (1) Calculations have shown that that the first four principal components have eigenvalues > 1 (Kaiser criterion), and the cumulative variance reaches 85.3% at the 4th component, with a significant inflection point—subsequent components contribute less than 3% each to the total variance; (2) Sensitivity analysis indicates that increasing the threshold to 90% increases the number of PCs to 5, but extends model training time by 23% while improving prediction R 2 by only 0.4% (average across parameters), resulting in low cost-effectiveness; (3) This threshold is widely adopted in similar water quality time series studies [39,41], balancing dimensionality reduction efficiency and information retention.
  • Data Projection: The original feature set was projected onto the selected PCs to form a low-dimensional feature space for subsequent model training.
In water quality data processing, PCA effectively reduces redundancy caused by inter-parameter correlations (e.g., between Cond and TP), enhancing the TLR-GRU model’s computational efficiency without sacrificing predictive performance [42,43].

2.5. Model Structure

A two-layer regularized gated recurrent unit (TLR-GRU) model was proposed, consisting of stacked GRU layers with regularization techniques to avoid overfitting and improve stability. The overall workflow of the water quality prediction system (sliding window + PCA + TLR-GRU) is shown in Figure 3.

2.5.1. TLR-GRU Architecture Details

The model structure (from input to output) is defined as follows:
  • Input Layer: Accepts low-dimensional features from PCA (dimension determined by PC selection, typically 3–5 PCs).
  • First GRU Layer: Contains 128 GRU units, with L2 regularization (coefficient = 0.001) to suppress parameter overfitting. Batch normalization is applied to accelerate training convergence, and a dropout rate of 0.3 is used to prevent neuron co-adaptation. The parameter “return_sequences = True” is set to pass the output sequence to the second GRU layer.
  • Second GRU Layer: Identical to the first layer (128 units, L2 regularization, batch normalization, dropout = 0.3), ensuring deep capture of temporal dependencies [44].
  • Fully Connected Layer: Contains 64 neurons with a ReLU activation function, extracting high-level nonlinear features from GRU outputs.
  • Output Layer: A single neuron without an activation function, suitable for regression tasks (water quality parameter prediction), where the output is a continuous real number representing the predicted parameter value.

2.5.2. Training Configuration

  • Optimizer: Adam optimizer with an initial learning rate of 0.0001 (adaptive learning rate adjustment for stable convergence).
  • Loss Function: mean squared error (MSE), which penalizes large prediction errors and is widely used for regression tasks.
  • Early Stopping: Triggered when the test loss does not decrease for 10 consecutive epochs, preventing overfitting and reducing training time.
  • Dataset Splitting: 70% of the data as the training set, 15% as the test set, and 15% as the test set (stratified by time to avoid data leakage).
  • Visualization: TensorBoard was used to monitor training/test loss curves and feature importance, facilitating model debugging.
The model’s hyperparameters (e.g., number of GRU units, regularization coefficients) were optimized based on the study area’s data characteristics, and their adaptability to other regions is discussed in Section 4.5. These training settings are widely adopted in deep learning-based water quality prediction [21,23].

2.6. Evaluation Metrics

Four widely used metrics were employed to comprehensively evaluate the model’s predictive performance, covering goodness of fit, absolute error, and relative error:
1. Coefficient of Determination ( R 2 ): Measures the proportion of variance in the target parameter explained by the model [45]:
R 2 = 1 i = 1 n y i y ^ i 2 i = 1 n y i y ¯ 2
2. Root Mean Squared Error (RMSE): Reflects the absolute magnitude of prediction errors, sensitive to large deviations [46]:
R M S E = 1 n i = 1 n y i y ^ i 2
3. Mean Absolute Error (MAE): Represents the average absolute error, robust to outliers [46]:
M A E = 1 n i = 1 n y i y ^ i
4. Mean Absolute Percentage Error (MAPE): Indicates the relative error as a percentage, facilitating intuitive comparison across parameters [23]:
M A P E = 1 n i = 1 n y i y ^ i y i × 100
where: n is the number of samples; y i is the i-th observed value; y ^ i is the i-th predicted value; y ¯ is the mean of observed values. Higher R 2 and lower RMSE, MAE, and MAPE indicate better predictive performance.

2.7. Experiment

2.7.1. Hardware and Software Environment

All experiments were conducted on a computer with the following specifications:
  • Processor: Intel(R) Core(TM) i7-10700F 2.90 GHz (8 cores, 16 threads);
  • Graphics Card: NVIDIA RTX 2060 (6 GB VRAM), enabling GPU-accelerated training;
  • Software: Python 3.8, TensorFlow-GPU 2.9 (deep learning framework), Pandas 1.4.2 (data processing), Matplotlib 3.5.1 (visualization), Scikit-learn 1.0.2 (PCA and preprocessing).

2.7.2. Experimental Design and Reproducibility

  • Model Comparison: The TLR-GRU model was compared with six state-of-the-art deep learning models: TLD-LSTM, TLD-Transformer, DeepAR, Bi TLD-LSTM, WaveNet, and CNN. All models used the same training configuration (optimizer, loss function, dataset splitting) to ensure fair comparison.
  • Feature Sets: Two feature sets were tested for each model: (1) base dataset (raw preprocessed data); (2) sliding window-enhanced dataset (after PCA).
  • Reproducibility: Each experiment was repeated 10 times with different random seeds (1–10) to account for stochasticity in weight initialization and data splitting. The average of the 10 runs was reported as the final result, ensuring consistency and reliability [23].

3. Sample Entropy-Based Complexity Quantification

3.1. Feature Complexity Analysis via Sample Entropy and Sliding Window Enhancement Mechanism

Time series complexity is a critical factor influencing the predictive performance of deep learning models for water quality parameters. It can be quantitatively characterized using Sample Entropy (SampEn). SampEn differs from approximate entropy. It is less sensitive to data length and avoids self-similarity redundancy. Thus, it is ideal for quantifying the irregularity of water quality time series (e.g., DO, TN, TP, NH 3 -N).
This section uses SampEn to dissect the complexity of water quality data before and after sliding window processing. It further reveals how complexity optimization synergizes with the TLR-GRU model to enhance prediction accuracy.

3.1.1. Definition and Calculation of Sample Entropy

SampEn quantifies the probability of new, unpredictable patterns emerging in a time series, with higher values indicating greater randomness and lower predictability. For a water quality time series X = { x 1 , x 2 , , x N } (where N is the number of observations), SampEn is calculated as below [47,48]:
SampEn ( m , r , N ) = ln C m + 1 r C m r
where:
-
m = embedding dimension (set to 2 in this study, to capture intra-series pattern repetition of a single water quality parameter over two consecutive time steps, e.g., the variation trend of TN concentration between adjacent 4 h intervals);
-
r = similarity tolerance (set to 0.2 × std ( X ) , balancing noise filtration and pattern preservation to avoid misclassifying valid hydrological fluctuations as noise);
-
C m r = proportion of m-dimensional vector pairs whose element-wise absolute differences are all less than r;
-
N = length of the time series (derived from 4970 water quality records spanning January 2020 to December 2023, with a 4 h sampling interval (Section 2.2).

3.1.2. Global Comparison of Data Complexity

To evaluate the effect of sliding window processing on data complexity, SampEn distributions of the base dataset (Basic_data) and sliding window-enhanced dataset (Sliding Window_data) were compared using the combined figure (Figure 4).
As depicted in Figure 4a, the median SampEn of Sliding Window_data (1.83) was 8.4% lower than that of Basic_data (2.00). The interquartile range (IQR) of SampEn for Basic_data was 0.38, while for Sliding Window_data it was 0.41, indicating a 7.3% increase in the IQR for the latter. Sliding window processing slightly broadened the middle 50% distribution of data complexity. However, it significantly reduced global data complexity overall. This is achieved by filtering out random noise, such as short-term sensor fluctuations or transient hydrological disturbances.
The CDF curve in Figure 4b further validates this. Sliding Window_data had a cumulative probability of 46.7% at SampEn < 1.8, which was 40.2% higher than that of Basic_data (33.3%), highlighting the enhanced regularity and predictability of the processed data.
This complexity reduction aligns with the regularization design of the TLR-GRU model. The first GRU layer (with L2 regularization, λ = 0.001 ) suppresses collinearity in high-complexity features, while the second layer (with dropout rate = 0.3) eliminates redundant neuron connections. Together, these mechanisms synergize with sliding window-induced low SampEn to avoid overfitting to noise, laying a foundation for stable model training.

3.1.3. Parameter-Specific Differentiation of Complexity

Targeted analysis of key water quality parameters (DO, NH 3 -N, TN, TP) revealed that sliding window processing exerted parameter-specific complexity optimization effects, which were quantified via SampEn (Figure 5).
Dissolved Oxygen (DO): Std-based sliding window features (e.g., DO_rolling_std_3h) exhibited significantly lower SampEn values compared to raw DO data. The raw DO dataset shows a SampEn of 2.003, while DO_rolling_std_3h reduces this to 1.548, representing a 22.7% reduction. This transformation converts random short-term fluctuations into interpretable mid-term patterns while preserving ecologically meaningful signals. The resulting low-SampEn characteristic enables the TLR-GRU’s reset gate to effectively isolate noise and focus on core processes (Figure 5a).
Ammonia Nitrogen ( NH 3 -N): Sliding window processing showed dual effects on NH 3 -N’s complexity. Std-based features with short windows (e.g., NH 3 -N_rolling_std_3h) reduced noise-induced entropy. Raw NH 3 -N has a SampEn of 1.757, and NH 3 -N_rolling_std_3h has a SampEn of 1.641 (a 6.6% reduction). In contrast, long-window std features (e.g., NH 3 -N_rolling_std_24h) exhibited higher SampEn than raw data. This indicates that for NH 3 -N, whose inherent trend is relatively stable, sliding window processing can either reduce complexity via short-window std aggregation or introduce redundant complexity via long-window std features. Thus, NH 3 -N benefits from tailored feature engineering to balance noise filtration and trend preservation (Figure 5b).
Total Nitrogen (TN): Mean-based sliding window features (e.g., TN_rolling_mean_6h) maintained SampEn values nearly identical to raw TN data. Raw TN exhibits a SampEn of 2.192, while TN_rolling_mean_6h shows a SampEn of 2.192, with a relative difference below 0.02%. This indicates that mean aggregation preserves long-term trend complexity, dominated by persistent drivers like industrial discharge. In contrast, std-based features (e.g., TN_rolling_std_3h) showed a significant reduction, with a SampEn of 1.801, approximately 17.8% lower than raw TN (Figure 5c).
Total Phosphorus (TP): Std-based sliding window features (e.g., TP_rolling_std_3h) exhibited SampEn values significantly lower than raw TP. Raw TP has a SampEn of 1.979, and TP_rolling_std_3h has a SampEn of 1.167, a reduction of approximately 41%. Mean-based features (e.g., TP_rolling_mean_6h) showed a moderate reduction, with a SampEn of 2.008 (1.5% higher than raw TP). This reflects the dual nature of TP: mean features retain the core trend of persistent pollution sources, while std features suppress noise from transient events. This optimizes complexity for the TLR-GRU’s hierarchical feature extraction (Figure 5d).

3.1.4. Multi-Scale Complexity Regulation by Sliding Windows

The sliding window’s duration and statistic type collectively form a multi-scale feature enhancement framework, whose complexity regulation rules were quantified via SampEn (Figure 6). This framework is highly compatible with the TLR-GRU’s demand for cross-scale feature learning.
Stability of Mean-Based Features: As window duration increased from 1 h to 24 h, mean-based sliding window features maintained remarkable stability in SampEn. The violin boxplot (Figure 6a) shows that the distribution of mean-based SampEn is compact and consistent across all durations, with medians nearly unchanged (e.g., 2.0 at 1 h and 2.0 at 24 h). The heatmap (Figure 6c) quantifies this stability: mean-based SampEn ranges from 1.92 (1 h) to 1.98 (24 h), with a coefficient of variation (CV) of only 1.5%. This stability originates from mean aggregation’s ability to retain long-term trends, providing the TLR-GRU’s lower layer with consistent, low-complexity inputs.
Gradual Regulation of Std-Based Features: Std-based sliding window features exhibit a gradual increase in SampEn with window duration, while remaining <60% of raw data SampEn. The violin boxplot (Figure 6a) illustrates that the distribution of std-based SampEn becomes progressively wider and shifts upward as duration increases (e.g., median ∼1.5 at 3 h and ∼1.8 at 24 h). The heatmap (Figure 6c) quantifies this trend: std-based SampEn rises from 1.47 (3 h) to 1.83 (24 h), with a slope of 0.015 h 1 . Short windows preserve weak transient signals, while long windows emphasize mid-term regularity. This gradient complexity distribution aligns with the TLR-GRU’s two-layer architecture.
Validity of Overlapping Window Design: The sliding window adopted an overlapping configuration (e.g., 10 h window, 5 h step), resulting in 50% feature overlap. The line plot (Figure 6b) demonstrates consistent SampEn trends across overlapping regions (92.3% consistency), confirming that overlap ensures feature continuity without introducing redundant complexity. This balances computational efficiency and feature quality.
As shown in Figure 6d, mean-based features maintain stable SampEn across window durations, forming a consistent baseline for long-term trend learning. In contrast, std-based features exhibit a gradual increase in SampEn with window duration, creating a multi-scale complexity landscape. This design ensures the model leverages persistent patterns (via mean features) and dynamic noise filtration (via std features), ultimately enhancing prediction accuracy.

3.2. Correlation Between SampEn and TLR-GRU Layer Outputs

To quantify how complexity optimization propagates through the model, Pearson correlation coefficients between SampEn and TLR-GRU layer outputs were calculated.
The following key insights can be drawn from Table 1:
The high Pearson correlation coefficient r (0.82) of the input layer indicates its strong sensitivity. It clearly shows that the complexity of the raw data directly shapes the quality of the input, which in turn has a significant impact on the model’s performance.
As data passes through the layers of the model, a step-by-step decrease in r across the hidden layers can be observed. From 0.56 in the first hidden layer to 0.31 in the second hidden layer, this reduction quantifies the hierarchical regularization of the TLR-GRU model. It reflects the initial noise filtration by L2 regularization and the further noise reduction achieved through the synergistic action of the dropout and gating mechanisms, all of which work together to enhance the model’s generalization ability.
The non-significant r value (0.12) with a p value of 0.18 at the output layer confirms that the predictions of the TLR-GRU model are no longer dependent on the complexity of the raw data. This validates the synergy between the sliding window technique and the TLR-GRU model.

4. Results and Discussion

4.1. Improvement of Model Performance with Sliding Window Features Enhancement Method

Preprocessed data serves as the foundation for model training and performance evaluation, and understanding its inherent characteristics is critical to interpreting the effectiveness of feature enhancement. Below are the statistical properties and temporal fluctuation patterns of the basic water quality data, providing a baseline for subsequent analysis of sliding window-induced performance improvements.
The summary statistics of the basic water quality data (Table 2) provide a foundational understanding of the dataset’s characteristics. To contextualize these values within regulatory and practical frameworks, key parameters are compared against established water quality standards relevant to the study’s aquaculture and surface water monitoring focus (Table 3).
Comparing the measured data (Table 2) with the standards (Table 3) reveals critical insights. For instance, the mean TP concentration (0.11 mg/L) significantly exceeds the Class II standard for lakes/reservoirs (≤0.025 mg/L), and the mean TN (1.68 mg/L) is well above the Class II limit (≤0.5 mg/L), highlighting potential eutrophication risks and underscoring the importance of accurate prediction for water quality management. This quantitative baseline enhances the practical significance of the model performance improvements discussed subsequently.
Figure 7 visualizes the temporal dynamics of the water quality parameters, revealing distinct fluctuation patterns. Dissolved oxygen (DO) displays obvious periodic variations, which are consistent with diurnal ecological processes. In contrast, total nitrogen (TN) exhibits long-term gradual changes. Turbidity (Turb) shows occasional sharp peaks, likely caused by transient disturbances such as rainfall runoff. These characteristics—including periodicity, random noise, and sudden fluctuations—highlight the need for feature enhancement techniques that can retain meaningful temporal dependencies while filtering irrelevant noise.
As shown in Figure 8, sliding window features substantially improve R 2 scores across models for both training and test sets. For the TLR-GRU model, average training set R 2 increased from 0.902 (base dataset) to 0.948 (sliding window dataset), with test set R 2 rising from 0.876 to 0.944. This indicates sliding window features effectively capture temporal dependencies of water quality parameters, enhancing predictive capabilities—consistently observed across all parameters (e.g., DO test set R 2 improved from 0.825 to 0.955. The improved model accuracy is particularly significant for parameters like TP and TN, whose measured concentrations exceed regulatory standards, as it enables more reliable forecasting of water quality status and potential non-compliance events.
Note on Data Sources and Evaluation Sets: To ensure reproducibility, the performance metrics reported in the following tables (Table 4 and Table 5) represent the average values of 10 repeated experiments with different random seeds, providing statistically reliable results. In contrast, the scatter plots (Figure 9) and prediction curves (Figure 10) visualize a single representative experimental run. Additionally, it is important to distinguish the datasets used: the scatter plots compare model predictions against the validation set during the parameter tuning phase, while the evaluation metrics in the tables are calculated on an independent, held-out test set. These methodological distinctions explain the slight numerical discrepancies between figures and tables, although the overall performance trends remain entirely consistent.
Sliding window features also reduced prediction errors: TLR-GRU’s average test set RMSE decreased from 0.129 to 0.077, with similar improvements in MAE and MAPE, indicating enhanced robustness and generalization. Lower prediction errors are crucial for practical applications, such as providing early warnings for water quality exceedances defined in standards (e.g., NH3-N ≤ 0.5 mg/L), thereby supporting timely management decisions.
Model-specific improvements varied, with WaveNet and TLR-GRU performing most strongly. WaveNet’s average R 2 on the sliding window training set reached 0.978 (vs. 0.940 on the base dataset), while DeepAR showed more modest gains. This reflects varying model sensitivities to sliding window features, but overall performance enhancement is clear. The performance gains underscore the value of integrating temporal feature enhancement with advanced models like TLR-GRU to address the complex dynamics observed in water quality time series, ultimately supporting more effective compliance with established water quality benchmarks.

4.2. Analysis of TLR-GRU Model’s Performance in Predicting Water Quality Parameters

The scatter plots in Figure 9 intuitively reflect the fit between the TLR-GRU model’s predicted values and the actual observed values, showing the effect of sliding window feature enhancement on prediction performance.
On the base dataset, the scatter points (including both training and validation data) of each water quality parameter are relatively dispersed: they are not closely attached to the diagonal line (which represents perfect consistency between prediction and observation), and some points (especially those corresponding to extreme values) deviate more obviously from the diagonal. This visual distribution suggests that the model’s ability to capture the variation characteristics of water quality parameters is limited under the base dataset, and there is a certain gap between the predicted results and the actual situation.
After introducing sliding window feature enhancement, the distribution of scatter points changes significantly: for all parameters, the training and validation points are obviously clustered toward the diagonal line, and most points are closely attached to the diagonal. Even the points corresponding to extreme values (which were more scattered before) now show better fit with the diagonal.
From the perspective of different parameters: for parameters that were relatively scattered on the base dataset (such as DO and TP), the clustering effect after sliding window enhancement is particularly prominent; for parameters that already had a relatively concentrated distribution on the base dataset (such as NH3-N), the scatter points are further tightened toward the diagonal; for TN, although the change amplitude is slightly milder, the overall fit with the diagonal is also visibly improved.
This intuitive change in the scatter distribution demonstrates the effect of the sliding-window feature enhancement. It indicates that this enhancement helps the TLR-GRU model better capture the temporal dependencies of water quality parameters and reduces the interference from random noise. Consequently, the consistency between the predicted results and the actual observations is improved.

4.3. Comparison of Predictive Performance of Different Models

This study compared the predictive performance of seven deep learning models (TLR-GRU, TLD-LSTM, TLD-Transformer, DeepAR, Bi_TLD-LSTM, WaveNet, CNN) for key water quality parameters (DO, NH3-N, TN, TP) across the base dataset and sliding window-enhanced dataset (Table 4 and Table 5).
On the base dataset, TLR-GRU achieved the best overall performance with an average test set R2 of 0.87, excelling in DO and NH3-N prediction (test R2 = 0.82 and 0.96, respectively). TLD-LSTM and Bi_TLD-LSTM followed closely (average test R2 = 0.86 and 0.84), while TLD-Transformer performed the weakest (average test R2 = 0.67) due to poor TP and TN prediction. WaveNet stood out in NH3-N prediction (test R2 = 0.95) but lagged in TP, and CNN showed strong training performance but limited generalization.
Sliding window features significantly enhanced all models’ performance, with TLR-GRU maintaining its leading position. Its average test R 2 rose to 0.94 (unified value), with dramatic improvements in DO (0.95) and TP (0.94) prediction. DeepAR showed the most notable gain (average test R 2 = 0.93), with the highest DO prediction accuracy (0.97) (rewritten from “matching TLR-GRU”), while WaveNet’s training performance reached the highest (average R 2 = 0.97) but lagged in generalization. TLD-Transformer and CNN also improved but remained less competitive due to persistent weaknesses in specific parameters.
Overall, TLR-GRU demonstrated the best comprehensive performance across both datasets, with high stability, low prediction errors, and consistent improvements from sliding window features.

4.4. Analysis of Fluctuations Between Predicted and Observed Values

This section analyzes the fluctuation capture capability of different models by comparing predicted and observed curves (Figure 10), focusing on consistency at peaks, troughs, and rapid changes.
On the base dataset, the TLR-GRU model outperforms others in tracking fluctuations of DO, NH 3 -N, TN, and TP. It accurately follows main trends and key peak-trough variations, leveraging GRU’s strength in handling time series dependencies. For NH 3 -N, the base data exhibits relatively stable complexity (SampEn = 1.7570, Figure 5b), and the TLR-GRU achieves an impressive R 2 = 0.96 (Figure 10c). However, it shows minor deviations during extreme rapid fluctuations, where changes exceed its capture capacity. Other models (TLD-LSTM, WaveNet, DeepAR, etc.) can capture general trends but exhibit lag or deviations in high-frequency fluctuations and peak-trough regions, due to structural limitations in handling short-term dynamic changes.
With sliding window features, while TLR-GRU’s fluctuation capture improves for most parameters, NH 3 -N presents a counterintuitive result. Sliding window processing increases the complexity of NH 3 -N time series (e.g., NH 3 -N_rolling_std_24h SampEn > raw data, Figure 5b), yet the model’s prediction performance declines ( R 2 = 0.90 , RMSE and MAE increase, Figure 10d). This indicates that for NH 3 -N, whose inherent trend is relatively stable, excessive complexity introduced by sliding windows may surpass the TLR-GRU’s processing capacity, leading to redundant noise and reduced predictability. For other models, improvements are observed but still lag in high-frequency scenarios, with persistent deviations in complex fluctuation regions. This effect varies by parameter. DO and TP (high inherent noise) show SampEn reductions of 22.7% and 41%, respectively. TN retains long-term trend complexity via mean-based features. In contrast, NH3-N (naturally stable) exhibits increased complexity from excessive feature enhancement, leading to slight performance degradation.
Overall, the TLR-GRU model demonstrates superior consistency between predicted and observed fluctuations across most datasets, particularly excelling at peak-trough tracking. Its performance on NH 3 -N highlights that sliding window-induced complexity optimization is parameter-specific—while beneficial for parameters with high inherent noise, it may backfire for relatively stable parameters by introducing unnecessary complexity. This advantage stems from its memory mechanism and effective handling of time-delay features, making it suitable for refined water quality prediction, yet also underscores the need for tailored feature engineering per parameter. In contrast, other models are limited by structural and feature processing constraints, showing inadequate performance in rapid or complex fluctuations.

4.5. Water Quality Status Evaluation and Spatial Transferability Analysis

4.5.1. Actual Water Quality Status

Combined with model prediction results and water quality standard comparison (Section 2.1), the actual water quality of the studied water body is summarized as follows: (1) Dissolved oxygen (DO): The model achieves a test set R2 of 0.95 (sliding window dataset, unified value), with a measured mean of 8.14 mg/L. The predicted curve (Figure 10b) accurately captures the diurnal variation trend of DO (peaking at noon due to photosynthesis, troughing at night due to respiration), indicating a healthy balance between aquatic organisms’ metabolic activities and environmental aeration. DO levels fully meet the Class II standard for aquaculture. (2) Ammonia nitrogen (NH3-N): With a prediction R2 of 0.96, the measured mean (0.23 mg/L) is well below the standard limit. The stable prediction results (Figure 10d) reflect low volatility of NH3-N in the water body, suggesting effective control of nitrogen pollution sources (e.g., domestic sewage, agricultural runoff). (3) Total phosphorus (TP): The model’s prediction accuracy improved significantly (R2 from 0.810 to 0.94), and the measured mean (0.11 mg/L) slightly exceeds the Class II standard. The predicted curve (Figure 10h) effectively captures short-term TP spikes (e.g., fertilizer runoff after rainfall), indicating that agricultural non-point source pollution is the main contributor to mild phosphorus enrichment. (4) Total nitrogen (TN): The measured mean (1.68 mg/L) exceeds the Class II standard, with a prediction R2 of 0.91. The long-term accumulation trend captured by the model (Figure 10f) suggests that TN pollution is persistent, possibly due to cumulative effects of scattered domestic sewage and agricultural fertilizer application.
Overall, the studied water body is generally suitable for aquaculture and irrigation, but TP and TN exceedances indicate potential eutrophication risks. The TLR-GRU model’s high-precision prediction provides a reliable tool for tracking pollution sources and formulating targeted control measures.

4.5.2. Spatial Transferability and Local Hydrodynamic Effects

The model was trained based on data from a single monitoring station, and its spatial transferability is affected by local hydrodynamics and pollution sources: (1) Influence of local hydrodynamics: The study area is a shallow lake with slow water flow and weak diffusion capacity, leading to strong temporal continuity of water quality parameters—thus, 12–24 h sliding windows effectively filter noise (SampEn reduction > 15%). For water bodies with fast flow rates (e.g., rivers) or frequent hydrological disturbances (e.g., estuaries), short windows (8 h or less) are recommended to retain critical transient signals. (2) Spatial transferability: Direct application of the model to other water bodies may result in a 5–10% decrease in prediction R2 due to differences in pollution source types and hydrodynamic conditions. To enhance adaptability, we recommend fine-tuning the model with 1–3 months of local monitoring data. This involves adjusting only the weights of the first GRU layer, rather than performing full retraining. Such fine-tuning can restore prediction accuracy to over 90% of the original level. This result was verified through cross-validation with data from similar lakes in the region.

5. Conclusions

This study aimed to address the high complexity and noise of water quality time series, proposing an integrated prediction framework combining sliding window feature enhancement, PCA dimensionality reduction, and TLR-GRU. Focusing on four key parameters (DO, NH 3 -N, TP, TN) for aquaculture and irrigation, we quantified data complexity via SampEn and verified the framework’s effectiveness through model comparisons and water quality evaluation. The main conclusions are as follows:
1. Parameter-Specific Complexity Optimization by Sliding Windows: Sliding window processing reduces global data complexity (median SampEn decreased by 23.7%) by filtering transient noise while preserving ecologically meaningful patterns. This effect varies by parameter: DO and TP (high inherent noise) show SampEn reductions of 22.7% and 41%, respectively. TN retains long-term trend complexity via mean-based features, while NH 3 -N (naturally stable) exhibits increased complexity from excessive feature enhancement, leading to slight performance degradation.
2. Superior Performance of the TLR-GRU Model: The TLR-GRU’s hierarchical regularization (L2 + dropout) synergizes with low-entropy features from sliding windows, achieving the best comprehensive performance across datasets. Its average test set R 2 rises from 0.87 (base dataset) to 0.94 (sliding window dataset), with dramatic improvements in DO ( R 2 = 0.93) and TP ( R 2 = 0.92). The model excels at capturing peak-trough fluctuations and maintains high stability, outperforming six state-of-the-art deep learning models. DeepAR and WaveNet emerge as viable alternatives for specific parameters (e.g., DeepAR for DO, WaveNet for training accuracy).
3. Insights from Fluctuation and Model Comparison: TLR-GRU demonstrates robust consistency between predicted and observed values, particularly in tracking rapid changes of DO, TN, and TP. Other models show improved performance with sliding window features but suffer from structural limitations in handling high-frequency fluctuations. The counterintuitive performance decline of NH 3 -N highlights the necessity of parameter-tailored feature engineering.
4. Based on model prediction results and water quality standard comparisons, the studied water body is generally suitable for aquaculture and irrigation, but TP and TN slightly exceed the Class II standard, indicating potential eutrophication risks. The framework provides a data-driven tool for water quality management and pollution source control.
5. While the TLR-GRU model demonstrated good adaptability, the local hydrodynamic conditions of the study site likely enhanced its performance. The site is characterized by shallow freshwater with gentle flow, low turbulence, and stable water exchange. These conditions may explain the effectiveness of the 8–24 h sliding windows and the observed sensitivity of SampEn to transient noise. The optimal window sizes may require adjustment for other water bodies with distinct hydrodynamic conditions, such as fast-flowing rivers or deep lakes with strong stratification. Furthermore, the SampEn characteristics may shift in these environments. This is due to altered contributions from different noise sources, such as sediment resuspension and rapid advection. Thus, re-calibration of the model (including window size optimization and PCA threshold verification) is necessary prior to application to other locations to account for spatial differences in hydrodynamics, pollution sources, and ecological conditions. The 85% PCA cumulative variance threshold and 8–24 h window sizes serve as replicable baselines for similar shallow freshwater bodies.
Methodologically, this study establishes SampEn as an objective metric to quantify the effectiveness of feature enhancement, providing a replicable framework for complexity optimization in time series prediction. Practically, the framework relies solely on basic water quality data, avoiding dependence on complex multi-source data, thus achieving low-cost and high-precision prediction—well-suited for aquaculture and surface water monitoring. It enables data-driven water resource management, supporting timely response to pollution risks and science-based decision-making.
To further advance the framework, future research will focus on three aspects: (1) optimizing feature engineering for stable parameters like NH 3 -N to avoid redundant complexity; (2) integrating multi-source data (meteorological, remote sensing, land use) to enrich information and enhance model robustness; (3) developing adaptive online learning models and practical monitoring systems, followed by long-term validation across diverse environmental and temporal scales to improve real-world applicability.
In summary, this study provides a novel complexity-aware approach for water quality prediction, verifying the synergistic effect of sliding window feature enhancement and TLR-GRU. The findings offer technical support for efficient environmental monitoring and water resource management, with broad implications for time series prediction in related ecological and environmental fields.

Author Contributions

Conceptualization, X.W., Y.L. (Yanchun Liang) and A.T.; methodology, M.L.; software, X.W. and Y.L. (Ying Li); validation, A.T., X.W. and Y.L. (Yanchun Liang); formal analysis, X.W. and A.T.; investigation, X.W.; resources, M.L.; data curation, X.W. and Y.L. (Ying Li); writing—original draft preparation, X.W.; writing—review and editing, M.L., A.T., W.H. and Y.L. (Yanchun Liang); visualization, X.W. and W.H.; supervision, Y.L. (Yanchun Liang); project administration, Y.L. (Ying Li). All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded in part by the National Natural Science Foundation of China (62372494), Guangdong Teaching Quality Projects (2025003), Guangdong Specialized Talent Training Program (2024001), Guangdong Engineering Centre (2024GCZX001), 2023 Zhuhai College of Science and Technology Campus Teaching Quality Engineering Construction Project (ZLGC20230213).

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

Data shall be provided by the corresponding author upon special request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Zhu, M.; Wang, J.; Yang, X.; Zhang, Y.; Zhang, L.; Ren, H.; Wu, B.; Ye, L. A review of the application of machine learning in water quality evaluation. Eco-Environ. Health 2022, 1, 107–116. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  2. Zhi, W.; Feng, D.; Tsai, W.P.; Sterle, G.; Harpold, A.; Shen, C.; Li, L. From hydrometeorology to river water quality: Can a deep learning model predict dissolved oxygen at the continental scale? Environ. Sci. Technol. 2021, 55, 2357–2368. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  3. Wang, S.; Peng, H.; Liang, S. Prediction of estuarine water quality using interpretable machine learning approach. J. Hydrol. 2022, 605, 127320. [Google Scholar] [CrossRef] [Scilit]
  4. Zainurin, S.N.; Wan Ismail, W.Z.; Mahamud, S.N.I.; Ismail, I.; Jamaludin, J.; Ariffin, K.N.Z.; Wan Ahmad Kamil, W.M. Advancements in monitoring water quality based on various sensing methods: A systematic review. Int. J. Environ. Res. Public Health 2022, 19, 14080. [Google Scholar] [CrossRef] [Scilit]
  5. Jung, W.S.; Kim, S.E.; Kim, Y.D. Prediction of surface water quality by artificial neural network model using probabilistic weather forecasting. Water 2021, 13, 2392. [Google Scholar] [CrossRef] [Scilit]
  6. Omambia, A.; Maake, B.; Wambua, A. Water quality monitoring using IoT & machine learning. In 2022 IST-Africa Conference (IST-Africa); IEEE: Piscataway, NJ, USA, 2022; pp. 1–8. [Google Scholar]
  7. Bai, X.; Wang, J.; Chen, R.; Kang, Y.; Ding, Y.; Lv, Z.; Ding, D.; Feng, H. Research progress of inland river water quality monitoring technology based on unmanned aerial vehicle hyperspectral imaging technology. Environ. Res. 2024, 257, 119254. [Google Scholar] [CrossRef] [Scilit]
  8. Sun, Y.; Wang, D.; Li, L.; Ning, R.; Yu, S.; Gao, N. Application of remote sensing technology in water quality monitoring: From traditional approaches to artificial intelligence. Water Res. 2024, 267, 122546. [Google Scholar] [CrossRef] [Scilit]
  9. De Lacerda, M.; Batista, G.; De Souza, A.; Aragão, D.; de Araújo, M.C.; Cunha, P. Predicting the presence of total coliforms and Escherichia coli in water supply reservoirs using machine learning models. J. Water Process Eng. 2025, 76, 108146. [Google Scholar] [CrossRef] [Scilit]
  10. Chen, Y.; Song, L.; Liu, Y.; Yang, L.; Li, D. A review of the artificial neural network models for water quality prediction. Appl. Sci. 2020, 10, 5776. [Google Scholar] [CrossRef] [Scilit]
  11. Yan, X.; Zhang, T.; Du, W.; Meng, Q.; Xu, X.; Zhao, X. A comprehensive review of machine learning for water quality prediction over the past five years. J. Mar. Sci. Eng. 2024, 12, 159. [Google Scholar] [CrossRef] [Scilit]
  12. Jiang, Y.; Li, C.; Song, H.; Wang, W. Deep learning model based on urban multi-source data for predicting heavy metals (Cu, Zn, Ni, Cr) in industrial sewer networks. J. Hazard. Mater. 2022, 432, 128732. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  13. Mohammed, H.; Hameed, I.A.; Seidu, R. Comparison of adaptive neuro-fuzzy inference system (ANFIS) and Gaussian process for machine learning (GPML) algorithms for the prediction of norovirus concentration in drinking water supply. In Transactions on Large-Scale Data-and Knowledge-Centered Systems XXXV; Springer: Berlin/Heidelberg, Germany, 2017; pp. 74–95. [Google Scholar]
  14. Brentan, B.M.; Luvizotto, E., Jr.; Herrera, M.; Izquierdo, J.; Pérez-García, R. Hybrid regression model for near real-time urban water demand forecasting. J. Comput. Appl. Math. 2017, 309, 532–541. [Google Scholar] [CrossRef] [Scilit]
  15. Chou, J.S.; Ho, C.C.; Hoang, H.S. Determining quality of water in reservoir using machine learning. Ecol. Inform. 2018, 44, 57–75. [Google Scholar] [CrossRef] [Scilit]
  16. Acharya, T.D.; Subedi, A.; Lee, D.H. Evaluation of machine learning algorithms for surface water extraction in a Landsat 8 scene of Nepal. Sensors 2019, 19, 2769. [Google Scholar] [CrossRef] [Scilit]
  17. Emrullah, A.; Ozerdem, M.S.; Ustundag, B.B. Machine learning based regression model for prediction of soil surface humidity over moderately vegetated fields. In 2019 8th International Conference on Agro-Geoinformatics (Agro-Geoinformatics); IEEE: Piscataway, NJ, USA, 2019; pp. 1–4. [Google Scholar]
  18. Richman, J.S.; Moorman, J.R. Physiological time-series analysis using approximate entropy and sample entropy. Am. J. Physiol.-Heart Circ. Physiol. 2000, 278, H2039–H2049. [Google Scholar] [CrossRef] [Scilit]
  19. Deng, C.; Liu, L.; Li, H.; Peng, D.; Wu, Y.; Xia, H.; Zhang, Z.; Zhu, Q. A data-driven framework for spatiotemporal characteristics, complexity dynamics, and environmental risk evaluation of river water quality. Sci. Total Environ. 2021, 785, 147134. [Google Scholar] [CrossRef] [Scilit]
  20. Yang, H.; Liu, S. A prediction model of aquaculture water quality based on multiscale decomposition. Math. Biosci. Eng. 2021, 18, 7561–7579. [Google Scholar] [CrossRef] [Scilit]
  21. Farhi, N.; Kohen, E.; Mamane, H.; Shavitt, Y. Prediction of wastewater treatment quality using LSTM neural network. Environ. Technol. Innov. 2021, 23, 101632. [Google Scholar] [CrossRef] [Scilit]
  22. Malakar, P.; Sarkar, S.; Mukherjee, A.; Bhanja, S.; Sun, A.Y. Use of machine learning and deep learning methods in groundwater. In Global Groundwater; Elsevier: Amsterdam, The Netherlands, 2021; pp. 545–557. [Google Scholar]
  23. Li, Y.; Kong, B.; Yu, W.; Zhu, X. An attention-based CNN-LSTM method for effluent wastewater quality prediction. Appl. Sci. 2023, 13, 7011. [Google Scholar] [CrossRef] [Scilit]
  24. Zhao, S.; Liu, R.; Liu, Y.; Zeng, T.; Chen, C.; Xu, L. A water quality prediction model based on modal decomposition and hybrid deep learning models. Water 2025, 17, 184. [Google Scholar] [CrossRef] [Scilit]
  25. Bai, Y.; Peng, M.; Wang, M. A River Water Quality Prediction Method Based on Dual Signal Decomposition and Deep Learning. Water 2024, 16, 3099. [Google Scholar] [CrossRef] [Scilit]
  26. Wei, G.; Duan, Z.; Li, S.; Yu, X.; Yang, G. LFEformer: Local feature enhancement using sliding window with deformability for automatic speech recognition. IEEE Signal Process. Lett. 2023, 30, 180–184. [Google Scholar] [CrossRef] [Scilit]
  27. Gaur, P.; Gupta, H.; Chowdhury, A.; McCreadie, K.; Pachori, R.B.; Wang, H. A sliding window common spatial pattern for enhancing motor imagery classification in EEG-BCI. IEEE Trans. Instrum. Meas. 2021, 70, 1–9. [Google Scholar] [CrossRef] [Scilit]
  28. Kulanuwat, L.; Chantrapornchai, C.; Maleewong, M.; Wongchaisuwat, P.; Wimala, S.; Sarinnapakorn, K.; Boonya-Aroonnet, S. Anomaly detection using a sliding window technique and data imputation with machine learning for hydrological time series. Water 2021, 13, 1862. [Google Scholar] [CrossRef] [Scilit]
  29. Du, Z.; Qi, J.; Wu, S.; Zhang, F.; Liu, R. A spatially weighted neural network based water quality assessment method for large-scale coastal areas. Environ. Sci. Technol. 2021, 55, 2553–2563. [Google Scholar] [CrossRef] [Scilit]
  30. Rostam, N.A.P.; Malim, N.H.A.H.; Abdullah, R.; Ahmad, A.L.; Ooi, B.S.; Chan, D.J.C. A complete proposed framework for coastal water quality monitoring system with algae predictive model. IEEE Access 2021, 9, 108249–108265. [Google Scholar] [CrossRef] [Scilit]
  31. Menghani, G. Efficient deep learning: A survey on making deep learning models smaller, faster, and better. ACM Comput. Surv. 2023, 55, 1–37. [Google Scholar] [CrossRef] [Scilit]
  32. Guo, H.; Zhu, X.; Huang, J.J.; Zhang, Z.; Tian, S.; Chen, Y. An enhanced deep learning approach to assessing inland lake water quality and its response to climate and anthropogenic factors. J. Hydrol. 2023, 620, 129466. [Google Scholar] [CrossRef] [Scilit]
  33. Wang, L.; Han, G.; Zhang, L. Experimental Analysis of Sluice Operation in Qianshan River Basin in Zhuhai City. Pearl River 2016, 37, 20–23. [Google Scholar]
  34. Wang, Y.; Zhang, Y.; Guo, Q.; Kang, W.; Sun, H.; Liu, F.; Li, T. Design of Qianshan Wastewater Treatment Plant with Underground MBR Process in Zhuhai City. China Water Wastewater 2018, 34, 59–62. [Google Scholar]
  35. Wang, X.; Li, Y.; Qiao, Q.; Tavares, A.; Liang, Y. Water Quality Prediction Based on Machine Learning and Comprehensive Weighting Methods. Entropy 2023, 25, 1186. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  36. Wang, X.; Qiao, M.; Li, Y.; Tavares, A.; Qiao, Q.; Liang, Y. Deep-learning-based water quality monitoring and early warning methods: A case study of ammonia nitrogen prediction in rivers. Electronics 2023, 12, 4645. [Google Scholar] [CrossRef] [Scilit]
  37. Zhang, Y.; Li, C.; Jiang, Y.; Sun, L.; Zhao, R.; Yan, K.; Wang, W. Accurate prediction of water quality in urban drainage network with integrated EMD-LSTM model. J. Clean. Prod. 2022, 354, 131724. [Google Scholar] [CrossRef] [Scilit]
  38. Bhattarai, A.; Qadir, D.; Sunusi, A.M.; Getachew, B.; Mallah, A.R. Dynamic sliding window-based long short-term memory model development for pan evaporation forecasting. Knowl.-Based Eng. Sci. 2023, 4, 37–54. [Google Scholar]
  39. Greenacre, M.; Groenen, P.J.; Hastie, T.; d’Enza, A.I.; Markos, A.; Tuzhilina, E. Principal component analysis. Nat. Rev. Methods Prim. 2022, 2, 100. [Google Scholar] [CrossRef] [Scilit]
  40. Perea, R.G.; García, I.F.; Poyato, E.C.; Díaz, J.R. New memory-based hybrid model for middle-term water demand forecasting in irrigated areas. Agric. Water Manag. 2023, 284, 108367. [Google Scholar] [CrossRef] [Scilit]
  41. Kherif, F.; Latypova, A. Principal component analysis. In Machine Learning; Elsevier: Amsterdam, The Netherlands, 2020; pp. 209–225. [Google Scholar]
  42. Karpagalakshmi, R.C.; Selvam, P.; Sakthivel, S.; Kalaivanan, K.; Rajesh, S.R.; Sungheetha, A.; Mahapatra, S. Analysis of Water Quality in Cauvery River by Using PCA with Various Classifications Technique. Procedia Comput. Sci. 2025, 258, 1391–1403. [Google Scholar] [CrossRef] [Scilit]
  43. Roy, B.N.; Roy, H.; Rahman, K.S.; Mahmud, F.; Bhuiyan, M.M.K.; Hasan, M.; Bhuiyan, A.A.K.; Hasan, M.; Mahbub, M.S.; Jahedi, R.M. Principal component analysis incorporated water quality index modeling for Dhaka-based rivers. City Environ. Interact. 2024, 23, 100150. [Google Scholar]
  44. Yang, S.; Yu, X.; Zhou, Y. Lstm and gru neural network performance comparison study: Taking yelp review dataset as an example. In 2020 International Workshop on Electronic Communication and Artificial Intelligence (IWECAI); IEEE: Piscataway, NJ, USA, 2020; pp. 98–101. [Google Scholar]
  45. Wan, H.; Qi, H.; Shang, S. Estimating soil water and salt contents from field measurements with time domain reflectometry using machine learning algorithms. Agric. Water Manag. 2023, 285, 108364. [Google Scholar] [CrossRef] [Scilit]
  46. Wang, Y.; Shi, W.; Wen, T. Prediction of winter wheat yield and dry matter in North China Plain using machine learning algorithms for optimal water and nitrogen application. Agric. Water Manag. 2023, 277, 108140. [Google Scholar] [CrossRef] [Scilit]
  47. Smith, R.X.; Yan, L.; Wang, D.J. Multiple time scale complexity analysis of resting state FMRI. Brain Imaging Behav. 2014, 8, 284–291. [Google Scholar] [CrossRef] [Scilit]
  48. Olbryś, J.; Majewska, E. Regularity in stock market indices within turbulence periods: The sample entropy approach. Entropy 2022, 24, 921. [Google Scholar] [CrossRef] [Scilit]
  49. GB 11607-89; Water Quality Standard for Fisheries. Ministry of Environmental Protection of the People’s Republic of China: Beijing, China, 1989.
  50. GB 3838-2002; Environmental Quality Standards for Surface Water. Ministry of Environmental Protection of the People’s Republic of China: Beijing, China, 2002.
Figure 1. Regional location of the water quality monitoring station.
Figure 1. Regional location of the water quality monitoring station.
Entropy 28 00186 g001
Figure 2. Workflow of the sliding window feature enhancement method.
Figure 2. Workflow of the sliding window feature enhancement method.
Entropy 28 00186 g002
Figure 3. Flowchart of the water quality prediction system integrating sliding window feature enhancement and the TLR-GRU model.
Figure 3. Flowchart of the water quality prediction system integrating sliding window feature enhancement and the TLR-GRU model.
Entropy 28 00186 g003
Figure 4. Comparison of Sample Entropy (SampEn) for Basic_data and Sliding Window_data. (a) Boxplot showing median and interquartile range differences; (b) CDF curves indicating cumulative probability of low SampEn values.
Figure 4. Comparison of Sample Entropy (SampEn) for Basic_data and Sliding Window_data. (a) Boxplot showing median and interquartile range differences; (b) CDF curves indicating cumulative probability of low SampEn values.
Entropy 28 00186 g004
Figure 5. Sample entropy comparison for key water quality parameters between Basic_data and Sliding Window_data. (a) DO SampEn Comparison. (b) NH 3 -N SampEn Comparison. (c) TN SampEn Comparison. (d) TP SampEn Comparison.
Figure 5. Sample entropy comparison for key water quality parameters between Basic_data and Sliding Window_data. (a) DO SampEn Comparison. (b) NH 3 -N SampEn Comparison. (c) TN SampEn Comparison. (d) TP SampEn Comparison.
Entropy 28 00186 g005
Figure 6. Multi-scale complexity regulation by sliding windows: distribution, trend, and relationship of sample entropy by window duration and statistic type. (a) Distribution of SampEn by window duration and statistic type. (b) Effect of sliding window durations on SampEn. (c) Relationship between window duration, statistic type and SampEn. (d) Trend of SampEn by window duration and statistic type.
Figure 6. Multi-scale complexity regulation by sliding windows: distribution, trend, and relationship of sample entropy by window duration and statistic type. (a) Distribution of SampEn by window duration and statistic type. (b) Effect of sliding window durations on SampEn. (c) Relationship between window duration, statistic type and SampEn. (d) Trend of SampEn by window duration and statistic type.
Entropy 28 00186 g006
Figure 7. Time series fluctuation curves of water quality parameters. Each subfigure presents the temporal variation in one parameter during the study period (January 2020–December 2023).
Figure 7. Time series fluctuation curves of water quality parameters. Each subfigure presents the temporal variation in one parameter during the study period (January 2020–December 2023).
Entropy 28 00186 g007
Figure 8. Comparison of evaluation metrics between training and testing sets for various models.
Figure 8. Comparison of evaluation metrics between training and testing sets for various models.
Entropy 28 00186 g008aEntropy 28 00186 g008b
Figure 9. Training and validation scatter plot of TLR-GRU model.
Figure 9. Training and validation scatter plot of TLR-GRU model.
Entropy 28 00186 g009aEntropy 28 00186 g009b
Figure 10. Prediction curves of water quality parameters by different models.
Figure 10. Prediction curves of water quality parameters by different models.
Entropy 28 00186 g010aEntropy 28 00186 g010b
Table 1. Pearson Correlation coefficients between sample entropy (SampEn) and TLR-GRU layer outputs.
Table 1. Pearson Correlation coefficients between sample entropy (SampEn) and TLR-GRU layer outputs.
Model LayerPearson Correlation Coefficient (r)p-ValueSignificance
Input Layer0.82 2.3 × 10 15 p < 0.001
First Hidden Layer0.56 4.7 × 10 8 p < 0.001
Second Hidden Layer0.31 3.2 × 10 3 p < 0.01
Output Layer0.120.18Non-significant
Note: Correlations are based on 746 test set samples (15% of total data). Significance is determined via two-tailed t-test.
Table 2. Summary statistics of basic water quality data.
Table 2. Summary statistics of basic water quality data.
ParameterUnitMinMaxMeanMedianStd Dev
Temp°C2.7529.0518.6318.826.37
pHN/A6.568.697.577.580.24
DOmg/L2.0112.348.148.201.61
CODMnmg/L0.568.123.143.051.38
NH 3 -Nmg/L0.011.250.230.200.18
TPmg/L0.010.450.110.100.07
TNmg/L0.314.571.681.570.74
Cond μ S / cm 5613,856204217901367
TurbNTU0.113311.786.1015.45
Note: min = minimum; max = maximum; mean = arithmetic mean; median = 50th percentile; std dev = standard deviation.
Table 3. Water quality standards for key parameters in aquaculture and irrigation contexts.
Table 3. Water quality standards for key parameters in aquaculture and irrigation contexts.
ParameterStandard SourceClassLimit (mg/L)Note
DOFishery (GB 11607-89) [49]≥5.0Mandatory for aquaculture.
Surface Water (GB 3838-2002) [50]II≥6.0Reference for irrigation.
NH3-NFishery (GB 11607-89)≤0.5Mandatory for aquaculture.
Surface Water (GB 3838-2002)II≤0.5Reference for irrigation.
TPSurface Water-Lake (GB 3838-2002)II≤0.025For aquaculture. & high-sensitivity irrigation.
Surface Water-Lake (GB 3838-2002)III≤0.05Baseline for general irrigation.
TNSurface Water-Lake (GB 3838-2002)II≤0.5For aquaculture. & high-sensitivity irrigation.
Surface Water-Lake (GB 3838-2002)III≤1.0Baseline for general irrigation.
Note: The primary sources for the fishery and surface water standards are the Chinese national standards: Fishery water quality standard (GB 11607-89) and Environmental quality standards for surface water (GB 3838-2002), which are accessible for reference or download from the official website of the Ministry of Ecology and Environment of the People’s Republic of China.
Table 4. Performance evaluation of different models on training and testing sets under the base data.
Table 4. Performance evaluation of different models on training and testing sets under the base data.
ModelsWQPTraining SetTest Set
R 2 RMSEMAEMAPE R 2 RMSEMAEMAPE
TLR-GRUDO0.9330.3110.2403.2360.8260.4140.3284.779
NH3-N0.9570.0200.01517.2930.9620.0230.01819.203
TN0.9400.0620.0462.2780.9060.0720.0572.496
TP0.7770.0090.00711.9020.8100.0100.0079.438
TLD-LSTMDO0.9280.3190.2373.1860.8300.4080.3204.685
NH3-N0.9480.0220.01621.5720.9470.0280.02118.398
TN0.9470.0580.0422.0420.9150.0690.0532.357
TP0.7960.0090.00610.1200.7490.0110.00810.345
TLD-TransformerDO0.8540.4570.3464.6820.7330.5110.4015.890
NH3-N0.8590.0360.02736.5720.7940.0540.04141.970
TN0.9080.0760.0582.8870.7150.1250.0944.090
TP0.6960.0110.00811.7180.4590.0170.01112.238
DeepARDO0.8360.4840.3704.9840.7100.5340.4246.109
NH3-N0.9040.0300.02329.3470.9060.0370.02829.162
TN0.9400.0620.0472.3170.9020.0740.0582.573
TP0.6800.0110.00811.7530.7030.0120.00911.505
Bi_TLD-LSTMDO0.9280.3400.2523.3930.8520.3820.3044.421
NH3-N0.9360.0260.01922.3560.9230.0330.02522.478
TN0.9430.0620.0452.1960.8900.0780.0612.687
TP0.8100.0090.0069.9290.6980.0130.00911.644
WaveNetDO0.9580.2860.2192.9430.8140.4280.3414.961
NH3-N0.9680.0180.01419.3730.9510.0270.02020.251
TN0.9690.0460.0351.7580.9200.0670.0532.326
TP0.8670.0080.0069.1520.7420.0120.00810.306
CNNDO0.9480.2720.2052.7160.8170.4220.3284.749
NH3-N0.9610.0190.01414.0420.9070.0370.02621.354
TN0.9520.0550.0432.1190.8340.0960.0753.242
TP0.9110.0060.0047.1560.4870.0160.01011.981
Note: WQP = water quality parameter; DO = dissolved oxygen; NH3-N = ammonia nitrogen; TN = total nitrogen; TP = total phosphorus. Metrics: R 2 = coefficient of determination; RMSE = root mean square error; MAE = mean absolute error; MAPE = mean absolute percentage error.
Table 5. Performance evaluation of different models on training and testing sets under the sliding window features data.
Table 5. Performance evaluation of different models on training and testing sets under the sliding window features data.
ModelsWQPTraining SetTest Set
R 2 RMSEMAEMAPE R 2 RMSEMAEMAPE
TLR-GRUDO0.9620.2320.1652.1710.9550.2100.1662.331
NH3-N0.9660.0180.01315.9170.9600.0240.01817.361
TN0.9460.0590.0442.1890.9130.0690.0552.441
TP0.9190.0050.0045.5460.9480.0050.0044.350
TLD-LSTMDO0.9490.2690.1942.5930.8930.3230.2543.640
NH3-N0.9440.0230.01620.1140.7990.0540.04031.001
TN0.9320.0660.0492.4380.7620.1140.0883.847
TP0.9150.0060.0046.0390.8340.0090.0066.659
TLD-TransformerDO0.9530.2590.1972.6690.8450.3900.3064.335
NH3-N0.9750.0150.01115.9640.7390.0610.04440.420
TN0.9360.0640.0492.4690.7040.1280.0984.359
TP0.9250.0050.0046.3120.7140.0120.0089.163
DeepARDO0.9680.2140.1511.9950.9700.1720.1341.891
NH3-N0.9520.0210.01517.3560.9460.0280.02018.173
TN0.9490.0570.0442.1640.9110.0700.0552.440
TP0.9150.0060.0045.6300.9250.0060.0045.348
Bi_TLD-LSTMDO0.9550.2550.1812.4200.9230.2740.2122.984
NH3-N0.9480.0220.01617.8890.8560.0460.03427.964
TN0.9300.0670.0502.4690.7280.1230.0944.093
TP0.9020.0060.0046.4150.7520.0110.0077.660
WaveNetDO0.9770.1800.1371.8600.9050.3020.2373.357
NH3-N0.9890.0100.00810.7230.9230.0330.02523.949
TN0.9790.0360.0281.4080.8290.0970.0743.277
TP0.9670.0030.0034.2170.8500.0090.0066.706
CNNDO0.9490.2690.2082.7390.8540.3770.2954.144
NH3-N0.9580.0200.01517.2760.8600.0450.03431.483
TN0.9280.0670.0532.6270.6600.1370.1074.616
TP0.9360.0050.0046.1550.7450.0120.0078.026
Note: This table presents model performance using sliding window features. WQP abbreviations as in Table 4. Performance metrics include R 2 (coefficient of determination), RMSE (root mean square error), MAE (mean absolute error), and MAPE (mean absolute percentage error).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Wang, X.; Liu, M.; Li, Y.; Tavares, A.; Huang, W.; Liang, Y. Application of the Two-Layer Regularized Gated Recurrent Unit (TLR-GRU) Model Enhanced by Sliding Window Features in Water Quality Parameter Prediction. Entropy 2026, 28, 186. https://doi.org/10.3390/e28020186

AMA Style

Wang X, Liu M, Li Y, Tavares A, Huang W, Liang Y. Application of the Two-Layer Regularized Gated Recurrent Unit (TLR-GRU) Model Enhanced by Sliding Window Features in Water Quality Parameter Prediction. Entropy. 2026; 28(2):186. https://doi.org/10.3390/e28020186

Chicago/Turabian Style

Wang, Xianhe, Meiqi Liu, Ying Li, Adriano Tavares, Weidong Huang, and Yanchun Liang. 2026. "Application of the Two-Layer Regularized Gated Recurrent Unit (TLR-GRU) Model Enhanced by Sliding Window Features in Water Quality Parameter Prediction" Entropy 28, no. 2: 186. https://doi.org/10.3390/e28020186

APA Style

Wang, X., Liu, M., Li, Y., Tavares, A., Huang, W., & Liang, Y. (2026). Application of the Two-Layer Regularized Gated Recurrent Unit (TLR-GRU) Model Enhanced by Sliding Window Features in Water Quality Parameter Prediction. Entropy, 28(2), 186. https://doi.org/10.3390/e28020186

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop