Hybrid deep learning sea outlet water quality prediction method based on particle swarm optimization

Through a hybrid deep learning method based on particle swarm optimization, combined with time domain convolutional network, long and short-term memory neural network and convolutional block attention network, the existing water quality prediction methods have solved the problems of low prediction accuracy and low computational efficiency when dealing with complex and dynamically changing water quality problems, and achieved accurate prediction and stability improvement of water quality parameters at the estuary.

CN119940089AActive Publication Date: 2025-05-06SOUTH CHINA AGRICULTURAL UNIVERSITY

Patent Information

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

AI Technical Summary

Technical Problem

When existing water quality prediction methods deal with complex and dynamically changing water quality problems, there are problems such as low prediction accuracy, low computational efficiency, and poor robustness to noise and outliers.

Method used

A hybrid deep learning method based on particle swarm optimization is adopted, combined with time domain convolutional network, long and short-term memory neural network and convolutional block attention network, we learn and extract data relationships through multi-layer networks to capture short-term and long-term time series trends, and achieve accurate prediction of water quality parameters at sea outlets.

Benefits of technology

It improves the accuracy and stability of water quality prediction, enhances the time series modeling ability, improves the adaptive feature selection and optimization capabilities of the model, and is suitable for different water environments and monitoring index systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940089A_ABST
    Figure CN119940089A_ABST
Patent Text Reader

Abstract

The invention discloses a hybrid deep learning sea outlet water quality prediction method based on particle swarm optimization, and the method comprises the steps: firstly obtaining time series data through data preprocessing, carrying out the correlation analysis, screening a water quality index, and reducing the data noise; then constructing a water quality prediction model by applying a mixed deep learning mode and combining the advantages of TCN, LSTM and CBAM networks; then, time sequence data is used for training a model type, TCN is used for effectively capturing a long-time dependency relationship in the sequence data, LSTM is used for enhancing the processing capacity of long-term memory, a complex time dependency mode in water quality data is captured, CBAM is used for introducing an attention mechanism to adaptively select important features, and the accuracy of water quality prediction is optimized; and the prediction precision and stability are improved. The method has higher accuracy in daily monitoring and prediction of conventional water quality indexes and early warning and prediction of water quality sudden change under special events, and can meet diversified practical application requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of water pollution control, and specifically relates to a hybrid deep learning outlet water quality prediction method based on particle swarm optimization. Background Art

[0002] With the rapid economic growth and the continuous expansion of the population, the discharge of land-based pollutants continues to increase, bringing severe environmental pollution challenges to the coastal waters. Inorganic nitrogen and active phosphates are the main excessive indicators of seawater. Their excessive presence leads to eutrophication of water bodies, stimulates the excessive reproduction of algae and other aquatic organisms, and then causes water quality deterioration, and even produces harmful red tides and other ecological disasters. Therefore, scientifically and accurately predicting the water quality of the estuary, especially the accurate grasp of the water quality of the river section entering the sea, is of great significance for early warning of water pollution incidents and potential pollution risks. It can transform water environment pollution from post-event governance to pre-event prevention and remediation, provide strong technical and decision-making support for the ecological environment department, and improve its treatment efficiency. Existing water quality prediction methods include water quality prediction methods based on traditional statistical analysis, water quality prediction methods based on machine learning, and water quality prediction methods based on deep learning.

[0003] Among them, the water quality prediction method based on traditional statistical analysis is the earliest method used in water quality prediction, such as multivariate linear regression, nonlinear regression and time series analysis. Based on historical water quality data, it establishes a mathematical model to describe the law 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 multivariate regression analysis in Yellow River water quality prediction [J]. People's Yellow River, 2010, 32(03): 35-36) applied the multivariate linear regression (MLR) method to predict the COD concentration of the Yellow River mainstream from Tongguan to Sanmenxia, ​​and achieved good results with 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 that combines the autoregressive moving average model (ARIMA) with the K-means clustering model. Using the total phosphorus (TP) data of a certain basin as a sample, ARIMA was used to predict trends, and K-means was used to analyze the relationship between precipitation and TP. The combination of the two improved the prediction accuracy. Although traditional statistical analysis methods have achieved certain results in some water quality prediction tasks, due to their strong dependence on data, limitations of model assumptions, and insufficient ability to capture nonlinear dynamic relationships, this method may show certain limitations when facing 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 predictions.

[0004] With the development of computer technology, machine learning methods, such as support vector machine (SVM), artificial neural network (ANN), random forest (RF), gradient boosting tree (GDBT), etc., have been gradually applied to the field of water quality prediction due to their powerful data processing and pattern recognition capabilities. They can better capture the nonlinear relationship 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.") used three machine learning techniques, ANN, GMDH and SVM, to predict the water quality of the Tire River in southwestern Iran. The results showed that the prediction performance of SVM was more advantageous than the other two methods. However, machine learning models can effectively predict water quality for simple data with clear variable relationships. However, the limitations of machine learning models begin to emerge for more complex sequence data that exhibits nonlinear characteristics and is affected by multiple factors. Since sequence data contains a large number of interactive effects and potential variables that are difficult to capture intuitively, it is difficult for the model to accurately capture the inherent laws and changing trends of the data, which affects the detection results and performance of water quality predictions.

[0005] With the rapid development of artificial intelligence in recent years, deep learning has gradually been applied to the field of water quality detection. By constructing deep networks, such as convolutional neural networks (CNN), recurrent neural networks (RNN) and their variants, long short-term memory networks (LSTM), etc., 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 of the data, thereby improving the accuracy and robustness of predictions. For example: 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.) showed that the LSTM model performed well in predicting river daily water temperature, and could more accurately capture the daily changes in the thermal state of river water, providing strong support for river water temperature prediction and ecological management. In addition, the deep learning hybrid model can more comprehensively analyze the complex relationships in water quality data by combining the advantages of multiple machine learning algorithms or deep learning algorithms, thereby achieving accurate prediction of water quality indicators. For example, Wang et al. (Wang Z, Duan L, Shuai D, et al. Research on water environmental 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, combined with empirical mode decomposition (EEMD), to effectively reduce noise and jointly improve prediction performance. In addition, in recent years, the attention mechanism has also become one of the research hotspots in the field of deep learning. The attention mechanism was first proposed based on the Transformer architecture and applied to the field of natural language processing. After being applied to water quality prediction, it can effectively improve the prediction accuracy. For example, Xie Zaimi et al. (Xie Zaimi, Wang Ji, Mo Chunmei. Fusion of IFWA-optimized BLSTM and Transformer to construct a three-dimensional prediction model for seawater quality [J]. Transactions of the Chinese Society of Agricultural Engineering, 2023, 39(04): 162-170.) integrated the Transformer architecture and BiLSTM to effectively extract and integrate the 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 are prone to low computational efficiency when processing long time series or complex time series data, especially when consuming large resources during training; in addition, although some models can capture local features or long-term dependencies, they have limitations in capturing global dependencies and multi-scale information, resulting in the inability to fully improve prediction accuracy. Secondly, these models are less robust to noise and outliers, and may be unstable when data quality is poor or abnormally fluctuating, affecting the reliability of prediction results. Finally, the complexity and computational complexity of the model are usually high, the training time is long, and it is difficult to apply efficiently on large-scale data sets. In summary, the existing methods still have room for improvement in prediction accuracy, computational efficiency, and robustness, and more efficient and adaptive models are needed to handle complex water quality prediction tasks. Summary of the invention

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

[0007] In order to achieve the above object, the present invention provides a hybrid deep learning estuary water quality prediction method based on particle swarm optimization, comprising the following steps:

[0008] The original water quality data of the estuary containing multiple water quality indicators are obtained in chronological order, and a time series data set is obtained through data preprocessing;

[0009] Taking dissolved oxygen as the target water quality indicator, the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series data set 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 standby data set;

[0010] Construct a water quality prediction model, including a time-domain 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, use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model, and obtain the water quality prediction model with the optimal hyperparameters;

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

[0013] The water quality prediction model with the optimal hyperparameters is trained and verified using the training set and the validation set to obtain a trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation indicators 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 result.

[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 time series data is obtained by data preprocessing, specifically:

[0017] According to the 3σ principle, outliers in the original water quality data are removed, where σ represents the standard deviation of the original water quality data;

[0018] After outliers were removed, linear interpolation was used to fill in missing values ​​in the original water quality data;

[0019] After filling, the original water quality data are scaled to between 0 and 1 using the maximum and minimum normalization method;

[0020] The sliding window is applied to slide step by step on the scaled original water quality data to segment the original water quality data into multiple continuous, fixed-length time series data to obtain a time series data set.

[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 layer 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 time domain convolutional network.

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

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

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

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

[0026] Check whether the stopping condition is met. If so, the particle swarm optimization algorithm ends. Otherwise, continue to iteratively calculate the fitness value of each particle after the update and update the particle speed 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] Among them, v i,d (t+1) is the velocity of the i-th particle after the d-dimensional update in the t-th iteration, v i,d (t) is the velocity of the i-th particle in the t-th iteration before the d-dimensional update, ω is the inertia weight, c 1 、c 2 is the learning factor, r1 and r2 are random numbers uniformly distributed in the interval [0,1], and x i,d (t) is the position of the i-th particle in the t-th iteration before the d-dimensional update, pBest i,d is the optimal position of the ith particle in dimension d, gBest d is the position of the particle with the best fitness in d dimension among all particles;

[0030] The position update formula is:

[0031] x i,d (t+1)=x i,d (t)+v i,d (t+1),

[0032] Among them, x i,d (t+1) is the updated position of the ith particle in the d dimension in the tth iteration.

[0033] As a preferred technical solution, the water quality prediction model with the optimal hyperparameters is trained as follows:

[0034] The training set is input into the time domain convolutional network for convolution operation to extract local and global temporal features;

[0035] Pass local and global temporal features to the 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 the long-term dependent features respectively, and the long-term dependent features are weighted to highlight the important feature channels and time positions to obtain weighted features;

[0037] The output network is used to process the weighted features 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, including 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;

[0040] The data processing module is used to obtain the original water quality data of the estuary containing multiple water quality indicators in chronological order, and obtain a time series data set through data preprocessing;

[0041] The index number 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 data set, and retain the time series data of water quality indexes with a Pearson correlation coefficient greater than a set standard threshold as a standby data set;

[0042] The model building module is used to build a water quality prediction model, including a time domain 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 unused data set into a training set, a validation set and a test set according to a proportion;

[0045] The model training module is used to train and verify the water quality prediction model with the optimal hyperparameters using the training set and the validation set to obtain a trained water quality prediction model; and to perform performance evaluation on the trained water quality prediction model on the test set using the evaluation index to obtain a 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 for prediction to obtain the prediction result.

[0047] On the other hand, a computer-readable storage medium is provided, which stores a program, and when the program is executed by a processor, the above-mentioned hybrid deep learning estuary water quality prediction method is implemented.

[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, and demonstrates strong time series modeling capabilities in water quality prediction. TCN effectively captures long-term dependencies through convolution operations and can perform parallel calculations, avoiding the gradient vanishing problem in traditional RNN and LSTM, making the training of long-term series data more stable and efficient. At the same time, LSTM further enhances the processing capabilities of long-term memory and can capture complex time-dependent patterns in water quality data. Compared with traditional methods, the combination of TCN-LSTM can provide more accurate predictions when dealing with long-term changes and complex dynamics, and is suitable for various water quality change scenarios, especially in dynamic environments.

[0050] 2. Adaptive feature selection and optimization: The convolutional block attention network (CBAM) introduces an attention mechanism, which enables the model to dynamically select important features, thereby optimizing the accuracy of water quality prediction. Water quality data may contain multidimensional features and be noisy, and traditional methods often rely on manual feature selection. CBAM can automatically focus on features that have a significant impact on predictions, thereby improving the performance of the model; 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 with the traditional single model, the water quality prediction model of this application combines the advantages of different structures. When processing complex water quality data, it can more accurately predict the trend of water quality changes and reduce prediction errors by learning long-term dependencies and short-term characteristics. Whether it is daily monitoring and prediction of conventional water quality indicators or early warning prediction of water quality mutations under special events, it has higher accuracy.

[0052] 4. Wide applicability: The model is applicable to different water 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. By adjusting the model parameters and structure, it can effectively adapt to various water quality prediction tasks and meet diverse practical application needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0054] Figure 1This is a flow chart of a hybrid deep learning estuary water quality prediction method based on particle swarm optimization in an embodiment of the present invention.

[0055] Figure 2 Flow chart of data preprocessing in an embodiment of the present invention.

[0056] Figure 3 Schematic diagram of the result of Pearson correlation coefficient in an embodiment of the present invention.

[0057] Figure 4 Schematic diagram of the structure of the water quality prediction model in the embodiment of the present invention.

[0058] Figure 5 The figure is a flow chart of the optimization of the particle swarm optimization algorithm in the embodiment of the present invention.

[0059] Figure 6 It is a line graph of comparative experimental results in the embodiments of the present invention.

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

[0061] Figure 8 Schematic diagram of the structure of a computer-readable storage medium in an embodiment of the present invention. DETAILED DESCRIPTION

[0062] In order 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 in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.

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

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

[0065] S1. Obtain the original water quality data of the estuary containing multiple water quality indicators in chronological order, and obtain the time series data set through data preprocessing.

[0066] The original water quality data in the present invention are derived from the national surface water assessment section data of China National Environmental Testing Center, which is recorded once every 4 hours (4:00, 8:00, 12:00, 16:00, 20:00, 24:00), and of course, detection means can also be used to collect and obtain original water quality data by themselves. Original water quality data include water temperature (T), dissolved oxygen (DO), pH, electrical conductivity (EC), turbidity (Tu), total nitrogen (TN), ammonia nitrogen (NH3-N), permanganate index (COD Mn) and total phosphorus (TP) and other nine water quality index data. In the present embodiment, the Pearl River estuary is taken as the research object, and the water quality data from January 1, 2023 to December 23, 2023 are selected, and the research section selects Cangshan Ferry, Jitimen Bridge, Jianfeng Bridge, Zhuhai Bridge, Zhongshan Port Terminal, Hongqili, Jiaomen, Lianhuashan and Guantan, a total of 9 water quality monitoring sites.

[0067] Furthermore, in order to ensure the performance of the water quality prediction model in the water quality prediction experiment, the original water quality data is first preprocessed. This process includes cleaning and sorting the data to remove noise and irrelevant information, thereby improving the accuracy and operation efficiency of the prediction model. Figure 2 As shown, the specific steps are as follows:

[0068] First, the outliers in the original water quality data were removed according to the 3σ principle, and the water quality data that were not in the interval (μ-3σ,μ+3σ) were eliminated, where μ represented the mean and σ represented the standard deviation.

[0069] Secondly, since equipment collection may be subject to maintenance failures and there may be missing time point data after removing outliers, it is necessary to fill in the missing values ​​in this part; considering the characteristics of water quality data changes, 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 dimension and numerical range, the data needs to be normalized. The data is scaled to between 0 and 1 through the Min-Max Normalization method, which retains the relative relationship between the data, accelerates model convergence, and improves stability and generalization ability.

[0071] Since this application uses the trend and correlation of historical data to predict future trends or values, it is necessary to construct time series data. Therefore, this application applies the idea of ​​sliding windows. The sliding window is gradually slid on the original water quality data to divide the original water quality data recorded by time into a series of continuous, fixed-length time series data to obtain a time series data set; each sliding window contains a number of continuous data points, which serve as the basis for model training or prediction, that is, using the time series data containing n data to predict the next or next time data. In this embodiment, the size of the sliding window is 4, the sliding step is 1, and the length of the time series data is 4.

[0072] S2. Take 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 data set, and retain the time series data of water quality indicators with a Pearson correlation coefficient greater than the set standard threshold as the stand-by data set.

[0073] Feature correlation analysis in deep learning is an important step. Through feature correlation analysis, we can identify which features have an important impact on the output of the model, which features may be redundant or noisy, and whether there are interactions between features. This application uses the Pearson correlation coefficient method for feature screening, and optimizes the feature set by evaluating the linear correlation between features and target variables, effectively eliminating redundant features, simplifying the model structure, and thus improving training speed and prediction accuracy. At the same time, carefully selected features help the model to gain in-depth insights into the nature of the data and enhance generalization performance. Therefore, in this embodiment, dissolved oxygen is used as the target variable, and water quality indicators are used as features for feature screening. The correlation between the 9 water quality indicators is as follows Figure 3 As shown in the figure, taking dissolved oxygen as the prediction index, characteristic indexes with correlation coefficient greater than 0.4 were screened out, namely water temperature, pH, conductivity, ammonia nitrogen, total phosphorus and dissolved oxygen itself as multivariate input variables for prediction analysis.

[0074] S3. Build a water quality prediction model, including the temporal convolutional network (TCN), long short-term memory neural network (LSTM), convolutional block attention module (CBAM) and output network.

[0075] As a complex water system, the estuary has a large and complex amount of water quality parameter data, with significant time correlation (periodicity and trend), and will fluctuate with factors such as tidal rise and fall, seasonal changes, interference from human activities, and climate change. These factors work together to make the water quality of the estuary show highly non-stationary and nonlinear characteristics, and traditional statistical methods are difficult to accurately describe its changes. Therefore, Figure 4 As shown, the present invention adopts a hybrid deep learning method to extract data relationships by constructing a water quality prediction model for multi-layer network learning, capture short-term and long-term time series trends, and realize accurate prediction of water quality parameters at the estuary. First, since the recurrent neural network can only process information of one time step at a time, the information of the next time step must wait for the previous time step to be processed before it can continue, which means that neural networks with structures like LSTM cannot perform large-scale parallel calculations like CNN. Therefore, in order to solve the above problems, the present application first constructs a time domain convolutional network to capture the time features in time series data. TCN is an advanced sequence modeling method based on CNN structure, which shows excellent performance in processing time series data. It is mainly composed of three parts: causal convolution, dilated convolution and residual connection. Secondly, the present application uses LSTM to process time series information; long short-term memory neural network is a recurrent neural network with a special structure. Its unique design effectively solves the gradient disappearance and gradient explosion problems of traditional RNN when processing long sequence data, so that information can be preserved over a long span. Finally, a convolutional block attention network is constructed to highlight the feature channel and time position to improve the prediction accuracy. The CBAM attention mechanism was originally designed for image recognition tasks. It combines channel attention and spatial attention to enhance the feature expression ability of convolutional neural networks, but its principle can also be extended to time series prediction tasks. The "spatial attention" concept of CBAM is converted into "temporal attention", and then the attention weights of the channel and time dimensions are adjusted to help the model focus more on important time points and features, thereby improving the accuracy of prediction. 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 relationship between different time points in the time series data. By evaluating the importance of each time point, it can highlight key time points and suppress unimportant time points.

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

[0077] Furthermore, hyperparameters have a crucial impact on the training process and final performance of the model. Different hyperparameter settings will lead to significant differences in the performance of the model on the 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 loss rate of the long short-term memory neural network, and the number of hidden layer channels of the time domain convolutional network.

[0078] Since manual optimization is not only time-consuming but also has poor results, the present invention selects the particle swarm optimization algorithm (PSO) to find the optimal hyperparameter combination of the model, such as Figure 5 As shown, specifically:

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

[0080] Then, calculate the fitness value of each particle in the particle group, record the individual optimal particle and the global optimal particle. The fitness value of each particle is f(x i ), by substituting the current position of the particle into the objective function for evaluation. In the water quality prediction model, fitness is usually the inverse function of a certain performance indicator (in this embodiment, the mean square error MSE is used), expressed as:

[0081]

[0082] Among them, x i represents the position of the i-th particle, ∈ is a small non-zero number (e.g. 10 -10 ) to prevent the denominator from being 0.

[0083] Next, the particle speed and particle position are adjusted according to the speed 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] Among them, v i,d (t+1) is the velocity of the i-th particle after the d-dimensional update in the t-th iteration, v i,d(t) is the velocity of the i-th particle in the t-th iteration before the d-dimensional update, ω is the inertia weight, c 1 、c 2 is the learning factor, r1 and r2 are random numbers uniformly distributed in the interval [0,1], and x i,d (t) is the position of the i-th particle in the t-th iteration before the d-dimensional update, pBest i,d is the optimal position of the ith particle in dimension d, gBest d is the position of the particle with the best fitness in d dimension among all particles;

[0087] The position update formula is:

[0088] x i,d (t+1)=x i,d (t)+v i,d (t+1),

[0089] Among them, x i,d (t+1) is the updated position of the ith particle in the d dimension in the tth iteration.

[0090] Finally, check whether the stopping condition (such as the number of iterations or accuracy requirements) is met. If so, the particle swarm optimization algorithm is terminated. Otherwise, the fitness value of each particle after the update is continued to be iteratively calculated and the particle speed and particle position are updated until the stopping condition is met.

[0091] Particle swarm optimization is an iteration-based optimization algorithm that simulates the group behavior of birds foraging and seeks the global optimal solution through information sharing and collaboration between individuals. The algorithm regards the solution to the optimization problem as a "particle" in the search space, and all particles have a fitness value determined by the objective function. The particles fly at a certain speed in the search space, and their flight speed and direction are jointly determined by the historical optimal position of the particles and the historical optimal position of the entire group. In the iterative process, the particles gradually approach the global optimal solution by continuously updating their own speed and position.

[0092] In this embodiment, when the particle swarm algorithm is used to optimize the model hyperparameters, the iteration batch is set to 100 times, the preset optimization interval of the learning rate is set to [0.001, 0.05], the preset interval of the number of hidden neurons is set to [8, 100], the preset interval of the number of hidden layers is set to [1, 5], the preset interval of the loss rate is set to [0.1, 0.3], and the preset interval of 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 Hyperparameter optimization results

[0094]

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

[0096] In the complex and delicate process of water quality prediction, data division is a crucial link, which is directly related to the effect of model training and the accuracy of the final prediction. Usually, the unused data set is divided according to a certain proportion to ensure that the model can obtain sufficient and reasonable data support during the training, verification and testing stages. In this embodiment, 80% of the data is used as a training set for model learning and optimization; 10% of the data is used as a verification set to evaluate model performance during training and prevent overfitting; the remaining 10% of the data is used as a test set for the final evaluation of the model's predictive ability.

[0097] S6. Use the training set and the validation set to train and validate the water quality prediction model with the optimal hyperparameters to obtain a trained water quality prediction model; use the evaluation index 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:

[0099] First, the training set is input into the time domain convolutional network for convolution operation to extract local and global time features; then, the local and global time features are passed to the long short-term memory neural network to process sequence information and capture long-term dependent features; then, the convolutional block attention network is used to calculate the channel and spatial attention weights for the long-term dependent features, and the long-term dependent features are weighted to highlight the important feature channels and time positions to obtain weighted features; finally, the output network is used to process the weighted features to obtain the prediction results. In this embodiment, the output network uses two fully connected layers for processing.

[0100] In order to evaluate the water quality prediction model, although the intuitive chart method can show the overlap of real data and predicted data, and distinguish the prediction effects of different models by color and observe the curve overlap to judge the prediction performance, the chart method is susceptible to subjective judgment and lacks objectivity. Therefore, in order to evaluate the model more scientifically, it is necessary to use a mathematical formula to calculate the prediction error. The present invention uses four indicators, namely root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE) and goodness of fit (R2), to objectively and quantitatively reflect the performance of the prediction model. These indicators can more accurately measure the deviation between the predicted value and the actual value, and provide a reliable basis for the selection and optimization of the model. The calculation formulas of the four indicators are as follows:

[0101]

[0102]

[0103]

[0104]

[0105] Among them, y i is the true value, is the predicted value, is the average value, and n is the test set size.

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

[0107] In order to comprehensively evaluate the performance of the TCN-LSTM-CBAM model (i.e., water quality prediction model) in time series prediction tasks, especially prediction with dissolved oxygen as the target indicator, this application selects six widely recognized prediction models as references for horizontal comparison, namely support vector regression (SVR), extreme gradient boosting (XGBoost), temporal convolutional network (TCN), gated recurrent unit (GRU), long short-term memory network (LSTM) and Transformer model. To ensure the fairness and comparability of the experimental results, all models are run in the same experimental environment, and the Jiaomen water quality monitoring station located at the mouth of the Pearl River is selected to obtain data from the Jiaomen water quality monitoring station from January 1, 2023 to December 23, 2023, totaling 2046 data, including 1431 training sets, 205 validation sets, and 410 test sets; the experimental parameter settings remain highly consistent: the number of iterations is uniformly set to 100 times, the number of samples processed in each batch is 24, and the learning rate is strictly controlled at 0.001. The comparison results are as follows Figure 6 As shown in Table 2 below:

[0108] Table 2 Performance comparison results

[0109]

[0110] Through in-depth analysis of the experimental results, it can be seen that the water quality prediction model has shown excellent performance in the prediction task with dissolved oxygen as the target indicator. Figure 6As shown, the prediction curve of the water quality prediction model almost completely overlaps with the actual data curve, and the volatility is significantly lower, which fully demonstrates its high accuracy and high stability in predicting dissolved oxygen. In order to more specifically quantify the performance advantages of the TCN-LSTM-CBAM model, it can be seen from the data in Table 2 that compared with 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 error of the TCN-LSTM-CBAM model is reduced by about 16.35% relative to the XGBoost model; in terms of mean absolute error (MAE), the error is reduced by about 23.84%; in terms of mean absolute percentage error (MAPE), the error is reduced by about 22.80%. In addition, in terms of the coefficient of determination (R 2 ) This key indicator for evaluating the goodness of fit of the model, the TCN-LSTM-CBAM model also achieved 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 convenience, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.

[0112] Based on the same idea as the hybrid deep learning estuary water quality prediction method based on particle swarm optimization in the above-mentioned embodiment, the present invention also provides a hybrid deep learning estuary water quality prediction system based on particle swarm optimization, which can be used to execute the above-mentioned hybrid deep learning estuary water quality prediction method based on particle swarm optimization. For ease of explanation, the structural schematic diagram of the embodiment of the hybrid deep learning estuary water quality prediction system based on particle swarm optimization only shows the parts related to the embodiment of the present invention. Those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and may include more or fewer components than shown in the diagram, or combine certain components, or arrange the components differently.

[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 indicator 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 obtain the original water quality data of the estuary containing multiple water quality indicators in chronological order, and obtain the time series data set through data preprocessing;

[0115] The index number 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 data set, and retain the time series data of water quality indexes with Pearson correlation coefficients greater than the set standard threshold as the standby data set;

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

[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 data set to be used into a training set, a validation set and a test set according to the proportion;

[0119] The model training module is used to train and verify the water quality prediction model with the optimal hyperparameters using the training set and the validation set to obtain a trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation indicators 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 for prediction 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 embodiment of the hybrid deep learning estuary water quality prediction method based on particle swarm optimization are applicable to the embodiment of the hybrid deep learning estuary water quality prediction system based on particle swarm optimization. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here.

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

[0123] like Figure 8As shown, in one embodiment, a computer-readable storage medium is provided, in which a program is stored in a memory. When the program is executed by a processor, a hybrid deep learning estuary water quality prediction method based on particle swarm optimization is implemented, specifically:

[0124] The original water quality data of the estuary containing multiple water quality indicators are obtained in chronological order, and a time series data set is obtained through data preprocessing;

[0125] Taking dissolved oxygen as the target water quality indicator, the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series data set 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 standby data set;

[0126] Construct a water quality prediction model, including a time-domain 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, use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model, and obtain the water quality prediction model with the optimal hyperparameters;

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

[0129] The water quality prediction model with the optimal hyperparameters is trained and verified using the training set and the validation set to obtain a trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation indicators 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 result.

[0131] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0132] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, 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 implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.

Claims

1. A hybrid deep learning estuary water quality prediction method based on particle swarm optimization, characterized in that: The steps include: The original water quality data of the estuary containing multiple water quality indicators are obtained in chronological order, and a time series data set is obtained through data preprocessing; Taking dissolved oxygen as the target water quality indicator, the Pearson correlation coefficient between each water quality indicator and dissolved oxygen in the time series data set 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 standby data set; Construct a water quality prediction model, including a time-domain convolutional network, a long short-term memory neural network, a convolutional block attention network, and an output network; Initialize the water quality prediction model, use the particle swarm optimization algorithm to optimize the hyperparameters of the water quality prediction model, and obtain the water quality prediction model with the optimal hyperparameters; Divide the dataset to be used into training set, validation set and test set according to the proportion; The water quality prediction model with the optimal hyperparameters is trained and verified using the training set and the validation set to obtain a trained water quality prediction model; the performance of the trained water quality prediction model is evaluated on the test set using evaluation indicators 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 result.

2. The hybrid deep learning estuary water quality prediction method 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 estuary water quality prediction method according to claim 1, characterized in that: The time series data is obtained by data preprocessing, specifically: According to the 3σ principle, outliers in the original water quality data are removed, where σ represents the standard deviation of the original water quality data; After outliers were removed, linear interpolation was used to fill in missing values ​​in the original water quality data; After filling, the original water quality data are scaled to between 0 and 1 using the maximum and minimum normalization method; The sliding window is applied to slide step by step on the scaled original water quality data to segment the original water quality data into multiple continuous, fixed-length time series data to obtain a time series data set.

4. The hybrid deep learning estuary water quality prediction method 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 layer 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 time domain convolutional network.

5. The hybrid deep learning estuary water quality prediction method according to claim 1, characterized in that: The particle swarm optimization algorithm is used to optimize the hyperparameters of the water quality prediction model, specifically: Randomly initialize the particle group, particle velocity and particle position; Calculate the fitness value of each particle in the particle group, and record the individual optimal particle and the global optimal particle; Adjust the particle speed and particle position according to the speed update formula and the position update formula; Check whether the stopping condition is met. If so, the particle swarm optimization algorithm ends. Otherwise, continue to iteratively calculate the fitness value of each particle after the update and update the particle speed and particle position until the stopping condition is met.

6. The hybrid deep learning estuary water quality prediction method according to claim 5, characterized in that: 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 t In the iteration i Particles in d The speed after the update, v i,d ( t ) is the t In the iteration i Particles in d The speed before the update, ω is the inertia weight, c 1. c 2 is the learning factor, r1 and r2 are random numbers that are uniformly distributed in the interval [0,1]. x i,d ( t ) is the t In the iteration i Particles in d The position before the update, pBest i,d For the i Particles in d The optimal position of the dimension, gBest d For all particles in d The particle position with the best fitness. The position update formula is: 𝑥 𝑖,d (𝑡+1)=𝑥 𝑖,d (𝑡)+𝑣 𝑖,d (𝑡+1), Among them, 𝑥 𝑖,d (𝑡+1) is the t In the iteration i Particles in d The updated position.

7. The hybrid deep learning estuary water quality prediction method according to claim 1, characterized in that: The water quality prediction model with the optimal hyperparameters is trained as follows: The training set is input into the time domain convolutional network for convolution operation to extract local and global temporal features; Pass local and global temporal features to the 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 the long-term dependent features respectively, and the long-term dependent features are weighted to highlight the important feature channels and time positions to obtain weighted features; The output network is used to process the weighted features to obtain the prediction results.

8. The hybrid deep learning estuary water quality prediction method according to claim 1, characterized in that: The evaluation indicators include root mean square error, mean absolute error, mean absolute percentage error and goodness of fit.

9. A hybrid deep learning estuary water quality prediction system based on particle swarm optimization, characterized by: The hybrid deep learning estuary water quality prediction method applied to any one of claims 1-8 comprises 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 obtain the original water quality data of the estuary containing multiple water quality indicators in chronological order, and obtain a time series data set through data preprocessing; The index number 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 data set, and retain the time series data of water quality indexes with a Pearson correlation coefficient greater than a set standard threshold as a standby data set; The model building module is used to build a water quality prediction model, including a time domain 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 unused data set into a training set, a validation set and a test set according to a proportion; The model training module is used to train and verify the water quality prediction model with the optimal hyperparameters using the training set and the validation set to obtain a trained water quality prediction model; and to perform performance evaluation on the trained water quality prediction model on the test set using the evaluation index to obtain a 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 for prediction to obtain the prediction result.

10. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the hybrid deep learning estuary water quality prediction method described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

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

    CN118504615A

  • Construction method and application of hybrid deep learning prediction model based on SSA-VMD and CNN-BiLSTM

    CN119047516A

  • AU2020104000A4

Cited By

  • Red tide prediction method and system based on time interval and low-rank time frequency Traformer

    CN120541499A

  • A red tide prediction method and system based on time interval and low-rank time-frequency Trasformer

    CN120541499B

  • Water resource monitoring method based on big data

    CN120579067A