A water quality prediction method based on the deep learning model GCN-GRU of graph neural network

By constructing the graph neural network model GCN-GRU, combining the graph convolution network and gated cycle unit, the spatial and temporal correlation of the water quality monitoring station is captured, and the problems of spatial correlation and time dependence in water quality prediction are solved, achieving more accurate water quality prediction and model explanatory improvement.

CN119963367BActive Publication Date: 2025-08-29GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411968008.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-08-29
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

Existing water quality prediction methods are difficult to effectively capture the spatial correlation and time dependence between various water quality monitoring stations in the basin, resulting in inaccurate prediction results and lack of explanatory explanation.

Method used

The deep learning model GCN-GRU based on graph neural network is adopted, and the monitoring site is used as nodes by constructing a graph structure, and the spatial relationships of GCN are captured and time-dependent are captured. Combined with the self-attention mechanism and the fully connected network to integrate the spatiotemporal characteristics, a dynamic water quality prediction model is constructed.

Benefits of technology

It significantly improves the accuracy and interpretability of water quality prediction, can better simulate the pollutant transmission process, and enhances the reliability and interpretability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119963367B_ABST
    Figure CN119963367B_ABST
Patent Text Reader

Abstract

The present invention provides a water quality prediction method based on the deep learning model GCN-GRU of graph neural network. The distribution of monitoring stations and the adjacency relationship between monitoring stations are regarded as nodes and edges of the graph to construct a graph structure. The graph structure is used to retain the original spatial distribution of monitoring stations in the watershed, which can more accurately simulate the transmission process of pollutants and significantly improve the explanatory power of the model. By introducing graph convolutional networks and gated recurrent units, the spatial and temporal information in non-grid structured data can be effectively captured. Then, the self-attention mechanism and fully connected network are adopted to effectively integrate the 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.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of water quality prediction technology based on big data and artificial intelligence technology, and in particular to a water quality prediction method and system based on a graph neural network deep learning model GCN-GRU. Background Art

[0002] Currently, numerous water quality monitoring stations have been deployed across river basins, accumulating a vast amount of complex and highly nonlinear time series data. In this context, establishing an accurate and reliable water quality prediction system is crucial to assist decision makers in formulating policies to minimize damage to ecosystems. However, water quality changes are influenced by multiple factors, and their transmission processes and mechanisms are complex, posing significant challenges to simulation and prediction. Furthermore, previous methods have mostly only made predictions for a single monitoring station, ignoring the interconnectedness between stations within a river basin and lacking a spatial analysis of water quality changes. Therefore, utilizing deep learning models to effectively capture spatial information is crucial for accurately simulating and predicting pollutant transport behavior.

[0003] Process-driven methods, renowned for their solid physical foundations and strong interpretability, are essential 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 handling nonlinear problems, restricting their application in water quality prediction. To address these issues, machine learning methods have been introduced to water quality prediction to handle complex nonlinear problems. For example, randomized autoregressive integrated moving average models, random forests, and multivariate linear regression can extract deeper features from raw 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 excel 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 patterns of water quality changes. However, these methods struggle to capture spatial information due to the significant spatial correlations between multiple monitoring stations. Therefore, extracting spatial information and exploring pollutant evolution patterns are urgently needed to improve the predictive reliability of deep learning models.

[0004] Convolutional neural networks (CNNs) can effectively capture local features and their correlations in images through convolution operations. For example, some researchers have proposed a parallel-structured model (TransFuse) that utilizes CNNs 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 viable strategy. The basic idea is to map pollutant concentration data from monitoring stations into an image and use CNNs to model the spatial correlations between image grids, thereby extracting spatial information. For example, in 2021, Nie et al. proposed a water level prediction method combining CNNs and BiLSTMs, using CNNs to extract spatial features of water level data. In 2014, Sakiyama and Tanaka proposed a deep learning model for water level prediction that combined CNNs and GRUs, using CNNs to learn the spatial correlations between water level data observed at adjacent monitoring stations. However, due to the uneven distribution of monitoring stations within a region, the grid information in the image is difficult to accurately distinguish, which inevitably leads to errors in the modeling process. Image-based methods face challenges in processing such unstructured data. Therefore, the structure and performance of network models for spatiotemporal series data still need further improvement.

[0005] In recent years, graph neural networks (GNNs) have excelled in processing spatial information due to their exceptional ability to extract graph topology information. They have garnered widespread attention in diverse fields, including biotechnology, pharmaceuticals, knowledge graphs, social network analysis, and network traffic prediction. For example, in 2021, Yang et al. proposed a method (ConsisRec) for enhancing social recommendations using GNNs, which improves model performance by addressing social inconsistency. In 2021, Wang et al. proposed a functional connectivity-based graph convolutional network architecture (cGCN), which uses a graph structure to represent brain functional connectivity and extracts spatial features of connected neighborhoods through a GCN. In 2020, Lu et al. proposed an urban traffic flow prediction model (STAG-GCN) that uses GNNs to construct a fixed graph based on local spatial proximity to capture spatial correlations. Although some studies have attempted to apply GNNs to water quality prediction, the significant spatiotemporal heterogeneity of water quality data makes extracting and fusing complex spatiotemporal features in long time series a major challenge. Furthermore, previous studies have mostly focused on predictions at single sites, ignoring the spatial propagation characteristics of natural water pollution. The lack of spatial information during model construction not only affects the reliability of prediction results but also reduces the interpretability of the model. Therefore, how to more scientifically integrate the extracted spatiotemporal features is the key to accurately simulating and predicting water quality evolution. 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 =f1{f2(x n ,x n+1 ,…,x n+t ),f3(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 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 prior unknown functions;

[0012] S2, data collection and preprocessing: collecting and preprocessing pollutant variables and hydrological and meteorological data;

[0013] S3, graph construction: the monitoring stations in the predicted area 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 dataset 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 a preset loss function, thereby obtaining 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] In step S7, the pollutant variables and hydrological and meteorological data obtained in real time from the target monitoring station are input into the dynamic water quality prediction model of step S6, and after calculation, the water quality prediction result of the target monitoring station in the future preset time period is obtained.

[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 temporal dependency of data in the time series dataset, so as to capture spatial information and temporal information; then, the decoder is used to adopt the self-attention mechanism to analyze the correlation matrix of spatial information and temporal 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 predicted value, compare the predicted value with the label value and calculate the loss function value, continue to iterate until the model reaches the optimal value, that is, the loss function value is minimized, and output the spatial relationship, temporal relationship and spatiotemporal feature fusion function.

[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] Where X represents the value of the time series dataset; μ represents the mean of the time series dataset; σ represents the standard deviation of the time series dataset; 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 to construct a graph, which can be expressed mathematically 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] Where 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 GRU neuron consists 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 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-1is the hidden state of the previous moment; σ represents the Sigmoid nonlinear activation function, and tanh represents the hyperbolic tangent nonlinear activation function.

[0035] Furthermore, 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, 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 have a stable gradient during model 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; d 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 mathematically as:

[0044] y=a(x)·x#(10)

[0045] Where x represents input, y represents output, and 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 provides a water quality prediction method based on the deep learning model GCN-GRU of graph neural network, which regards the distribution of monitoring stations and the adjacency relationship between monitoring stations as nodes and edges of the graph to construct a graph structure, and uses the graph structure to retain the original spatial distribution of monitoring stations in the watershed, which can more accurately simulate the transmission process of pollutants and significantly improve the explanatory ability of the model; by introducing graph convolutional network (GCN) and gated recurrent unit (GRU), it can effectively capture the spatial and temporal information in non-grid structured data, and then adopt the self-attention mechanism (Self-attention) and fully connected network (FC) to effectively integrate the long-term spatiotemporal features in water quality time series data. It 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 This is a flowchart of a water quality prediction method based on a graph neural network deep learning model GCN-GRU according to a preferred embodiment of the present invention;

[0049] Figure 2 This is the water pollutant concentration prediction result of Yangshuo Station;

[0050] Figure 3 This is the water pollutant concentration prediction result of Jiaozhou Station;

[0051] Figure 4 Comparison of water quality 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 The scatter plot shows the prediction performance comparison 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 figure shows the medium- and long-term prediction results of GCN-GRU. DETAILED DESCRIPTION

[0056] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts 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 commonly understood by those skilled in the art to which this invention pertains. The terms used in this specification of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0058] See Figure 1 A preferred embodiment of the present invention provides a water quality prediction method based on a graph neural network deep learning model GCN-GRU, 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 =f1{f2(x n ,x n+1 ,…,x n+t ),f3(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 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 prior unknown functions.

[0062] Although water pollution is influenced by a combination of factors, its sustained impact is primarily reflected in the spatial correlations between multiple monitoring stations and historical time series data on pollutants. This invention automatically captures unknown multi-station relationships and complex spatiotemporal evolution patterns to construct 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 total nitrogen (TN), chemical oxygen demand (CODMn), ammonia nitrogen (NH3-N), and dissolved oxygen (DO). Hydrometeorological data include 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. Then, the data processed by the Z-score method is normalized. The calculation formula of the Z-score method is as follows:

[0066]

[0067] Where X represents the value of the time series dataset; μ represents the mean of the time series dataset; σ represents the standard deviation of the time series dataset; 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, forming a time series dataset with a graph structure.

[0069] In order to learn the transmission law 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 multiple methods for constructing adjacency matrices. Considering the spatial correlation between different sites, it is very important to construct a suitable adjacency matrix. In this embodiment, if the distance between 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, 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.

[0073] To effectively extract spatial and temporal information for water quality prediction, we propose an encoder composed of a GCN and a GRU. The encoder uses the GCN to learn complex spatial information in the graph structure, thereby capturing the spatial transport patterns of pollutants. The GRU then analyzes the temporal correlations of the data 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 implicit in non-Euclidean data. GCN can effectively capture the complex relationships between graph nodes and their surrounding nodes by aggregating information from adjacent graph nodes in the graph. It can be expressed mathematically as follows:

[0076]

[0077] Where 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. Its unique gating mechanism effectively alleviates the problems of vanishing and exploding gradients. Furthermore, GRU has a strong memory capacity and can better capture long-term dependencies in sequential data.

[0080] Each GRU neuron consists of a reset gate and an update gate. At each time step, the GRU operation process is expressed as:

[0081] r t =σ(W r ·[h t-1 ,x t ]+b r )# (5)

[0082] z t =σ(W z ·[h t-1 ,xt ]+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 in this embodiment combines GCN and GRU to learn the transmission patterns between monitoring stations, as well as the periodic laws and fluctuation characteristics in the data, thereby achieving effective encoding of spatial and temporal information.

[0087] To effectively integrate spatiotemporal features in water quality prediction, this example proposes a decoder consisting of a self-attention mechanism and a fully connected network (FC). The decoder uses the self-attention mechanism to learn the correlation matrix between spatiotemporal information, effectively integrating spatiotemporal features. The FC then uses the FC to adaptively adjust the spatiotemporal features at different time steps to ultimately 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 model's prediction accuracy. Specifically, it includes the following steps:

[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 have a stable gradient during model training, divide the score by dk 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; d 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] Where x represents input, y represents output, and 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, thereby obtaining 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 relationships in the graph structure to capture the spatial transmission patterns of pollutants, and the GRU is used to analyze the temporal dependencies of the data in the time series dataset to capture spatial and temporal information. Then, the decoder uses a self-attention mechanism to analyze the correlation matrix of spatial and temporal information to fuse spatiotemporal features, and adaptively extracts key information of spatiotemporal features at multiple time steps through a fully connected network. The spatiotemporal features at different time steps are adaptively adjusted to obtain the final predicted value, which is compared with the label value and the loss function value is calculated. The iteration continues until the model reaches the optimal value, that is, the loss function value is minimized, and the spatial relationship, temporal relationship, and spatiotemporal feature fusion function are output. This embodiment can use the loss function of the existing technology to train the model. To save space, the loss function will not be described in detail.

[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] In step S7, the pollutant variables and hydrological and meteorological data obtained in real time from the target monitoring station are input into the dynamic water quality prediction model of step S6, and after calculation, the water quality prediction result of the target monitoring station in the future preset time period is obtained.

[0106] The following is an example of a specific embodiment to illustrate the effect of the water quality prediction method based on the graph neural network deep learning model GCN-GRU of the present invention.

[0107] The Li River Basin in Guilin, nestled within a typical karst landscape, is renowned for its rich geographical features and diverse ecosystems, providing a unique platform for environmental science research. Water quality in this region is complex and variable, influenced by multiple factors, including agricultural activities, industrial emissions, tourism development, and natural conditions, exhibiting significant spatial and temporal variations. The Li River Basin, therefore, serves as an ideal testing ground for building graph neural network models, as its extensive monitoring data effectively validates the performance of our proposed model. This study specifically selected eight representative monitoring stations—Yangshuo, Jiaozhou, Qiaotou, Dayongjiang, the reservoir outlet, Huangshawan, Guanyan, and Fuxing—to obtain continuous hourly data. These data not only cover a variety of raw pollutant information but also include detailed hydrometeorological parameters. Table 1 lists the pollutant variables and hydrometeorological parameters in the basic dataset. Pollutant variables include total nitrogen (TN), chemical oxygen demand (CODMn), ammonia nitrogen (NH₃–N), and dissolved oxygen (DO). Hydrometeorological parameters include variables such as water temperature (WT), pH (pH), electrical conductivity (EC), and turbidity (TB). To assess water quality changes, we selected dissolved oxygen (DO) and total nitrogen (TN) as the primary analysis targets. Hourly data from January 2020 to December 2022 served as the baseline 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 model training, 20% for hyperparameter tuning, and the remaining 20% ​​for final verification of the model's predictive capabilities.

[0108] Table 1

[0109]

[0110] The evaluation indicators used are root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) to assess the effectiveness of the model. The three indicators 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 experiments were trained on a server equipped with an NVIDIA A100 Tensor Core GPU (40GB of video memory) and an Intel(R) Core(TM) i7-10700 CPU. The deep learning model was developed using Python 3.9 and PyTorch 1.11. Training was performed for 100 epochs with a batch size of 32. Adam was used as the optimization algorithm, with a learning rate of 0.001 and a weight decay rate of 0.0005. To avoid local overfitting, the inter-layer dropout probability was set to 0.2, and early training was implemented. Training was terminated 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 epochs, and the model was considered to have converged. The model parameters with the lowest loss on the validation set were saved as the optimal parameters and evaluated on the test set. The parameters of the GCN-GRU model with the best performance are shown in Table 2. After training, the MAE, RMSE, and SMAPE were calculated.

[0116] Table 2

[0117]

[0118] To evaluate the performance of the GCN-GRU model, Yangshuo and Jiaozhou stations were selected as representative stations, with DO and TN as evaluation indicators. The GCN-GRU model was trained using monitoring data from January 2020 to February 2022 to predict hourly DO and TN concentrations from March 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 Comparisons between model predictions and monitored values ​​are presented. At Yangshuo Station, the maximum relative errors for DO and TN were 10.8% and 18.6%, respectively. At Jiaozhou Station, the maximum relative errors for DO and TN were 11.4% and 19.8%, respectively. The experimental results demonstrate that the GCN-GRU model performs well across the entire prediction range. In particular, during periods of sudden changes in pollutant concentrations, the model is able to effectively reduce errors and demonstrate strong predictive capabilities. This demonstrates that the model is able to effectively learn spatial relationships between stations and capture temporal correlations, demonstrating excellent adaptability in addressing complex spatiotemporal variations.

[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 GCN-GRU model performs best based on the fit between the predicted and monitored values. This further validates the effectiveness of the GCN in capturing spatial correlations between sites and the GRU in capturing temporal patterns. Therefore, combining the two can more effectively extract spatiotemporal features, thereby improving prediction performance. Experimental results demonstrate that each module in the GCN-GRU model contributes significantly to 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 in the figure, it is intuitively demonstrated 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 to capture spatial correlation. However, it can be observed that the RMSE, MAE, and SMAPE values ​​of the GRU model are better than those of the GCN model. This may be due to the larger time step set in the experiment, and the GCN model lacks the ability to capture temporal patterns. At the same time, the GCN-GRU model performs best, which shows that combining GCN with GRU to improve long-time step prediction capabilities is necessary and effective, and can significantly improve the overall performance of the model. In general, the GCN model performs well in error evaluation indicators. The introduction of the graph structure helps the model 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, compared with the GCN and GRU models, the GCN-GRU model performs best in fitting the monitoring data curve. This demonstrates the necessity and effectiveness of the spatiotemporal feature fusion module to improve model performance. The core of this method lies in the introduction of a self-attention mechanism. By assigning different weights to different parts of the input data, it enhances the model's ability to capture key information, enabling it to better cope with the spatiotemporal heterogeneity of water quality data. Furthermore, it enhances the ability to comprehensively process data from multiple time steps, thereby improving prediction accuracy. Table 3 further shows the evaluation metrics of the prediction results. The GCN-GRU model performs best in metrics such as RMSE, MAE, and SMAPE. Although the GCN and GRU models also achieve good results, the GCN-GRU model achieves significant improvements in all evaluation metrics due to its spatial modeling and long-term dependency processing capabilities. Furthermore, the GCN-GRU model performs best in predicting DO and TN indicators across different sites, further demonstrating its superior generalization 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 example, the GCN-GRU model is also compared with five benchmark models, including 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 Random Forest and MLP models performed relatively poorly. This is primarily due to the difficulty these machine learning models have in effectively capturing temporal dependencies and dynamic changes in time series data. In contrast, RNN (recurrent neural network) and LSTM (long short-term memory) models demonstrated superior performance. These models are designed to process sequential data and can identify and exploit temporal correlations within time series to enhance prediction accuracy. The LSTM model, in particular, improves upon the traditional RNN by introducing a gated unit mechanism. This feature effectively mitigates the common vanishing and exploding gradient problems during training, enabling the LSTM to more robustly capture long-term data dependencies, further improving prediction performance. The Transformer architecture not only inherits the LSTM's ability to capture short- and long-term dependencies in time series data, but also utilizes a unique self-attention mechanism to model global information across the entire sequence. This mechanism allows the model to simultaneously consider information at all time points, resulting in superior performance in water quality prediction tasks compared to the LSTM. Finally, the GCN-GRU model achieved the highest performance, thanks to its ability to combine complex relationship modeling across both spatial and temporal dimensions. Specifically, the GCN component is responsible for expressing the spatial correlations between different monitoring sites, while the GRU focuses on time series analysis. Incorporating a graph structure into the model design to capture relationships between geographic locations, combined with a time series model, provides a new perspective and approach for improving water quality prediction, demonstrating significant advantages over 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 water quality indicators DO and TN concentrations 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, and all showed linear correlation. However, compared with the deep learning model, the difference between the predicted values ​​and 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. This is because the model retained the original distribution of the sites through the graph structure and was able to better learn the laws of pollutant transmission.

[0130] In time series prediction problems, whether the model can accurately predict 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 prediction performance at the hourly time scale. Figure 8 As shown in the figure, the prediction performance of all three models decreases as the time window increases. This phenomenon is mainly attributed to the increased uncertainty introduced by the long-term evolution of water quality, which in turn affects the accuracy of the model. In addition, GCN outperforms GRU in smaller time windows; however, as the time step increases, the prediction performance of GRU gradually surpasses 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 water pollutant concentrations helps decision makers develop effective environmental protection strategies, thereby reducing water pollution and protecting 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 a graph neural network (GCN-GRU) is proposed, which can effectively extract and fuse water quality spatiotemporal features. 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 reveals the transmission patterns of water pollutants under the influence of hydrological and meteorological variables.

[0132] To verify the effectiveness of the GCN-GRU model, a comparative experiment was conducted using a real dataset from the Guilin Ecological Environment Bureau. The experiments showed that the GCN-GRU model performed well in water quality prediction and was able to more accurately capture the diffusion patterns of water pollution transmission within the region. At the Yangshuo station, the model achieved RMSE, MAE, and SMAPE values ​​of 0.233, 0.162, and 0.016 for DO prediction, respectively, representing average improvements of 18.53%, 16.49%, and 11.11% compared to other methods. Based on the prediction results, this method demonstrated three significant advantages: First, compared to the traditional CNN model, the GNN model, by modeling the associations between monitoring stations and their sites as nodes and edges of a graph, allows for the effective extraction of spatial relationships between each monitoring station and its neighbors. Second, by 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 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 embodiments of the present invention, but the embodiments are not intended to limit the scope of the patent application of the present invention. Any equivalent changes or modifications 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): ; Where, Represents input; Represents the spatiotemporal characteristics of the target monitoring station; Represents the spatiotemporal characteristics of the target monitoring station and its surrounding monitoring stations; Indicates the input timestamp; represents the predicted value; Represents spatial relationship function; Represents a time relationship function; Represents the spatiotemporal feature fusion function, function 、 and is a priori unknown function; S2, data collection and preprocessing: collecting and preprocessing pollutant variables and hydrological and meteorological data; S3, graph construction: the monitoring stations in the predicted area 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 dataset 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 a preset loss function, thereby obtaining the spatial relationship, temporal relationship and spatiotemporal feature fusion function of the dynamic water quality prediction model; 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 temporal dependency of data in the time series dataset, so as to capture spatial information and temporal information; then, the decoder is used to use the self-attention mechanism to analyze the correlation matrix of spatial information and temporal information, so as to fuse 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 predicted value, compare the predicted value with the label value and calculate the loss function value, continue to iterate until the model reaches the optimal value, that is, the loss function value is minimized, and output the spatial relationship, temporal relationship and spatiotemporal feature fusion function; 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; In step S7, the pollutant variables and hydrological and meteorological data obtained in real time from the target monitoring station are input into the dynamic water quality prediction model of step S6, and after calculation, the water quality prediction result of the target monitoring station in the future preset time period is obtained.

2. The water quality prediction method based on the deep learning model GCN-GRU of the graph neural network according to claim 1 is 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. Then, the data processed by the Z-score method is normalized.

3. The water quality prediction method based on the deep learning model GCN-GRU of the graph neural network according to claim 2 is characterized in that: The calculation formula of the Z-score method is as follows: ; in, Represents the value of a time series dataset; Represents the mean of the time series data set; Represents the standard deviation of the time series data set; Indicates how different a data point is from the overall data.

4. The water quality prediction method based on the deep learning model GCN-GRU of the graph neural network according to 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 can be expressed mathematically as follows: ; Where, Indicates a site and sites the distance between them; is the weight value of the edge.

5. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network according to claim 1, characterized in that: In step S4, GCN effectively captures the complex relationships between graph nodes and their surrounding nodes by aggregating information about adjacent graph nodes in the graph, which can be expressed mathematically as follows: ; Where, It is The output of the spatial graph convolution layer; It is a feature that integrates short-term temporal information and spatial information; It is The weight matrix of the layer; is the adjacency matrix Add self-connection, that is, add the identity matrix ; yes degree matrix of ; is the activation function.

6. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network according to claim 1, characterized in that: In step S4, each GRU neuron consists of a reset gate and an update gate. At each time step, the GRU operation process is expressed as: ; ; ; ; in, is the input; 、 、 is a trainable parameter; operator represents element-wise multiplication; 、 、 is bias; It is the reset gate; It is the renewal gate; is a candidate hidden state; is to update the hidden state; is the hidden state at the previous moment; Represents the Sigmoid nonlinear activation function, represents the hyperbolic tangent nonlinear activation function.

7. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network according to claim 1, characterized in that: In step S4, the decoder is used to analyze the correlation matrix of spatial information and temporal information using a self-attention mechanism, 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 have a stable gradient during model 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, 、 、 Represent the query vector, key vector and value vector respectively; represents the dimension of the key vector; is the normalization function.

8. The water quality prediction method based on the deep learning model GCN-GRU of graph neural network according to claim 1, 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: ; Where, Represents input; Indicates output; Represents the correlation matrix.