Water quality prediction method of deep learning model GCN-GRU based on graph neural network
By using the graph neural network model GCN-GRU in water quality prediction, the spatial correlation and spatiotemporal characteristics between monitoring sites are captured, and the shortcomings of existing methods in capturing spatial and spatiotemporal information are solved, and more efficient and reliable water quality prediction is achieved.
Patent Information
- Application Number
- CN202411968008.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2044-12-30
AI Technical Summary
Existing water quality prediction methods are difficult to effectively capture the spatial correlation and spatiotemporal characteristics between multiple monitoring stations, resulting in insufficient reliability and interpretation of the prediction results.
The deep learning model GCN-GRU based on graph neural network is adopted to model the monitoring sites and their relationships by constructing graph structures, combining GCN and GRU to capture spatial and temporal information, and integrate spatiotemporal features through self-attention mechanism and fully connected network.
It significantly improves the reliability and interpretability of water quality prediction results, can more accurately simulate the pollutant transmission process, and enhances the model's interpretation ability.
Smart Images

Figure CN119963367A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of water quality prediction based on big data and artificial intelligence technology, and in particular to a water quality prediction method and system based on a deep learning model GCN-GRU of a graph neural network. Background Art
[0002] At present, many water quality monitoring stations have been deployed in various river basins, and a large amount of complex and highly nonlinear time series data has been accumulated. In this context, it is particularly important to establish an accurate and reliable water quality prediction system, which will help decision makers formulate relevant policies to minimize damage to the ecosystem. However, water quality changes are affected by many factors, and its transmission process and mechanism are complex, which brings great challenges to simulation and prediction. In addition, most previous methods only predict a single monitoring station, ignoring the correlation between stations in the basin and lacking spatial analysis of water quality changes. Therefore, it is of great significance to use deep learning models to effectively capture spatial information and accurately simulate and predict pollutant transport behavior.
[0003] Process-driven methods are known for their solid physical foundation and strong interpretability, and are important tools for developing water quality prediction models. For example, SWAP and HSPF have been widely used to simulate and predict the transport and transformation of pollutants in rivers. However, these methods have limitations in dealing with nonlinear problems, which restricts their application in the field of water quality prediction. To address these problems, machine learning methods have been introduced into the field of water quality prediction to deal with complex nonlinear problems. For example, random autoregressive integrated moving average model, random forest and multivariate linear regression can mine deeper features from the original data and achieve reliable computational performance. However, these methods have limitations in capturing long-term dependencies in time series data. In contrast, deep learning methods perform well in time series modeling and can capture temporal correlations in data. For example, recurrent neural networks, long short-term memory models, gated recurrent units and Transformer models can learn the periodic laws of water quality changes. However, there are significant spatial correlations between multiple monitoring stations, and these methods are difficult to capture spatial information. Therefore, extracting spatial information and exploring the laws of pollutant evolution are urgent needs to improve the prediction reliability of deep learning models.
[0004] Through convolution operations, convolutional neural networks can effectively capture local features and their correlations in images. For example, in the prior art, some scholars have proposed a model (TransFuse) with a parallel structure, which uses CNN to effectively capture low-level spatial details in images. Therefore, using image-based methods to extract spatial information between water quality monitoring stations is a feasible strategy. The basic idea is to map the pollutant concentration data of the monitoring station into the image, and use CNN to model the spatial correlation between image grids to extract spatial information. For example, Nie et al. proposed a water level prediction method combining CNN and BiLSTM in 2021, which uses CNN to extract the spatial features of water level data. Sakiyama and Tanaka proposed a water level prediction deep learning model combining CNN and GRU in 2014, using CNN to learn the spatial correlation between water level data observed by adjacent monitoring stations. However, due to the uneven distribution of monitoring stations in the region, the grid information in the image is difficult to distinguish accurately, which inevitably leads to errors in the modeling process. Image-based methods face challenges in processing such unstructured data. Therefore, for spatiotemporal series data, the structure and performance of network models still need to be further improved.
[0005] In recent years, graph neural networks have attracted extensive attention in many fields such as biotechnology, pharmaceuticals, knowledge graphs, social network analysis, and network traffic prediction due to their excellent ability to extract graph topology information and their outstanding performance in processing spatial information. For example, Yang et al. proposed a method (ConsisRec) using GNN to enhance social recommendation in 2021, which improves model performance by solving the social inconsistency problem. Wang et al. proposed a graph convolutional network architecture (cGCN) based on functional connectivity in 2021, which uses graph structure to represent brain functional connectivity and extracts spatial features of connectivity neighborhoods through graph convolutional networks. Lu et al. proposed an urban traffic flow prediction model (STAG-GCN) in 2020, which uses GNN to construct a fixed graph based on local spatial proximity to capture spatial correlation. At present, although some studies have tried to apply GNN to the field of water quality prediction, the water quality data itself has significant spatiotemporal heterogeneity, which makes it a major challenge to extract and fuse complex spatiotemporal features in long time series. In addition, most past studies have focused on the prediction of a single site, ignoring the spatial propagation characteristics of natural water pollution. If spatial information is lacking during model construction, it will not only affect the reliability of the prediction results, but also reduce the interpretability of the model. Therefore, how to more scientifically integrate the extracted spatiotemporal features is the key to accurately simulate and predict the evolution of water quality. Summary of the invention
[0006] In order to solve the technical problems raised in the above background technology, a water quality prediction method based on a deep learning model GCN-GRU of a graph neural network is provided, which improves the reliability of water quality prediction results.
[0007] In order to achieve the above object, the technical solution adopted by the present invention is:
[0008] A water quality prediction method based on a deep learning model GCN-GRU of a graph neural network includes the following steps:
[0009] S1, construct a dynamic water quality prediction model, the internal evolution relationship of the dynamic water quality prediction model is shown in formula (1):
[0010] y n+t+1 =f 1 {f 2 (x n ,x n+1 ,…,x n+t ),f 3 (J n ,J n+1 ,…,J n+t )}#(1)
[0011] In the formula, {(x n ,x n+1 ,…,x n+t ),(J n ,J n+1 ,…,J n+t )} represents the input; x represents the temporal and spatial characteristics of the target monitoring station; J represents the temporal and spatial characteristics of the target monitoring station and its surrounding monitoring stations; n~n+t represents the input timestamp; y represents the predicted value; f 2 represents the spatial relationship function; f 3 represents the time relationship function; f 1 Represents the spatiotemporal feature fusion function, function f 1 、f 2 and f 3 is a priori unknown function;
[0012] S2, data collection and preprocessing: collection and preprocessing of pollutant variables and hydrological and meteorological data;
[0013] S3, graph construction: the monitoring stations in the area to be predicted are regarded as graph nodes, the distance information between adjacent monitoring stations is regarded as the edges of the graph, and the pollutant variables and hydrological and meteorological parameters constitute the node features, forming a time series data set with a graph structure;
[0014] S4, constructing an encoder-decoder network model, wherein the encoder of the encoder-decoder network model is composed of GCN and GRU, and the decoder of the encoder-decoder network model is composed of a self-attention mechanism and a fully connected network;
[0015] S5, training the encoder-decoder network model according to the time series data set and the preset loss function, so as to obtain the spatial relationship, temporal relationship and spatiotemporal feature fusion function of the dynamic water quality prediction model;
[0016] S6, bringing the spatial relationship, temporal relationship and spatiotemporal feature fusion function obtained in step S5 into the dynamic water quality prediction model of step S1;
[0017] S7, inputting the pollutant variables and hydrological and meteorological data obtained in real time from the target monitoring station into the dynamic water quality prediction model of step S6, and obtaining the water quality prediction result of the target monitoring station in the future preset time period after calculation.
[0018] Furthermore, in step S5, for each iteration of training, first, the encoder GCN is used to learn the complex spatial relationship in the graph structure, so as to capture the spatial transmission law of pollutants, and the GRU is used to analyze the time dependency of data in the time series data set, so as to capture spatial information and time information; then, the decoder is used to use the self-attention mechanism to analyze the correlation matrix of spatial information and time information, so as to fuse the spatiotemporal features, and adaptively extract the key information of spatiotemporal features under multiple time steps through the fully connected network, and adaptively adjust the spatiotemporal features of different time steps to obtain the final prediction value, compare the prediction value with the label value and calculate the loss function value, and continue to iterate until the model is optimal, that is, the loss function value is minimized, and the spatial relationship, time relationship and spatiotemporal feature fusion function are output.
[0019] Furthermore, in step S2, after collecting pollutant variables and hydrological and meteorological data, first, the Z-score method is used to fill in the local missing data to ensure the smoothness of the data. At the same time, the Z-score method is used to screen and eliminate outliers in the data, and then the data processed by the Z-score method is normalized.
[0020] Furthermore, the calculation formula of the Z-score method is as follows:
[0021]
[0022] Among them, X represents the value of the time series data set; μ represents the mean of the time series data set; σ represents the standard deviation of the time series data set; and Z represents the degree of difference between a data point and the overall data.
[0023] Furthermore, in step S3, if the distance between the two monitoring stations is less than a preset distance threshold, it is considered that there is an adjacency relationship between the two monitoring stations, and the inverse of the distance between the two monitoring stations is used as the element value of the adjacency matrix, thereby constructing a graph, which is expressed in mathematical formula as follows:
[0024]
[0025] Where, d i,j represents the distance between site i and site j; w (i,j) is the weight value of the edge.
[0026] Furthermore, in step S4, GCN effectively captures the complex relationship between the graph node and its surrounding nodes by aggregating the information of adjacent graph nodes in the graph, which can be expressed as follows:
[0027]
[0028] In the formula, S (l) is the output of the lth spatial graph convolutional layer; F (l) It is a feature that combines short-term temporal information and spatial information; W (l) is the weight matrix of the lth layer; It is the adjacency matrix A plus the self-connection, that is, plus the identity matrix I; yes is the degree matrix; σ is the activation function.
[0029] Furthermore, in step S4, each neuron of the GRU is composed of a reset gate and an update gate. At each time step, the operation process of the GRU is expressed as:
[0030] r t =σ(W r ·[h t-1 ,x t ]+b r )# (5)
[0031] z t =σ(W z ·[h t-1 ,x t ]+b z )# (6)
[0032]
[0033]
[0034] Among them, x t is the input; W r , W z , W his a trainable parameter; the operator ⊙ represents element-wise multiplication; b r , b z , b h is the bias; r t is the reset gate; z t It is the update gate; is a candidate hidden state; h t is to update the hidden state; h t-1 is the hidden state of the previous moment; σ represents the Sigmoid nonlinear activation function, and tanh represents the hyperbolic tangent nonlinear activation function.
[0035] Further, in step S4, the decoder is used to adopt a self-attention mechanism to analyze the correlation matrix of spatial information and temporal information, so as to fuse the spatiotemporal features, which specifically includes the following steps:
[0036] Step 1: Use three different linear layers to map the input into three different new vectors: Query, Key, and Value.
[0037] Step 2: Multiply the query vector and the key vector to get a score vector. In order to make the model have a stable gradient during training, divide the score by d k is the dimension of the key vector;
[0038] Step 3: Process the result obtained in step 2 with the Softmax activation function, map the correlation coefficient to the interval (0,1), make the correlation coefficients all positive and sum to one, and obtain the correlation matrix;
[0039] Step 4: Multiply the correlation matrix obtained in step 3 by the Value vector to obtain the enhanced feature information;
[0040] The workflow of the self-attention mechanism is expressed mathematically as follows:
[0041]
[0042] Where Q, K, and V represent query vector, key vector, and value vector respectively; k represents the dimension of the key vector; Softmax(·) is the normalization function.
[0043] Furthermore, in step S4, the fully connected network filters important information from the input through adaptive adjustment and reduces the influence of interference signals. This function is achieved through the correlation matrix learned by the neural network, which maps the input to the output and is expressed as follows:
[0044] y=a(x)·x#(10)
[0045] In the formula, x represents input; y represents output; a(x) represents the correlation matrix.
[0046] Due to the adoption of the above technical solution, the present invention has the following beneficial effects:
[0047] The present invention discloses a water quality prediction method based on a deep learning model GCN-GRU of a graph neural network. The distribution of monitoring stations and the adjacency relationship between the monitoring stations are regarded as nodes and edges of a graph to construct a graph structure. The graph structure is used to retain the original spatial distribution of monitoring stations in a watershed, so that the transmission process of pollutants can be simulated more accurately and the explanatory power of the model can be significantly improved. A graph convolutional network (GCN) and a gated recurrent unit (GRU) are introduced to effectively capture spatial and temporal information in non-grid structured data. Then, a self-attention mechanism (Self-attention) and a fully connected network (FC) are used to effectively integrate long-term spatiotemporal features in water quality time series data. The method combines the advantages of GCN in spatial modeling and the capabilities of GRU in temporal modeling to achieve comprehensive capture of spatial correlation and temporal dependency, thereby improving the reliability of water quality prediction results and providing an important tool for environmental protection and pollution control. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A flowchart of a water quality prediction method based on a deep learning model GCN-GRU of a graph neural network according to a preferred embodiment of the present invention;
[0049] Figure 2 This is the prediction result of water pollutant concentration at Yangshuo Station;
[0050] Figure 3 This is the predicted result of water pollutant concentration at Jiaozhou Station;
[0051] Figure 4 Comparison of water pollutant prediction results of GCN, GRU, and GCN-GRU at Yangshuo station;
[0052] Figure 5 Comparison of water quality pollutant prediction results of GCN, GRU, and GCN-GRU at Jiaozhou Station;
[0053] Figure 6 This is a scatter plot comparing the prediction performance of the model at Yangshuo station;
[0054] Figure 7 This is a scatter plot comparing the prediction performance of the model at Jiaozhou station;
[0055] Figure 8 This is a graph showing the medium- and long-term prediction results of GCN-GRU. DETAILED DESCRIPTION
[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0058] See also Figure 1 A water quality prediction method based on a deep learning model GCN-GRU of a graph neural network is provided in a preferred embodiment of the present invention, comprising the following steps:
[0059] S1, build a dynamic water quality prediction model, the internal evolution relationship of the dynamic water quality prediction model is shown in formula (1):
[0060] y n+t+1 =f 1 {f 2 (x n ,x n+1 ,…,x n+t ),f 3 (J n ,J n+1 ,…,J n+t )}#(1)
[0061] In the formula, {(x n ,x n+1 ,…,x n+t ),(J n ,J n+1 ,…,J n+t )} represents the input; x represents the temporal and spatial characteristics of the target monitoring station; J represents the temporal and spatial characteristics of the target monitoring station and its surrounding monitoring stations; n~n+t represents the input timestamp; y represents the predicted value; f 2 represents the spatial relationship function; f 3 represents the time relationship function; f 1 Represents the spatiotemporal feature fusion function, function f 1 、f 2 and f 3 is a priori unknown function.
[0062] Although water pollution is affected by a combination of factors, its sustained impact is mainly reflected in the spatial correlation of multiple monitoring stations and the historical time series data of pollutants. The embodiments of the present invention automatically capture unknown multi-station relationships and complex spatiotemporal evolution laws to build an efficient dynamic water quality prediction model.
[0063] S2, data collection and preprocessing: collect and preprocess pollutant variables and hydrological and meteorological data.
[0064] Specifically, pollutant variables may include parameters such as total nitrogen (TN), chemical oxygen demand (CODMn), ammonia nitrogen (NH3-N), and dissolved oxygen (DO). Hydrometeorological data refer to electrical conductivity (EC), pH, turbidity (TB), and water temperature (WT).
[0065] In addition, due to factors such as instrument failure, environmental interference, and extreme weather, missing values and outliers appear in the monitoring data, which seriously affects the integrity and accuracy of the data. To this end, after collecting pollutant variables and hydrological and meteorological data, first, the Z-score method is used to fill in the local missing data to ensure the smoothness of the data. At the same time, the Z-score method is used to screen and eliminate outliers in the data, and then the data processed by the Z-score method is normalized. The calculation formula of the Z-score method is as follows:
[0066]
[0067] Among them, X represents the value of the time series data set; μ represents the mean of the time series data set; σ represents the standard deviation of the time series data set; and Z represents the degree of difference between a data point and the overall data.
[0068] S3, graph construction: The monitoring stations in the area to be predicted are regarded as graph nodes, the distance information between adjacent monitoring stations is regarded as the edges of the graph, and the pollutant variables and hydrological and meteorological parameters constitute the node features to form a time series data set with a graph structure.
[0069] In order to learn the transmission rules between sites, the water quality monitoring stations in the region are regarded as nodes of the graph, and their adjacency matrix is constructed. If there is an adjacency relationship between two monitoring stations, they are considered to have spatial correlation. There are currently a variety of methods for constructing adjacency matrices. Considering the spatial correlation between different sites, it is crucial to construct a suitable adjacency matrix. In this embodiment, if the distance between the two monitoring stations is less than a preset distance threshold, it is considered that there is an adjacency relationship between the two monitoring stations, and the inverse of the distance between the two monitoring stations is used as the element value of the adjacency matrix, thereby constructing a graph, which is expressed as follows:
[0070]
[0071] Where, d i,j represents the distance between site i and site j; w (i,j) is the weight value of the edge.
[0072] S4, construct an encoder-decoder network model, the encoder of the encoder-decoder network model is composed of GCN and GRU, and the decoder of the encoder-decoder network model is composed of a self-attention mechanism and a fully connected network.
[0073] In order to effectively extract spatial and temporal information in water quality prediction, an encoder composed of GCN and GRU is proposed. The encoder uses GCN to learn complex spatial information in the graph structure to capture the spatial transmission law of pollutants. Then, the temporal correlation of the data is analyzed by GRU to extract long-term and short-term dependencies.
[0074] (1) GCN
[0075] As an important deep learning method, GCN can effectively capture the complex relationships hidden in non-Euclidean data. GCN can effectively capture the complex relationships between graph nodes and their surrounding nodes by aggregating the information of adjacent graph nodes in the graph, which can be expressed mathematically as follows:
[0076]
[0077] In the formula, S (l) is the output of the lth spatial graph convolutional layer; F (l) It is a feature that combines short-term temporal information and spatial information; W (l) is the weight matrix of the lth layer; It is the adjacency matrix A plus the self-connection, that is, plus the identity matrix I; yes is the degree matrix; σ is the activation function.
[0078] (2) GRU
[0079] GRU is a variant of RNN. With its unique gating mechanism, it can effectively alleviate the problems of gradient vanishing and gradient exploding. In addition, GRU has a strong memory capacity and can better capture long-term dependencies in sequence data.
[0080] Each GRU neuron consists of a reset gate and an update gate. At each time step, the operation process of GRU is expressed as:
[0081] r t =σ(W r ·[h t-1 ,x t ]+b r)# (5)
[0082] z t =σ(W z ·[h t-1 ,x t ]+b z )# (6)
[0083]
[0084]
[0085] Among them, x t is the input; W r , W z , W h is a trainable parameter; the operator ⊙ represents element-wise multiplication; b r , b z , b h is the bias; r t is the reset gate; z t It is the update gate; is a candidate hidden state; h t is to update the hidden state; h t-1 is the hidden state of the previous moment; σ represents the Sigmoid nonlinear activation function, and tanh represents the hyperbolic tangent nonlinear activation function.
[0086] The encoder of this embodiment combines GCN and GRU, aiming to learn the transmission mode between monitoring stations, as well as the periodic laws and fluctuation characteristics in the data, so as to achieve effective encoding of spatial and temporal information.
[0087] In order to effectively integrate the spatiotemporal features in water quality prediction, this embodiment proposes a decoder composed of a self-attention mechanism and a fully connected network (FC). The decoder learns the correlation matrix between spatiotemporal information through the self-attention mechanism, thereby effectively integrating spatiotemporal features. Then, the fully connected network is used to adaptively adjust the spatiotemporal features of different time steps, and finally generate a prediction result.
[0088] (1) Self-attention mechanism
[0089] In time series forecasting, the self-attention mechanism assigns weights to each position by calculating the correlation between different positions in the input sequence, thereby better capturing the association between data and improving the prediction accuracy of the model. Specifically, the following steps are included:
[0090] Step 1: Use three different linear layers to map the input into three different new vectors: Query, Key, and Value.
[0091] Step 2: Multiply the query vector and the key vector to get a score vector. In order to make the model have a stable gradient during training, divide the score by d k is the dimension of the key vector;
[0092] Step 3: Process the result obtained in step 2 with the Softmax activation function, map the correlation coefficient to the interval (0,1), make the correlation coefficients all positive and sum to one, and obtain the correlation matrix;
[0093] Step 4: Multiply the correlation matrix obtained in step 3 by the Value vector to obtain the enhanced feature information;
[0094] The workflow of the self-attention mechanism is expressed mathematically as follows:
[0095]
[0096] Where Q, K, and V represent query vector, key vector, and value vector respectively; k represents the dimension of the key vector; Softmax(·) is the normalization function.
[0097] (2) Fully Connected Network (FC)
[0098] The fully connected network filters important information from the input through adaptive adjustment and reduces the impact of interference signals. This function is achieved through the correlation matrix learned by the neural network, which maps the input to the output and is expressed mathematically as:
[0099] y=a(x)·x#(10)
[0100] In the formula, x represents input; y represents output; a(x) represents the correlation matrix.
[0101] The decoder combines the self-attention mechanism and the fully connected network to decode the spatiotemporal information in the water quality time series data, thereby effectively fusing these features to obtain the final prediction results.
[0102] S5, training the encoder-decoder network model according to the time series data set and the preset loss function, so as to obtain the spatial relationship, temporal relationship and spatiotemporal feature fusion function of the dynamic water quality prediction model.
[0103] In step S5, for each iteration of training, first, the encoder GCN is used to learn the complex spatial relationship in the graph structure, so as to capture the spatial transmission law of pollutants, and the GRU is used to analyze the time dependency of data in the time series data set, so as to capture spatial information and time information; then, the decoder is used to use the self-attention mechanism to analyze the correlation matrix of spatial information and time information, so as to fuse the spatiotemporal features, and the key information of spatiotemporal features under multiple time steps is adaptively extracted through the fully connected network, and the spatiotemporal features of different time steps are adaptively adjusted to obtain the final prediction value, and the prediction value is compared with the label value and the loss function value is calculated, and the iteration is continued until the model reaches the optimal value, that is, the loss function value is minimized, and the spatial relationship, time relationship and spatiotemporal feature fusion function are output. This embodiment can use the loss function of the prior art to train the model. In order to omit space, the loss function is not repeated.
[0104] S6, bringing the spatial relationship, temporal relationship and spatiotemporal feature fusion function obtained in step S5 into the dynamic water quality prediction model of step S1;
[0105] S7, inputting the pollutant variables and hydrological and meteorological data obtained in real time from the target monitoring station into the dynamic water quality prediction model of step S6, and obtaining the water quality prediction result of the target monitoring station in the future preset time period after calculation.
[0106] The effect of the water quality prediction method based on the graph neural network deep learning model GCN-GRU of the present invention is explained below with a specific embodiment.
[0107] The Li River Basin in Guilin is located in a typical karst landform area, which is famous for its rich geographical features and diverse ecosystems, providing a unique platform for environmental science research. The water quality in the region is complex and changeable, and is affected by multiple factors such as agricultural activities, industrial emissions, tourism development and natural conditions, showing significant spatial and temporal differences. The Li River Basin is therefore an ideal experimental field for building graph neural network models, and its detailed monitoring data can effectively verify the performance of our proposed model. In this study, eight representative monitoring stations—Yangshuo, Jiaozhou, Qiaotou, Dayongjiang, reservoir outlet, Huangshawan, Guanyan and Fuxing—were specially selected to obtain continuous hourly data records, which not only cover a variety of raw pollutant information, but also contain detailed hydrometeorological parameters. Table 1 lists the pollutant variables and hydrometeorological parameters in the basic data set. Pollutant variables include total nitrogen (TN), chemical oxygen demand (CODMn), ammonia nitrogen (NH3–N) and dissolved oxygen (DO). Hydrometeorological parameters include variables such as water temperature (WT), pH (PH), electrical conductivity (EC), and turbidity (TB). In order to evaluate water quality changes, we selected dissolved oxygen DO and total nitrogen TN as the main analysis objects, and used hourly data from January 2020 to December 2022 as the benchmark training dataset to ensure the accuracy and reliability of model training and testing. In step S3, we divided the time series dataset into three parts: 60% for training the model, 20% for adjusting hyperparameters, and the remaining 20% for the final test of the model's predictive ability.
[0108] Table 1
[0109]
[0110] Evaluation indicators use root mean square error (RMSE), mean absolute error (MAE) and mean absolute percentage error (MAPE) to evaluate the effectiveness of the model. The three represent the deviation between the predicted results and the actual results. The smaller the deviation, the more accurate the result. The formula is as follows:
[0111]
[0112]
[0113]
[0114] Where n is the total number of samples, y i is the time series of monitoring, y′ i is the predicted time series.
[0115] The experiment was trained on a server equipped with an NVIDIA A100 Tensor Core GPU (40GB video memory) and an Intel (R) Core (TM) i7-10700 CPU. The deep learning model was developed using the framework of Python 3.9 and Pytorch 1.11. The training cycle was 100, the batch size was 32, the optimization algorithm was Adam, the learning rate was 0.001, and the weight decay rate was set to 0.0005. In order to avoid local overfitting, the inter-layer dropout probability was set to 0.2, and the strategy of early termination of training was adopted. When the loss of the encoder-decoder model (hereinafter referred to as the GCN-GRU model) on the validation set did not decrease for 20 consecutive cycles, the training stopped and the model was considered to have converged. The model parameters with the lowest loss on the validation set were saved as the best parameters and evaluated on the test set. The parameters of the GCN-GRU model with the best performance are shown in Table 2. After the training is completed, MAE, RMSE, and SMAPE are calculated.
[0116] Table 2
[0117]
[0118] In order to evaluate the performance of the GCN-GRU model, Yangshuo Station and Jiaozhou Station were selected as typical stations, and DO and TN were used as evaluation indicators. The GCN-GRU model was trained using monitoring data from January 2020 to February 2022 to predict hourly DO and TN concentration values from March 2022 to December 2022. The data was preprocessed before entering the model, and then trained.
[0119] To verify the accuracy of the model, the trained GCN-GRU model was evaluated using a test dataset from September 1 to September 16, 2022. During this period, the model accurately predicted the changing trends of DO and TN concentrations. Figure 2 and Figure 3 The comparison results between the model prediction value and the monitoring value are shown respectively. At Yangshuo Station, the maximum relative errors of DO and TN are 10.8% and 18.6%, respectively. At Jiaozhou Station, the maximum relative errors of DO and TN are 11.4% and 19.8%, respectively. The experimental results show that the GCN-GRU model has good prediction performance in the entire prediction range. Especially in the time period when the pollutant concentration suddenly changes, the model can fit the error well and show good prediction ability. This shows that the model can effectively learn the spatial relationship between stations and capture the temporal correlation, thereby showing excellent adaptability in dealing with complex spatiotemporal change factors.
[0120] In order to verify the effectiveness of each model component in improving model performance, an ablation experiment was designed and conducted. Specific components (such as GCN and GRU) were removed from the hybrid model one by one, and Yangshuo Station and Jiaozhou Station were used as typical stations to conduct ablation experiments on the GCN, GRU and GCN-GRU models to predict DO and TN concentrations in the next 48 hours. Under the same number of training iterations and parameter settings, the specific performance of each model is shown in Table 3. By analyzing the evaluation indicators of each model and combining Figure 4 and Figure 5 The fit between the predicted value and the monitored value in the figure shows that the GCN-GRU model performs best. In addition, this further verifies the effectiveness of GCN in capturing spatial correlation between sites and GRU in capturing temporal patterns. Therefore, the combination of the two can more effectively extract spatiotemporal features, thereby improving prediction performance. The experimental results show that each module in the GCN-GRU model is effective in improving model performance.
[0121] Table 3
[0122]
[0123] In order to further verify the ability of the GCN model in extracting spatial information, in this work, it is applied to the prediction of DO and TN concentrations in water quality. In addition, the experiment designed prediction tasks of different time periods to comprehensively evaluate the generalization ability of the GCN model in water quality prediction. The experimental results are shown in Figure 2. Figure 4 and Figure 5 As shown, it is intuitively shown that the GCN model fits the monitoring data curve well. Furthermore, Table 3 lists the evaluation indicators of the prediction results. It can be seen that the RMSE, MAE and SMAPE values of the GCN model perform well, which shows that the GCN model has excellent ability in capturing spatial associations. However, it can be observed that the RMSE, MAE and SMAPE values of the GRU model are better than those of the GCN model, which may be due to the larger time step set in the experiment, and the GCN model lacks the ability to capture time patterns. At the same time, the GCN-GRU model performs best, which shows that it is necessary and effective to combine GCN with GRU to improve the long-time step prediction ability, which can significantly improve the overall performance of the model. In general, the GCN model performs well in error evaluation indicators, and the introduction of the graph structure helps the model to more effectively utilize the spatial correlation information between monitoring stations, thereby achieving better performance.
[0124] The core module of this paper is the spatiotemporal feature fusion step. This step aims to address the limitations of GCN in processing temporal dependencies and the neglect of GRU in spatial dependencies. To this end, a decoder combining the self-attention mechanism and the fully connected network is designed to effectively integrate the advantages of GCN and GRU and enhance the model's ability to extract and fuse spatiotemporal information. The experimental results are shown in Figure 2. Figure 4 and Figure 5 As shown in the figure, compared with GCN and GRU, the GCN-GRU model performs best in fitting the monitoring data curve. This verifies the necessity and effectiveness of the spatiotemporal feature fusion module to improve the model performance. The core of this method is to introduce the Self-attention mechanism. By assigning different weights to different parts of the input data, the model's ability to capture key information is improved, enabling it to better cope with the spatiotemporal heterogeneity in water quality data. In addition, the comprehensive processing capability of multi-time step data is enhanced, thereby improving the accuracy of prediction. Further, Table 3 shows the evaluation indicators of the prediction results. Among them, the GCN-GRU model performs best in indicators such as RMSE, MAE and SMAPE. Although the GCN and GRU models also achieved good results, the GCN-GRU model achieved significant improvements in various evaluation indicators by virtue of its spatial modeling and long-term dependency processing capabilities. In addition, the GCN-GRU model performed best in the prediction of DO and TN indicators at different sites, further demonstrating its superior generalization ability and stability. Overall, the GCN-GRU model can effectively capture the spatial correlation between sites and the temporal dependency of data, verifying the effectiveness of the designed spatiotemporal feature fusion module.
[0125] In this embodiment, the GCN-GRU model is also compared with five benchmark models, namely Random Forest, MLP, RNN, LSTM and Transformer, to verify the superiority of the proposed model.
[0126] Table 4 lists the specific performance results of the six models. Among the evaluated prediction methods, the performance of Random Forest and MLP models is relatively unsatisfactory, which is mainly attributed to the fact that these two machine learning models are difficult to effectively capture the temporal dependencies and dynamic changes in time series data. In contrast, RNN (recurrent neural network) and LSTM (long short-term memory network) models show better performance because they are designed to process sequence data and can identify and utilize the temporal correlation in time series to enhance prediction accuracy. In particular, the LSTM model, compared with the traditional RNN, has the advantage of introducing a gated unit mechanism. This feature effectively alleviates the common gradient vanishing and gradient exploding problems in the training process, allowing LSTM to more robustly capture long-span data dependencies, thereby further improving the prediction effect. The Transformer architecture not only inherits LSTM's ability to capture long-term and short-term dependencies in time series data, but also realizes global information modeling of the entire sequence through a unique Self-Attention mechanism. This mechanism allows the model to consider information at all time points at the same time, so it has achieved performance that exceeds LSTM in water quality prediction tasks. Finally, the GCN-GRU model showed the highest performance level, thanks to its ability to combine complex relationship modeling in spatial and temporal dimensions. Specifically, the GCN part is responsible for expressing the spatial associations between different monitoring sites, while the GRU focuses on time series analysis. Incorporating graph structures into model design to capture the relationship between geographic locations and combining them with time series models provides new perspectives and methods for improving water quality prediction, showing more significant advantages than other single models.
[0127] Table 4
[0128]
[0129] In order to show the prediction effect more intuitively, Figure 6 and Figure 7 The performance of the GCN-GRU model and five baseline models in predicting the concentrations of water quality indicators DO and TN was compared, and scatter plots of the predicted values and monitored values were presented. The trends of the prediction curves and monitoring curves of all models were roughly consistent, showing a linear correlation. However, compared with the deep learning model, the difference between the predicted values and the monitored values of the machine learning model was larger, which highlights the importance of the ability to capture time dependencies. Next, the model that did not introduce the graph structure had relatively poor prediction results because it ignored the importance of spatial relationships. Overall, the GCN-GRU model had the best prediction results at all stages because the model retained the original distribution of the sites through the graph structure and was able to better learn the laws of pollutant transport.
[0130] In the problem of time series prediction, whether the model can accurately predict the medium- and long-term results is crucial. In this experiment, three models, GCN, GRU and GCN-GRU, were selected to explore the impact of different models and different time window sizes on the prediction performance at the hourly time scale. Figure 8 As shown in the figure, as the time window increases, the prediction performance of the three models decreases. This phenomenon is mainly attributed to the fact that water quality introduces more uncertainty in the long-term evolution process, which in turn affects the accuracy of the model. In addition, GCN performs better than GRU under smaller time windows; however, as the time step increases, the prediction performance of GRU gradually exceeds that of GCN. This shows that the graph structure of GCN has advantages in capturing short-term dynamic changes, but has shortcomings in long-term prediction. Overall, the GCN-GRU model performs best because it can effectively combine spatial and temporal correlations and handle highly nonlinear and complex long-term series data.
[0131] Accurately predicting the concentration of water pollutants can help decision makers develop effective environmental protection strategies to reduce water pollution and protect human health. However, due to the unstructured nature of water quality data, traditional methods face challenges in capturing the spatial dependencies between monitoring stations. In this implementation, a deep learning model based on graph neural network (GCN-GRU) is proposed, which can effectively extract and fuse water quality spatiotemporal characteristics. Experimental results show that GCN-GRU not only performs well in prediction performance by capturing the spatial and temporal correlations in water quality time series data, but also can reveal the transmission laws of water quality pollutants under the influence of hydrological and meteorological variables.
[0132] In order to verify the effectiveness of the GCN-GRU model, a comparative experiment was conducted using a real data set from the Guilin Ecological Environment Bureau. The experiment showed that the GCN-GRU model performed well in water quality prediction and could more accurately capture the diffusion law of water pollution transmission in the region. At the Yangshuo station, the RMSE, MAE, and SMAPE values of the model in DO prediction were 0.233, 0.162, and 0.016, respectively, which were 18.53%, 16.49%, and 11.11% higher than other methods on average. Based on the prediction results, this method showed three significant advantages: First, compared with the traditional CNN model, the GNN model models the associations between monitoring stations and their sites as nodes and edges of the graph. This flexible modeling method can effectively extract the spatial relationship between each monitoring station and its adjacent sites. Secondly, combining the spatial modeling advantages of GCN with the temporal modeling capabilities of GRU, it can effectively extract long-term spatiotemporal dependencies, thereby significantly improving the prediction performance. Finally, the proposed decoder consisting of a self-attention mechanism and a fully connected network can adaptively capture the influence of the spatiotemporal features fused from multiple time steps on the current moment, which plays an important role in improving the model performance.
[0133] The above description is a detailed description of the preferred feasible embodiments of the present invention, but the embodiments are not intended to limit the scope of the patent application of the present invention. All equivalent changes or modified changes completed under the technical spirit suggested by the present invention should fall within the patent scope covered by the present invention.
Claims
1. A water quality prediction method based on the deep learning model GCN-GRU of graph neural network, characterized in that: The following steps are involved: S1, construct a dynamic water quality prediction model, the internal evolution relationship of the dynamic water quality prediction model is shown in formula (1): y n+t+1 =f1{f2(x n ,x n+1 ,…,x n+t ),f3(J n ,J n+1 ,…,J n+t )}#(1) In the formula, {(x n ,x n+1 ,…,x n+t ),(J n ,J n+1 ,…,J n+t )} represents the input; x represents the spatiotemporal characteristics of the target monitoring station; J represents the spatiotemporal characteristics of the target monitoring station and its surrounding monitoring stations; n~n+t represents the input timestamp; y represents the predicted value; f2 represents the spatial relationship function; f3 represents the temporal relationship function; f1 represents the spatiotemporal feature fusion function, and functions f1, f2 and f3 are a priori unknown functions; S2, data collection and preprocessing: collection and preprocessing of pollutant variables and hydrological and meteorological data; S3, graph construction: the monitoring stations in the area to be predicted are regarded as graph nodes, the distance information between adjacent monitoring stations is regarded as the edges of the graph, and the pollutant variables and hydrological and meteorological parameters constitute the node features, forming a time series data set with a graph structure; S4, constructing an encoder-decoder network model, wherein the encoder of the encoder-decoder network model is composed of GCN and GRU, and the decoder of the encoder-decoder network model is composed of a self-attention mechanism and a fully connected network; S5, training the encoder-decoder network model according to the time series data set and the preset loss function, so as to obtain the spatial relationship, temporal relationship and spatiotemporal feature fusion function of the dynamic water quality prediction model; S6, bringing the spatial relationship, temporal relationship and spatiotemporal feature fusion function obtained in step S5 into the dynamic water quality prediction model of step S1; S7, inputting the pollutant variables and hydrological and meteorological data obtained in real time from the target monitoring station into the dynamic water quality prediction model of step S6, and obtaining the water quality prediction result of the target monitoring station in the future preset time period after calculation.
2. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 1, characterized in that: In step S5, for each iteration of training, first, the encoder GCN is used to learn the complex spatial relationship in the graph structure, so as to capture the spatial transmission law of pollutants, and the GRU is used to analyze the time dependency of data in the time series data set, so as to capture spatial information and time information; then, the decoder is used to use the self-attention mechanism to analyze the correlation matrix of spatial information and time information, so as to fuse the spatiotemporal features, and adaptively extract the key information of spatiotemporal features under multiple time steps through the fully connected network, and adaptively adjust the spatiotemporal features of different time steps to obtain the final prediction value, compare the prediction value with the label value and calculate the loss function value, and continue to iterate until the model is optimal, that is, the loss function value is minimized, and the spatial relationship, time relationship and spatiotemporal feature fusion function are output.
3. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 1, characterized in that: In step S2, after collecting pollutant variables and hydrological and meteorological data, first, the Z-score method is used to fill in the local missing data to ensure the smoothness of the data. At the same time, the Z-score method is used to screen and eliminate outliers in the data, and then the data processed by the Z-score method is normalized.
4. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 3 is characterized in that: The calculation formula of the Z-score method is as follows: Among them, X represents the value of the time series data set; μ represents the mean of the time series data set; σ represents the standard deviation of the time series data set; and Z represents the degree of difference between a data point and the overall data.
5. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 1, characterized in that: In step S3, if the distance between the two monitoring stations is less than a preset distance threshold, it is considered that there is an adjacency relationship between the two monitoring stations, and the inverse of the distance between the two monitoring stations is used as the element value of the adjacency matrix to construct a graph, which is expressed in mathematical formula as follows: Where, d i,j represents the distance between site i and site j; w (i,j) is the weight value of the edge.
6. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 2, characterized in that: In step S4, GCN effectively captures the complex relationship between the graph node and its surrounding nodes by aggregating the information of adjacent graph nodes in the graph, which can be expressed as follows: In the formula, S (l) is the output of the lth spatial graph convolutional layer; F (l) It is a feature that combines short-term temporal information and spatial information; W (l) is the weight matrix of the lth layer; It is the adjacency matrix A plus the self-connection, that is, plus the identity matrix I; yes is the degree matrix; σ is the activation function.
7. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 2, characterized in that: In step S4, each neuron of the GRU consists of a reset gate and an update gate. At each time step, the operation process of the GRU is expressed as: r t =σ(W r ·[h t-1 ,x t ]+b r )#(5) z t =σ(W z ·[h t-1 ,x t ]+b z )#(6) Among them, x t is the input; W r , W z , W h is a trainable parameter; the operator ⊙ represents element-wise multiplication; b r 、b z 、b h is the bias; r t is the reset gate; z t It is the update gate; is a candidate hidden state; h t is to update the hidden state; h t-1 is the hidden state of the previous moment; σ represents the Sigmoid nonlinear activation function, and tanh represents the hyperbolic tangent nonlinear activation function.
8. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 2, characterized in that: In step S4, the decoder is used to adopt a self-attention mechanism to analyze the correlation matrix of spatial information and temporal information, thereby fusing spatiotemporal features. Specifically, the following steps are included: Step 1: Use three different linear layers to map the input into three different new vectors: Query, Key, and Value. Step 2: Multiply the query vector and the key vector to get a score vector. In order to make the model have a stable gradient during training, divide the score by d k is the dimension of the key vector; Step 3: Process the result obtained in step 2 with the Softmax activation function, map the correlation coefficient to the interval (0,1), make the correlation coefficients all positive and sum to one, and obtain the correlation matrix; Step 4: Multiply the correlation matrix obtained in step 3 by the Value vector to obtain the enhanced feature information; The workflow of the self-attention mechanism is expressed mathematically as follows: Where Q, K, and V represent query vector, key vector, and value vector respectively; k represents the dimension of the key vector; Softmax(·) is the normalization function.
9. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network as claimed in claim 2, characterized in that: In step S4, the fully connected network filters important information from the input through adaptive adjustment and reduces the influence of interference signals. This function is achieved through the correlation matrix learned by the neural network, which maps the input to the output and is expressed mathematically as: y=a(x)·x#(10) In the formula, x represents input; y represents output; a(x) represents the correlation matrix.
Citation Information
Patent Citations
Drainage basin water quality prediction method based on OVMD-GAT-GRU
CN116307232A
Water quality data prediction method based on improved Re-GCN model
CN116882539A
Traffic flow prediction method and system based on trend space-time diagram convolution, and medium
CN116895157A
Cited By
Power grid data anomaly detection method and system based on hybrid deep learning model
CN120524401A
Multi-modal data fusion method and device, equipment and medium
CN120543998A
Method and system for centralized reading management of water meters in water affairs
CN120763759A
Groundwater pollution concentration prediction method of time-space diagram neural network fused with physical constraint
CN120850751A
Deep learning-based water quality prediction method and system for trunk and branch water delivery system
CN120911750A