A Hybrid Deep Learning-Based Method for Predicting Estuary Water Quality Based on Particle Swarm Optimization

By employing a hybrid deep learning approach based on particle swarm optimization, combining TCN, LSTM, and CBAM, the accuracy and efficiency issues of existing water quality prediction methods in complex water quality prediction were addressed, enabling efficient and accurate prediction of water quality parameters at sea outlets.

CN119940089BActive Publication Date: 2025-10-31SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411909479.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-10-31
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

Existing water quality prediction methods suffer from insufficient prediction accuracy, low computational efficiency, poor robustness, and high computational cost when dealing with complex and dynamically changing water quality issues, making it difficult to meet the needs of practical applications.

Method used

A hybrid deep learning approach based on particle swarm optimization is adopted, combining temporal convolutional network (TCN), long short-term memory neural network (LSTM) and convolutional block attention network (CBAM). Hyperparameters are optimized through particle swarm optimization algorithm to construct a water quality prediction model, capture short-term and long-term time series trends, and achieve accurate prediction of water quality parameters at the estuary.

Benefits of technology

It enhances time series modeling capabilities, improves prediction accuracy and stability, is applicable to various water quality change scenarios, reduces computational complexity and resource consumption, and is suitable for different aquatic environments and monitoring indicator systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940089B_ABST
    Figure CN119940089B_ABST
Patent Text Reader

Abstract

This invention discloses a hybrid deep learning method for predicting estuarine water quality based on particle swarm optimization. First, time-series data is obtained through data preprocessing, and correlation analysis is performed to screen water quality indicators and reduce data noise. Then, a hybrid deep learning approach is used, combining the advantages of TCN, LSTM, and CBAM networks to construct a water quality prediction model. Subsequently, the model is trained using time-series data. TCN effectively captures long-term dependencies in the sequence data, LSTM enhances the processing capacity of long-term memory to capture complex time-dependent patterns in the water quality data, and CBAM introduces an attention mechanism to adaptively select important features, optimizing the accuracy of water quality prediction and improving prediction precision and stability. This application demonstrates higher accuracy for both routine monitoring and prediction of water quality indicators and early warning prediction of sudden water quality changes under special events, meeting diverse practical application needs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of water pollution control, specifically relating to a hybrid deep learning method for predicting estuarine water quality based on particle swarm optimization. Background Technology

[0002] Accurate and scientific prediction of estuary water quality, especially precise control over the water quality at river inflow sections, is crucial for early warning of water pollution incidents and potential pollution risks. It enables a shift from post-incident treatment to pre-incident prevention and control of water pollution, providing strong technical and decision-making support to environmental protection departments and improving their treatment efficiency. Existing water quality prediction methods include traditional statistical analysis, machine learning-based methods, and deep learning-based methods.

[0003] Among them, traditional statistical analysis methods for water quality prediction were the earliest to be applied to water quality prediction. These include multiple linear regression, nonlinear regression, and time series analysis. Based on historical water quality data, these methods establish mathematical models to describe the patterns of water quality indicators changing over time or space, thereby achieving water quality prediction. For example, Yan Jianbo et al. ("Yan Jianbo, Ruan Xiaohong, Sun Han. Application of Multiple Regression Analysis in Water Quality Prediction of the Yellow River [J]. People's Yellow River, 2010, 32(03):35-36.") applied the multiple linear regression (MLR) method to predict the COD concentration in the Tongguan to Sanmenxia section of the Yellow River main stream, achieving good results with a limited sample size. Wu et al. ("Wu J, Zhang J, Tan W, et al. Application of time serial model in water quality predicting[J]. Comput. Mater. Contin,2023, 74: 67-82.") proposed a water quality prediction method combining the Autoregressive Moving Average (ARIMA) model and the K-means clustering model. Using total phosphorus (TP) data from a watershed as a sample, ARIMA was used to predict trends, while K-means was used to analyze the relationship between precipitation and TP. The combination of the two methods improved prediction accuracy. Although traditional statistical analysis methods have achieved certain results in some water quality prediction tasks, their strong dependence on data, limitations in model assumptions, and insufficient ability to capture nonlinear dynamic relationships may limit their effectiveness when dealing with complex and dynamically changing water quality problems. Therefore, in practical applications, it is often necessary to combine more advanced machine learning and data mining methods to improve the accuracy and reliability of water quality prediction.

[0004] With the development of computer technology, machine learning methods, such as Support Vector Machine (SVM), Artificial Neural Network (ANN), Random Forest (RF), and Gradient Boosting Tree (GDBT), have been increasingly applied to the field of water quality prediction due to their powerful data processing and pattern recognition capabilities. They are better able to capture the nonlinear relationships and potential characteristics in water quality changes, thus outperforming traditional statistical analysis methods in terms of prediction accuracy. For example, Haghiabi et al. (Haghiabi AH, Nasrolahi AH, Parsaie A. Water quality prediction using machine learning methods[J]. Water Quality Research Journal, 2018, 53(1): 3-13.) applied three machine learning techniques, ANN, GMDH, and SVM, to predict the water quality of the Tire River in southwestern Iran. The results showed that SVM had a greater predictive performance compared to the other two methods. However, while machine learning models can effectively predict water quality for simple data with clear variable relationships, their limitations become apparent when dealing with more complex sequence data that exhibits nonlinear characteristics and is influenced by multiple factors. Because sequence data contains a large number of interaction effects and latent variables that are difficult to capture intuitively, the model struggles to accurately capture the inherent patterns and trends of the data, thus affecting the detection results and performance of water quality prediction.

[0005] In recent years, with the rapid development of artificial intelligence, deep learning has been increasingly applied to the field of water quality monitoring. By constructing deep networks, such as convolutional neural networks (CNN), recurrent neural networks (RNN), and their variant Long Short-Term Memory networks (LSTM), it can automatically extract useful features from raw data, learn high-dimensional feature representations in the data, and capture complex nonlinear relationships and long-term dependencies, thereby improving the accuracy and robustness of predictions. For example, the research by Qiu et al. (Qiu R, Wang Y, Rhoads B, et al. River water temperature forecasting using a deep learning method[J]. Journal of Hydrology, 2021, 595: 126016.) shows that the LSTM model performs excellently in predicting daily river water temperature, more accurately capturing the daily variations in river water thermal state, providing strong support for river water temperature prediction and ecological management. Furthermore, deep learning hybrid models, by combining the advantages of multiple machine learning algorithms or deep learning algorithms, can more comprehensively analyze the complex relationships in water quality data, thereby achieving accurate predictions of water quality indicators. For example, Wang et al. ("Wang Z, Duan L, Shuai D, et al. Research on water environment indicators prediction method based on EEMD decomposition with CNN-BiLSTM[J]. Scientific Reports, 2024, 14(1): 1676.") proposed a hybrid water quality index prediction model based on CNN-BiLSTM, which, combined with Empirical Mode Decomposition (EEMD), effectively reduces noise and improves prediction performance. In addition, attention mechanisms have become a research hotspot in the field of deep learning in recent years. Originally proposed based on the Transformer architecture and applied to natural language processing, attention mechanisms, when applied to water quality prediction, can effectively improve prediction accuracy. For example, Xie Zaimi et al. ("Xie Zaimi, Wang Ji, Mo Chunmei. Constructing a three-dimensional prediction model of seawater quality by fusing IFWA-optimized BLSTM and transformer [J]. Transactions of the Chinese Society of Agricultural Engineering, 2023, 39(04): 162-170.") fused the Transformer architecture with BiLSTM to effectively extract and integrate key features of water quality data and accurately predict the changing trends of aquaculture water quality parameters in marine areas.Existing deep learning models generally face several common shortcomings: First, many models tend to suffer from low computational efficiency when processing long-term or complex time-series data, especially consuming significant resources during training. Furthermore, while some models can capture local features or long-term dependencies, they have limitations in capturing global dependencies and multi-scale information, preventing a comprehensive improvement in prediction accuracy. Second, these models are poorly robust to noise and outliers, potentially exhibiting instability with poor data quality or abnormal fluctuations, affecting the reliability of prediction results. Finally, the models are typically complex and computationally intensive, requiring long training times and hindering efficient application on large-scale datasets. In conclusion, existing methods still have room for improvement in prediction accuracy, computational efficiency, and robustness, necessitating more efficient and adaptive models to handle complex water quality prediction tasks. Summary of the Invention

[0006] The main objective of this invention is to overcome the shortcomings and deficiencies of the prior art and provide a hybrid deep learning method for predicting estuary water quality based on particle swarm optimization. This method uses a hybrid deep learning approach to learn and extract data relationships through a multi-layer network, capture short-term and long-term time series trends, and achieve accurate prediction of estuary water quality parameters.

[0007] To achieve the above objectives, the present invention provides a hybrid deep learning method for predicting estuarine water quality based on particle swarm optimization, comprising the following steps:

[0008] The raw water quality data of the estuary containing multiple water quality indicators were obtained in chronological order, and a time series dataset was obtained through data preprocessing.

[0009] Using dissolved oxygen as the target water quality indicator, the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series dataset is calculated, and the time series data of water quality indicators with a Pearson correlation coefficient greater than the set standard threshold are retained as the dataset to be used.

[0010] Construct a water quality prediction model, including a temporal convolutional network, a long short-term memory neural network, a convolutional block attention network, and an output network;

[0011] Initialize the water quality prediction model, and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the water quality prediction model with the optimal hyperparameters.

[0012] The dataset to be used is divided into training set, validation set and test set according to the proportion;

[0013] The optimal hyperparameter water quality prediction model is trained and validated using the training and validation sets to obtain the trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation metrics to obtain the final water quality prediction model.

[0014] The water quality data to be tested is input into the final water quality prediction model to obtain the prediction results.

[0015] As a preferred technical solution, the water quality indicators include water temperature, dissolved oxygen, pH, conductivity, turbidity, total nitrogen, ammonia nitrogen, permanganate index, and total phosphorus.

[0016] As a preferred technical solution, the step of obtaining time series data through data preprocessing specifically includes:

[0017] Outliers in the original water quality data are removed according to the 3σ principle, where σ represents the standard deviation of the original water quality data.

[0018] After outlier removal, linear interpolation was used to fill in the missing values ​​in the original water quality data.

[0019] After filling, the original water quality data is scaled to between 0 and 1 using the max-min normalization method;

[0020] A sliding window is applied to progressively slide across the scaled original water quality data, dividing the original water quality data into multiple continuous, fixed-length time series data to obtain a time series dataset.

[0021] As a preferred technical solution, the hyperparameters of the water quality prediction model include the number of hidden layer neurons, the number of hidden layers, the learning rate and the loss rate of the long short-term memory neural network, and the number of hidden layer channels of the temporal convolutional network.

[0022] As a preferred technical solution, the step of using particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model specifically involves:

[0023] Randomly initialize the particle swarm, particle velocity, and particle position;

[0024] Calculate the fitness value of each particle in the particle swarm, and record the best individual particle and the best global particle;

[0025] Adjust the particle velocity and particle position according to the velocity update formula and the position update formula;

[0026] Check if the stopping condition is met. If it is, end the particle swarm optimization algorithm. Otherwise, continue iteratively calculating the fitness value of each particle after the update and updating the particle velocity and particle position until the stopping condition is met.

[0027] As a preferred technical solution, the speed update formula is:

[0028] v i,d ( t +1) = ωv i,d ( t ) + c 1 r 1( pBest i,d - x i,d ( t )) + c 2 r 2( gBest d - x i,d ( t )),

[0029] in, v i,d ( t +1) is the first t In the nth iteration i A particle in d The speed after the update v i,d ( t ) is the first t In the nth iteration i A particle in d The speed before the maintenance update ω For inertial weights, c 1. c 2 is the learning factor. r 1. r 2 is a random number that follows a uniform distribution in the interval [0,1]. x i,d ( t ) is the first t In the nth iteration i A particle in d The location before the maintenance update pBest i,d For the first i A particle in d The optimal position of the dimension. gBest d For all particles in d The position of the particle with optimal dimensional fitness;

[0030] The position update formula is:

[0031] 𝑥 𝑖,d (𝑡+1)=𝑥 𝑖,d (𝑡)+𝑣 𝑖,d (𝑡+1),

[0032] Among them, 𝑥 𝑖,d (𝑡+1) is the first t In the nth iteration i A particle in d The updated position.

[0033] As a preferred technical solution, training the water quality prediction model with optimal hyperparameters specifically involves:

[0034] The training set is input into a temporal convolutional network for convolution operations to extract local and global temporal features.

[0035] Local and global temporal features are passed to a long short-term memory neural network to capture long-term dependency features;

[0036] The convolutional block attention network is used to calculate the channel and spatial attention weights for long-term dependent features, and the long-term dependent features are weighted to highlight important feature channels and temporal positions, resulting in weighted features.

[0037] The weighted features are processed using an output network to obtain the prediction results.

[0038] As a preferred technical solution, the evaluation indicators include root mean square error, mean absolute error, mean absolute percentage error, and goodness of fit.

[0039] On the other hand, a hybrid deep learning estuary water quality prediction system based on particle swarm optimization is provided, which is applied to the above-mentioned hybrid deep learning estuary water quality prediction method. It includes a data processing module, an index screening module, a model building module, a parameter optimization module, a data partitioning module, a model training module, and a prediction output module.

[0040] The data processing module is used to acquire raw water quality data containing multiple water quality indicators at the estuary in chronological order, and obtain a time series dataset through data preprocessing.

[0041] The index screening module is used to use dissolved oxygen as the target water quality index, calculate the Pearson correlation coefficient between each water quality index and dissolved oxygen in the time series dataset, and retain the time series data of water quality indexes with a Pearson correlation coefficient greater than a set standard threshold as the dataset to be used.

[0042] The model building module is used to build a water quality prediction model, including a temporal convolutional network, a long short-term memory neural network, a convolutional block attention network, and an output network.

[0043] The parameter optimization module is used to initialize the water quality prediction model and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the water quality prediction model with the optimal hyperparameters.

[0044] The data partitioning module is used to divide the dataset to be used into training set, validation set and test set according to a ratio;

[0045] The model training module is used to train and validate the optimal hyperparameter water quality prediction model using the training set and validation set to obtain the trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation metrics to obtain the final water quality prediction model.

[0046] The prediction output module is used to input the water quality data to be tested into the final water quality prediction model to obtain the prediction result.

[0047] Furthermore, a computer-readable storage medium is provided, storing a program that, when executed by a processor, implements the aforementioned hybrid deep learning method for predicting water quality at sea outlets.

[0048] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0049] 1. Enhanced Time Series Modeling Capabilities: The water quality prediction model combines the advantages of TCN and LSTM, demonstrating strong time series modeling capabilities in water quality prediction. TCN effectively captures long-term dependencies through convolutional operations and can be computed in parallel, avoiding the gradient vanishing problem in traditional RNNs and LSTMs, making training on long-term series data more stable and efficient. Meanwhile, LSTM further enhances the processing capabilities for long-term memory, capturing complex temporal dependency patterns in water quality data. Compared to traditional methods, the combination of TCN and LSTM provides more accurate predictions when dealing with long-term changes and complex dynamics, making it suitable for various water quality change scenarios, especially performing better in dynamic environments.

[0050] 2. Adaptive Feature Selection and Optimization: Convolutional Block Attention Network (CBAM) introduces an attention mechanism, enabling the model to dynamically select important features, thereby optimizing the accuracy of water quality prediction. Water quality data may contain multidimensional features and noise, and traditional methods often rely on manual feature selection. CBAM, however, automatically focuses on features that significantly impact prediction, thus improving model performance. CBAM assigns different weights to input features in the channel and time dimensions, allowing the model to automatically adjust its focus. This adaptive feature selection enables the model to better cope with the complexity and diversity of data, avoid interference from irrelevant information, and improve prediction accuracy and stability.

[0051] 3. Improved Prediction Accuracy: Compared to traditional single models, the water quality prediction model in this application integrates the advantages of different structures. When processing complex water quality data, by learning long-term dependencies and short-term characteristics, it can more accurately predict water quality change trends and reduce prediction errors. It demonstrates higher accuracy in both daily monitoring and prediction of routine water quality indicators and early warning prediction of sudden water quality changes under special events.

[0052] 4. Wide applicability: This model is applicable to different aquatic environments and monitoring indicator systems. Whether it is freshwater bodies such as rivers and lakes, or local areas of the ocean, as well as different water pollution conditions and monitoring frequencies, it can effectively adapt to various water quality prediction tasks by adjusting model parameters and structure, and meet diverse practical application needs. Attached Figure Description

[0053] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0054] Figure 1 This is a flowchart of a hybrid deep learning method for predicting estuary water quality based on particle swarm optimization, as described in an embodiment of the present invention.

[0055] Figure 2 This is a flowchart of data preprocessing in an embodiment of the present invention.

[0056] Figure 3 This is a schematic diagram of the Pearson correlation coefficient results in an embodiment of the present invention.

[0057] Figure 4 This is a schematic diagram of the water quality prediction model in an embodiment of the present invention.

[0058] Figure 5 This is a flowchart of the particle swarm optimization algorithm in an embodiment of the present invention.

[0059] Figure 6 This is a line graph showing the comparative experimental results in an embodiment of the present invention.

[0060] Figure 7 This is a structural diagram of the hybrid deep learning estuary water quality prediction system based on particle swarm optimization in an embodiment of the present invention.

[0061] Figure 8 This is a schematic diagram of the structure of a computer-readable storage medium in an embodiment of the present invention. Detailed Implementation

[0062] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative effort are within the scope of protection of the present application.

[0063] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.

[0064] like Figure 1 As shown, this embodiment of the hybrid deep learning method for predicting estuary water quality based on particle swarm optimization includes the following steps:

[0065] S1. Obtain raw water quality data containing multiple water quality indicators at the estuary in chronological order, and obtain a time series dataset through data preprocessing.

[0066] The raw water quality data in this invention comes from the national surface water assessment section data of the China National Environmental Monitoring Center, which is recorded every 4 hours (4:00, 8:00, 12:00, 16:00, 20:00, 24:00). Alternatively, raw water quality data can be collected independently using testing methods. The raw water quality data includes nine water quality indicators: water temperature (T), dissolved oxygen (DO), pH, conductivity (EC), turbidity (Tu), total nitrogen (TN), ammonia nitrogen (NH3-N), permanganate index (COD Mn), and total phosphorus (TP).

[0067] Furthermore, to ensure the performance of the water quality prediction model in water quality prediction experiments, the first step is to preprocess the raw water quality data. This process includes data cleaning and organization, aiming to remove noise and irrelevant information, thereby improving the accuracy and efficiency of the prediction model. Figure 2 As shown, the specific steps are as follows:

[0068] First, outliers in the original water quality data are removed according to the 3σ principle. Water quality data that are not in the range (μ−3σ,μ+3σ) are discarded, where μ represents the mean and σ represents the standard deviation.

[0069] Secondly, since the equipment may be subject to maintenance failures, and there may be missing data points after removing outliers, it is necessary to fill in the missing values ​​in this part. Considering the changing characteristics of water quality data, linear interpolation is used to fill in the missing values ​​to maintain the smoothness and continuity of the water quality data.

[0070] In addition, in order to eliminate the interference caused by differences in units and numerical ranges, the data also needs to be normalized. By using the Min-Max Normalization method, the data is scaled to between 0 and 1, which preserves the relative relationship between the data, accelerates model convergence, and improves stability and generalization ability.

[0071] Since this application utilizes the trends and correlations of historical data to predict future trends or values, it requires the construction of time series data. Therefore, this application applies the concept of a sliding window, which gradually slides across the original water quality data to divide the time-recorded original water quality data into a series of continuous, fixed-length time series data to obtain a time series dataset. Each sliding window contains several continuous data points, which serve as the basis for model training or prediction. In other words, it uses time series data containing n data points to predict the data for the next time period or the next time point. In this embodiment, the size of the sliding window is 4, the sliding step size is 1, and the length of the time series data is 4.

[0072] S2. Using dissolved oxygen as the target water quality indicator, calculate the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series dataset, and retain the time series data of water quality indicators with a Pearson correlation coefficient greater than the set standard threshold as the dataset to be used.

[0073] Feature correlation analysis is a crucial step in deep learning. It identifies which features significantly impact the model's output, which features might be redundant or noise, and whether interactions exist between features. This application employs the Pearson correlation coefficient method for feature selection. By evaluating the linear correlation between features and the target variable, it optimizes the feature set, effectively eliminating redundant features, simplifying the model structure, and thus improving training speed and prediction accuracy. Furthermore, carefully selected features help the model gain a deeper understanding of the data's essence, enhancing generalization performance. Therefore, in this embodiment, dissolved oxygen is used as the target variable, and water quality indicators are used as features for feature selection. The correlation relationships among the nine water quality indicators are as follows: Figure 3 As shown, dissolved oxygen was used as a prediction indicator, and characteristic indicators with a correlation coefficient greater than 0.4 were selected, namely water temperature, pH, conductivity, ammonia nitrogen, total phosphorus, and dissolved oxygen itself, as multivariate input variables for prediction analysis.

[0074] S3. Construct a water quality prediction model, including a Temporal Convolutional Network (TCN), a Long Short-Term Memory (LSTM) neural network, a Convolutional Block Attention Module (CBAM), and an output network.

[0075] As a complex water system, the estuary generates a vast and complex volume of water quality parameter data, exhibiting significant temporal correlation (periodicity and trend). These data fluctuate with tidal changes, seasonal alternations, human activities, and climate change. The combined effect of these factors results in highly non-stationary and non-linear characteristics of estuarine water quality, making it difficult for traditional statistical methods to accurately describe these changes. Therefore, as... Figure 4As shown, this invention employs a hybrid deep learning approach, constructing a multi-layered network to learn a water quality prediction model, extracting data relationships, capturing short-term and long-term time series trends, and achieving accurate prediction of estuary water quality parameters. First, since recurrent neural networks can only process information from one time step at a time, the information for the next time step must wait for the previous time step to complete before proceeding. This means that neural networks with structures like LSTM cannot perform large-scale parallel computation like CNNs. Therefore, to solve this problem, this application first constructs a temporal convolutional network to capture the temporal features in time series data. TCN is an advanced sequence modeling method based on a CNN structure, exhibiting excellent performance in processing time series data. It mainly consists of three parts: causal convolution, dilated convolution, and residual connections. Second, this application uses LSTM to process time series information; Long Short-Term Memory (LSTM) neural networks are recurrent neural networks with a special structure. Their unique design effectively solves the gradient vanishing and gradient exploding problems existing in traditional RNNs when processing long sequence data, allowing information to be preserved over long time spans. Finally, a convolutional block attention network is constructed to highlight feature channels and temporal locations, improving prediction accuracy. The CBAM attention mechanism was initially designed for image recognition tasks, enhancing the feature representation capabilities of convolutional neural networks by combining channel attention and spatial attention. However, its principle can also be extended to time series prediction tasks, transforming the "spatial attention" concept of CBAM into "temporal attention," thereby adjusting the attention weights of the channel and temporal dimensions. This helps the model focus more on important time points and features, thus improving prediction accuracy. The CBAM structure mainly includes a channel attention module and a temporal attention module. The channel attention module enhances useful features and suppresses useless features by evaluating the importance of each channel (or feature). The temporal attention module focuses on the relationships between different time points in the time series data, highlighting key time points and suppressing unimportant ones by evaluating the importance of each time point.

[0076] S4. Initialize the water quality prediction model and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the optimal hyperparameter water quality prediction model.

[0077] Furthermore, hyperparameters have a crucial impact on the model's training process and final performance. Different hyperparameter settings can lead to significant differences in model performance on data, including accuracy, generalization ability, and training speed. The hyperparameters of the water quality prediction model in this application mainly include the number of hidden layer neurons, the number of hidden layers, the learning rate and the dropout rate of the long short-term memory neural network, and the number of hidden layer channels of the temporal convolutional network.

[0078] Since manual optimization is not only time-consuming but also ineffective, this invention chooses the Particle Swarm Optimization (PSO) algorithm to find the optimal combination of hyperparameters for the model, such as... Figure 5 As shown, specifically:

[0079] First, the particle swarm, particle velocity, and particle position are randomly initialized.

[0080] Then, the fitness value of each particle in the particle swarm is calculated, and the best individual particle and the best global particle are recorded. The fitness value of each particle is... f ( x i The fitness is evaluated by substituting the current position of the particles into the objective function. In water quality prediction models, fitness is typically an inverse function of a performance index (mean squared error, MSE, in this example), expressed as:

[0081] ,

[0082] in, x i Indicates the first i The position of each particle ϵ For a very small non-zero number (e.g., 10) -10 ), to prevent the denominator from being 0.

[0083] Next, the particle velocity and particle position are adjusted according to the velocity update formula and the position update formula.

[0084] Specifically, the speed update formula is:

[0085] v i,d ( t +1) = ωv i,d ( t ) + c 1 r 1( pBest i,d - x i,d ( t )) + c 2 r 2( gBest d - x i,d ( t )),

[0086] in, v i,d ( t+1) is the first t In the nth iteration i A particle in d The speed after the update v i,d ( t ) is the first t In the nth iteration i A particle in d The speed before the maintenance update ω For inertial weights, c 1. c 2 is the learning factor. r 1. r 2 is a random number that follows a uniform distribution in the interval [0,1]. x i,d ( t ) is the first t In the nth iteration i A particle in d The location before the maintenance update pBest i,d For the first i A particle in d The optimal position of the dimension. gBest d For all particles in d The position of the particle with optimal dimensional fitness;

[0087] The position update formula is:

[0088] 𝑥 𝑖,d (𝑡+1)=𝑥 𝑖,d (𝑡)+𝑣 𝑖,d (𝑡+1),

[0089] Among them, 𝑥 𝑖,d (𝑡+1) is the first t In the nth iteration i A particle in d The updated position.

[0090] Finally, check if the stopping condition (such as the number of iterations or accuracy requirements) is met. If it is met, the particle swarm optimization algorithm ends; otherwise, continue iteratively calculating the fitness value of each particle after the update and updating the particle velocity and particle position until the stopping condition is met.

[0091] Particle Swarm Optimization (PSO) is an iterative optimization algorithm that simulates the swarm behavior of birds foraging. Through information sharing and cooperation among individuals, it seeks the global optimum. The algorithm treats the solution to the optimization problem as a "particle" in the search space, with each particle possessing a fitness value determined by the objective function. The particle flies at a certain speed in the search space, its speed and direction determined by both its historical best position and the historical best position of the entire swarm. During the iteration process, the particle gradually approaches the global optimum by continuously updating its speed and position.

[0092] In this embodiment, when using the particle swarm optimization algorithm to optimize model hyperparameters, the iteration batch size is set to 100 times, the preset optimization range for the learning rate is set to [0.001, 0.05], the preset range for the number of hidden neurons is set to [8, 100], the preset range for the number of hidden layers is set to [1, 5], the preset range for the dropout rate is set to [0.1, 0.3], and the preset range for the number of TCN hidden layer channels is set to [8, 64]. The final optimization results are shown in Table 1 below:

[0093] Table 1. Results of Hyperparameter Optimization

[0094]

[0095] S5. Divide the dataset to be used into training set, validation set and test set according to the proportion.

[0096] In the complex and nuanced process of water quality prediction, data partitioning is a crucial step, directly impacting the effectiveness of model training and the accuracy of final predictions. Typically, the dataset is divided proportionally to ensure the model receives sufficient and appropriate data support during training, validation, and testing. In this embodiment, 80% of the data is used as the training set for model learning and optimization; 10% is used as the validation set to evaluate model performance during training and prevent overfitting; and the remaining 10% is used as the test set for the final evaluation of the model's predictive ability.

[0097] S6. Use the training set and validation set to train and validate the water quality prediction model with the optimal hyperparameters to obtain the trained water quality prediction model; use evaluation metrics to evaluate the performance of the trained water quality prediction model on the test set to obtain the final water quality prediction model.

[0098] Furthermore, the training process is as follows:

[0099] First, the training set is input into a temporal convolutional network for convolutional operations to extract local and global temporal features. Next, these local and global temporal features are passed to a long short-term memory neural network to process sequence information and capture long-term dependency features. Then, a convolutional block attention network is used to calculate channel and spatial attention weights for the long-term dependency features, and weighted features are applied to highlight important feature channels and temporal positions, resulting in weighted features. Finally, the output network processes the weighted features to obtain the prediction result. In this embodiment, the output network uses two fully connected layers for processing.

[0100] While intuitive charts can effectively evaluate water quality prediction models by displaying the overlap between real and predicted data, differentiating prediction performance by color, and assessing curve overlap, they are susceptible to subjective bias and lack objectivity. Therefore, a more scientific approach is needed to calculate prediction errors using mathematical formulas. This invention employs four metrics—Root Mean Squared Error (RMSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), and R²—to objectively and quantitatively reflect the performance of prediction models. These metrics more accurately measure the deviation between predicted and actual values, providing a reliable basis for model selection and optimization. The calculation formulas for the four metrics are shown below:

[0101]

[0102]

[0103]

[0104]

[0105] in, y i For the true value, For predicted values, This is the average value. n This is the size of the test set.

[0106] S7. Input the water quality data to be tested into the final water quality prediction model to obtain the prediction results.

[0107] To comprehensively evaluate the performance of the TCN-LSTM-CBAM model (i.e., the water quality prediction model) in time series prediction tasks, particularly for predictions using dissolved oxygen as the target indicator, this application selected six widely accepted prediction models as benchmarks for horizontal comparison: Support Vector Regression (SVR), Extreme Gradient Boosting (XGBoost), Temporal Convolutional Network (TCN), Gated Recurrent Unit (GRU), Long Short-Term Memory (LSTM), and the Transformer model. To ensure the fairness and comparability of the experimental results, all models were run under the same experimental environment. Data from a water quality monitoring station located at an estuary was collected from January 1, 2023 to December 23, 2023, totaling 2046 data points: 1431 data points for training, 205 data points for validation, and 410 data points for testing. Experimental parameters were kept highly consistent: the number of iterations was uniformly set to 100, the number of samples processed per batch was 24, and the learning rate was strictly controlled at 0.001. The comparison results are as follows: Figure 6 And as shown in Table 2 below:

[0108] Table 2 Performance Comparison Results

[0109]

[0110] In-depth analysis of the experimental results shows that the water quality prediction model exhibits excellent performance in prediction tasks targeting dissolved oxygen. For example... Figure 6 As shown, the prediction curve of the water quality prediction model almost perfectly matches the actual data curve, with significantly lower fluctuations, fully demonstrating its high accuracy and stability in predicting dissolved oxygen. To more specifically quantify the performance advantages of the TCN-LSTM-CBAM model, the data in Table 2 shows that compared to the second-best performing XGBoost model, the water quality prediction model of this application has achieved significant improvements in multiple evaluation indicators. Specifically, in terms of root mean square error (RMSE), the TCN-LSTM-CBAM model reduces the error by approximately 16.35% compared to the XGBoost model; in terms of mean absolute error (MAE), the error is reduced by approximately 23.84%; and in terms of mean absolute percentage error (MAPE), the error is reduced by approximately 22.80%. Furthermore, in terms of the coefficient of determination (R²), a key indicator for evaluating model fit, the TCN-LSTM-CBAM model also achieves a 4.23% improvement. These data objectively reflect the superiority of the TCN-LSTM-CBAM model in dissolved oxygen prediction performance.

[0111] It should be noted that, for the sake of simplicity, the aforementioned method embodiments are all described as a series of actions. However, those skilled in the art should understand that the present invention is not limited to the described order of actions, because according to the present invention, some steps can be performed in other orders or simultaneously.

[0112] Based on the same idea as the particle swarm optimization-based hybrid deep learning method for predicting estuary water quality in the above embodiments, this invention also provides a particle swarm optimization-based hybrid deep learning system for predicting estuary water quality. This system can be used to execute the aforementioned particle swarm optimization-based hybrid deep learning method for predicting estuary water quality. For ease of explanation, the structural diagram of the embodiment of the particle swarm optimization-based hybrid deep learning system for predicting estuary water quality only shows the parts related to the embodiments of this invention. Those skilled in the art will understand that the illustrated structure does not constitute a limitation on the device, and it may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0113] like Figure 7 As shown, another embodiment of the present invention provides a hybrid deep learning estuary water quality prediction system based on particle swarm optimization, including a data processing module, an index screening module, a model building module, a parameter optimization module, a data partitioning module, a model training module, and a prediction output module.

[0114] The data processing module is used to acquire raw water quality data containing multiple water quality indicators at the estuary in chronological order, and obtain a time series dataset through data preprocessing.

[0115] The indicator screening module is used to calculate the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series dataset, with dissolved oxygen as the target water quality indicator, and retains the time series data of water quality indicators with a Pearson correlation coefficient greater than the set standard threshold as the pending dataset.

[0116] The model building module is used to build water quality prediction models, including temporal convolutional networks, long short-term memory neural networks, convolutional block attention networks, and output networks;

[0117] The parameter optimization module is used to initialize the water quality prediction model and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the water quality prediction model with the optimal hyperparameters.

[0118] The data partitioning module is used to divide the dataset to be used into training, validation and test sets according to a certain ratio;

[0119] The model training module is used to train and validate the optimal hyperparameter water quality prediction model using the training set and validation set to obtain the trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation metrics to obtain the final water quality prediction model.

[0120] The prediction output module is used to input the water quality data to be tested into the final water quality prediction model to obtain the prediction results.

[0121] It should be noted that the hybrid deep learning estuary water quality prediction system based on particle swarm optimization of the present invention corresponds one-to-one with the hybrid deep learning estuary water quality prediction method based on particle swarm optimization of the present invention. The technical features and beneficial effects described in the embodiments of the hybrid deep learning estuary water quality prediction method based on particle swarm optimization are applicable to the embodiments of the hybrid deep learning estuary water quality prediction system based on particle swarm optimization. For details, please refer to the description in the embodiments of the method of the present invention, which will not be repeated here.

[0122] Furthermore, in the above embodiments of the hybrid deep learning estuary water quality prediction system based on particle swarm optimization, the logical division of each program module is merely illustrative. In practical applications, the above functions can be assigned to different program modules as needed, for example, for the sake of corresponding hardware configuration requirements or software implementation convenience. That is, the internal structure of the hybrid deep learning estuary water quality prediction system based on particle swarm optimization can be divided into different program modules to complete all or part of the functions described above.

[0123] like Figure 8 As shown, in one embodiment, a computer-readable storage medium is provided, storing a program in a memory. When the program is executed by a processor, it implements a hybrid deep learning method for predicting estuarine water quality based on particle swarm optimization, specifically:

[0124] The raw water quality data of the estuary containing multiple water quality indicators were obtained in chronological order, and a time series dataset was obtained through data preprocessing.

[0125] Using dissolved oxygen as the target water quality indicator, the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series dataset is calculated, and the time series data of water quality indicators with a Pearson correlation coefficient greater than the set standard threshold are retained as the dataset to be used.

[0126] Construct a water quality prediction model, including a temporal convolutional network, a long short-term memory neural network, a convolutional block attention network, and an output network;

[0127] Initialize the water quality prediction model, and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the water quality prediction model with the optimal hyperparameters.

[0128] The dataset to be used is divided into training set, validation set and test set according to the proportion;

[0129] The optimal hyperparameter water quality prediction model is trained and validated using the training and validation sets to obtain the trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation metrics to obtain the final water quality prediction model.

[0130] The water quality data to be tested is input into the final water quality prediction model to obtain the prediction results.

[0131] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0132] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0133] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.

Claims

1. A hybrid deep learning method for predicting estuarine water quality based on particle swarm optimization, characterized in that, Includes the following steps: The raw water quality data of the estuary containing multiple water quality indicators were obtained in chronological order, and a time series dataset was obtained through data preprocessing. Using dissolved oxygen as the target water quality indicator, the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series dataset is calculated, and the time series data of water quality indicators with a Pearson correlation coefficient greater than the set standard threshold are retained as the dataset to be used. Construct a water quality prediction model, including a temporal convolutional network, a long short-term memory neural network, a convolutional block attention network, and an output network; Initialize the water quality prediction model, and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the water quality prediction model with the optimal hyperparameters. The dataset to be used is divided into training set, validation set and test set according to the proportion; The optimal hyperparameter water quality prediction model is trained and validated using the training and validation sets to obtain the trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation metrics to obtain the final water quality prediction model. The water quality data to be tested is input into the final water quality prediction model to obtain the prediction results; The process of using particle swarm optimization to optimize the hyperparameters of the water quality prediction model specifically involves: Randomly initialize the particle swarm, particle velocity, and particle position; Calculate the fitness value of each particle in the particle swarm, and record the best individual particle and the best global particle; Adjust the particle velocity and particle position according to the velocity update formula and the position update formula; Check if the stopping condition is met. If it is, end the particle swarm optimization algorithm. Otherwise, continue iteratively calculating the fitness value of each particle after the update and updating the particle velocity and particle position until the stopping condition is met. The speed update formula is: v i,d ( t +1) = ωv i,d ( t ) + c 1 r 1( pBest i,d - x i,d ( t )) + c 2 r 2( gBest d - x i,d ( t )), in, v i,d ( t +1) is the first t In the nth iteration i A particle in d The speed after the update v i,d ( t ) is the first t In the nth iteration i A particle in d The speed before the maintenance update ω For inertial weights, c 1. c 2 is the learning factor. r 1. r 2 is a random number that follows a uniform distribution in the interval [0,1]. x i,d ( t ) is the first t In the nth iteration i A particle in d The location before the maintenance update pBest i,d For the first i A particle in d The optimal position of the dimension. gBest d For all particles in d The position of the particle with optimal dimensional fitness; The position update formula is: 𝑥 𝑖,d (𝑡+1)=𝑥 𝑖,d (𝑡)+𝑣 𝑖,d (𝑡+1), Among them, 𝑥 𝑖,d (𝑡+1) is the first t In the nth iteration i A particle in d The updated position.

2. The hybrid deep learning method for predicting estuary water quality according to claim 1, characterized in that, The water quality indicators include water temperature, dissolved oxygen, pH, conductivity, turbidity, total nitrogen, ammonia nitrogen, permanganate index, and total phosphorus.

3. The hybrid deep learning method for predicting estuary water quality according to claim 1, characterized in that, The process of obtaining time series data through data preprocessing specifically includes: Outliers in the original water quality data are removed according to the 3σ principle, where σ represents the standard deviation of the original water quality data. After outlier removal, linear interpolation was used to fill in the missing values ​​in the original water quality data. After filling, the original water quality data is scaled to between 0 and 1 using the max-min normalization method; A sliding window is applied to progressively slide across the scaled original water quality data, dividing the original water quality data into multiple continuous, fixed-length time series data to obtain a time series dataset.

4. The hybrid deep learning method for predicting estuary water quality according to claim 1, characterized in that, The hyperparameters of the water quality prediction model include the number of hidden layer neurons, the number of hidden layers, the learning rate and the loss rate of the long short-term memory neural network, and the number of hidden layer channels of the temporal convolutional network.

5. The hybrid deep learning method for predicting estuary water quality according to claim 1, characterized in that, The training of the water quality prediction model with optimal hyperparameters specifically involves: The training set is input into a temporal convolutional network for convolution operations to extract local and global temporal features. Local and global temporal features are passed to a long short-term memory neural network to capture long-term dependency features; The convolutional block attention network is used to calculate the channel and spatial attention weights for long-term dependent features, and the long-term dependent features are weighted to highlight important feature channels and temporal positions, resulting in weighted features. The weighted features are processed using an output network to obtain the prediction results.

6. The hybrid deep learning method for predicting estuary water quality according to claim 1, characterized in that, The evaluation metrics include root mean square error, mean absolute error, mean absolute percentage error, and goodness of fit.

7. A hybrid deep learning-based estuary water quality prediction system based on particle swarm optimization, characterized in that, The hybrid deep learning method for predicting estuary water quality, applied to any one of claims 1-6, includes a data processing module, an indicator screening module, a model building module, a parameter optimization module, a data partitioning module, a model training module, and a prediction output module. The data processing module is used to acquire raw water quality data containing multiple water quality indicators at the estuary in chronological order, and obtain a time series dataset through data preprocessing. The index screening module is used to use dissolved oxygen as the target water quality index, calculate the Pearson correlation coefficient between each water quality index and dissolved oxygen in the time series dataset, and retain the time series data of water quality indexes with a Pearson correlation coefficient greater than a set standard threshold as the dataset to be used. The model building module is used to build a water quality prediction model, including a temporal convolutional network, a long short-term memory neural network, a convolutional block attention network, and an output network. The parameter optimization module is used to initialize the water quality prediction model and use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model to obtain the water quality prediction model with the optimal hyperparameters. The data partitioning module is used to divide the dataset to be used into training set, validation set and test set according to a ratio; The model training module is used to train and validate the optimal hyperparameter water quality prediction model using the training set and validation set to obtain the trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation metrics to obtain the final water quality prediction model. The prediction output module is used to input the water quality data to be tested into the final water quality prediction model to obtain the prediction result.

8. A computer-readable storage medium storing a program, characterized in that, When the program is executed by the processor, it implements the hybrid deep learning method for predicting estuary water quality as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Short-term Load Forecasting Method Based on TCN and IPSO-LSSVM Combined Model

    AU2020104000A4

  • Method for predicting bottom dissolved oxygen based on self-attention mechanism

    CN118504615A