Water quality prediction method based on graph neural network and spatial-temporal feature fusion
By using the method of fusion of graph neural networks and space-time features in water quality prediction, the problem of neglecting spatial correlation and space-time changes in the existing technology is solved, and a higher accuracy and explanatory water quality prediction are achieved.
Patent Information
- Application Number
- CN202411674705.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-11
AI Technical Summary
The existing water quality prediction methods ignore the spatial correlation and spatiotemporal changes between various monitoring stations in the basin, resulting in insufficient understanding and prediction capabilities of the model for global water quality changes.
Using a method based on the fusion of graph neural networks and spatiotemporal features, a deep learning model of graph topology networks and spatiotemporal feature fusion modules, including graph convolutional networks, gated loop units and self-attention mechanisms, is used to extract and fuse spatial and temporal features between monitoring stations to form a deep learning model of graph topology structure.
Effectively respond to the temporal and spatial changes of water pollution, reduce the cost of water quality prediction, improve the accuracy of water quality prediction, and enhance the interpretability of water quality prediction results.
Smart Images

Figure CN119598402A_ABST
Abstract
Description
Technical Field
[0001] This application involves the intersection of environmental big data and deep learning, specifically a water quality prediction method based on the fusion of graph neural networks and spatiotemporal features. Background Art
[0002] Water is one of the most precious resources on earth, but with the expansion of human activities and the acceleration of industrialization, water resources are facing an increasingly severe threat of pollution. To meet this challenge, many water quality monitoring stations have been deployed in various river basins, accumulating a large amount of complex and highly nonlinear time series data, providing the basic conditions for the application of artificial intelligence deep learning technology in water quality prediction. 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 of the existing deep learning prediction methods for water environment focus on the analysis and modeling of a single monitoring station, ignoring the spatial correlation between stations in the river basin and the impact of spatial proximity on the evolution of the water environment of the monitoring station. This limitation weakens the model's ability to understand and predict global water quality changes. In recent years, graph neural networks have attracted widespread attention in many fields such as biotechnology, pharmaceuticals, knowledge graphs, social network analysis, and network traffic prediction because they use graph convolution and graph attention mechanism technologies to learn the feature information of spatial nodes and graph topology structures, thereby improving the performance of deep learning models in processing complex graph topology data. In an environment with complex spatial relationships and dynamic factors, graph neural networks show potential in accurately predicting water quality, which makes them particularly valuable in predicting the water quality of interconnected water bodies. Therefore, how to more scientifically integrate and extract these spatiotemporal features becomes the key to accurately simulate and predict the evolution of water quality. The structure and performance of deep learning coupling models still need to be further improved. Summary of the invention
[0003] The purpose of the present invention is to provide a water quality prediction method based on graph neural network and spatiotemporal feature fusion to address the deficiencies of the prior art. This method can effectively cope with the spatiotemporal variation of water pollution, reduce the cost of water quality prediction, and improve the accuracy of water quality prediction.
[0004] The technical solution for achieving the purpose of the present invention is:
[0005] A water quality prediction method based on graph neural network and spatiotemporal feature fusion includes the following steps:
[0006] 1) Data collection and preprocessing: Collect and preprocess the water quality and hydrological hourly data of multiple monitoring stations in the predetermined area, specifically:
[0007] 1-1) Monitoring station selection: Collect data from multiple different monitoring stations as data sources;
[0008] 1-2) Pollutant data collection: Water quality data include at least two of dissolved oxygen, permanganate, ammonia nitrogen and total nitrogen; hydrological data include conductivity, pH value, turbidity value and water temperature;
[0009] 1-3) Pollutant data processing: The standardized score Z-score method is used to process missing values and outliers in the monitoring data. The Z-score method subtracts the mean and divides by the standard deviation to make the data conform to the standard normal distribution. Missing values include: the data collected by the monitoring station is empty, and outliers include: the data collected by the monitoring station is non-numeric.
[0010] The calculation of Z-score is shown in formula (1):
[0011]
[0012] Where X represents a single data value of the time series data, μ represents the mean of the data set, σ represents the standard deviation of the data set, and Z represents the degree of difference between a single data point and the overall data set;
[0013] 2) Constructing a graph topology network: multiple monitoring stations in a predetermined area are represented as nodes of a graph, and the adjacency relationships between monitoring stations are used as edges of the graph, where the weight of the edge is the inverse of the geographical distance of the monitoring stations. Specifically, the monitoring stations, adjacency relationships, water quality data, and hydrological parameters collected in step 1) are used as input features to construct a graph topology network that retains the original spatial distribution characteristics of the basin stations.
[0014] The mathematical expression of the graph topology network is shown in formula (2):
[0015]
[0016] Among them A D represents the adjacency matrix, d i,j represents the distance between site i and site j, R D is the maximum value of the distance, R D Set to 20km. Only when the geographical distance between monitoring stations is less than this value, a connection will be established;
[0017] 3) Fusion: Construct a spatiotemporal feature fusion module to extract and fuse the graph topology network obtained in step 2) to obtain the spatiotemporal feature data of water pollution and form a deep learning model input data set with a graph topology structure. The spatiotemporal feature fusion module includes a graph convolution network, a gated recurrent unit, and a self-attention mechanism, specifically:
[0018] 3-1) Graph Convolutional Network: Using the message passing paradigm based on graph convolution, the adjacency relationship between monitoring stations and sites is modeled as a graph structure, so that each monitoring station is connected into a spatially interconnected network to effectively extract the spatial features between monitoring stations. The calculation of the graph convolutional network is shown in formula (3):
[0019]
[0020] Where H represents the feature matrix of the graph convolution layer, l is the number of graph convolution layers, and W is the weight matrix. is the adjacency matrix A plus the identity matrix I, yes The degree matrix of , σ is the activation function;
[0021] 3-2) Gated recurrent unit: The gating mechanism is used to achieve a balance between retaining and forgetting past historical information, which helps to more accurately capture the periodicity of pollutants and effectively extract the time characteristics of each monitoring station. The calculation formula of the gated recurrent unit is shown in formula (4), formula (5), formula (6), and formula (7):
[0022] r t =σ(W r ·[h t-1 , x t ]+b r ) (4),
[0023] z t =σ(W z ·[h t-1 , x t ]+b z ) (5),
[0024]
[0025]
[0026] where x t is the input, W r , W z , W h is a trainable weight 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, σ and tanh represent nonlinear activation functions;
[0027] 3-3) Self-attention mechanism: Dynamically allocate weight matrix, calculate the correlation between spatial features and temporal features, obtain water pollution spatiotemporal features by weighted fusion, reduce related redundant features, and obtain water pollution spatiotemporal feature data. The mathematical formula of the self-attention mechanism is shown in formula (8):
[0028]
[0029] Where Q, K, and V represent the Query vector, Key vector, and Value vector, respectively. k represents the dimension of the Key vector, Softmax(·) is a normalization function to calculate the similarity;
[0030] 4) Dataset processing: Construct a graph time series prediction model to process the deep learning model input data set of the graph topology structure obtained in step 3) to complete the spatiotemporal prediction tasks of multiple monitoring stations. The graph time series prediction model includes spatial graph convolution and fully connected network, specifically:
[0031] 4-1) Spatial graph convolution: The convolution operation is used to process the fused spatiotemporal characteristics of water pollution to generate characteristic information of multiple monitoring stations;
[0032] 4-2) Fully connected network: Adaptively integrate the feature information combination, comprehensively consider the potential impact of hydrological parameters on water quality, and generate water quality prediction results for each monitoring station in the target time period;
[0033] 5) Effect verification: The root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (SMAPE) are used to evaluate the prediction results obtained in step 4). The data is normalized during the model training process. The parameters of the deep learning model are adjusted according to the Adam optimizer. The weight decay method, packet loss method, and early stopping method are combined to suppress overfitting. The effect is verified by comparing with other benchmark models, including:
[0034] 5-1) RMSE, MAE and SMAPE represent the deviation between the predicted results and the actual results. The smaller the deviation, the more accurate the result.
[0035] The calculation of RMSE is shown in formula (9):
[0036]
[0037] The calculation of MAE is shown in formula (10):
[0038]
[0039] The calculation of SMAPE is shown in formula (11):
[0040]
[0041] In the formula, n is the total number of samples, y is i is the time series of monitoring, y′ i is the predicted time series;
[0042] 5-2) Normalization: Normalization is to scale the data to the range of 0 to 1, which accelerates the training process of the model and improves the convergence speed;
[0043] 5-3) Weight decay method: Add a regularization term to the objective function to prevent the model from overfitting;
[0044] 5-4) Packet Dropping: Randomly discarding neural network units to prevent overfitting of the model;
[0045] 5-5) Early stopping method: Monitor the performance of the model on the validation set and stop training when overfitting begins to occur;
[0046] 5-6) Other benchmark models: Other benchmark models include Random Forest, Multilayer Perceptron MLP, Recurrent Neural Network RNN, Long Short-Term Memory Network LSTM and Transformer benchmark models.
[0047] Compared with the existing technology, this technical solution explores the impact of spatiotemporal evolution on water quality pollution in the river basin, which not only improves the water quality prediction performance, but also enhances the interpretability of water quality prediction results; the spatiotemporal feature fusion module combining graph convolutional networks, gated recurrent units and self-attention mechanisms realizes efficient capture of spatial dependencies, accurate identification of temporal evolution trends and deep fusion of spatiotemporal features; the graph time series prediction model using spatial graph convolution and fully connected networks realizes water quality prediction results for multiple monitoring stations in the future.
[0048] This method can effectively deal with the spatiotemporal variation of water pollution, reduce the cost of water quality prediction, and improve the accuracy of water quality prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a schematic diagram of the process of the method in the embodiment;
[0050] Figure 2 The distribution map of watershed monitoring sites in the study area in the embodiment;
[0051] Figure 3 It is a schematic diagram of the flow of the spatiotemporal feature fusion module in the embodiment;
[0052] Figure 4 Schematic diagram of the flow of the time series prediction model in the embodiment. DETAILED DESCRIPTION
[0053] The content of the present invention is further described below in conjunction with the drawings and embodiments, but the present invention is not limited thereto.
[0054] Example:
[0055] Reference Figure 1 , a water quality prediction method based on graph neural network and spatiotemporal feature fusion, including the following steps:
[0056] 1) Data collection and preprocessing: Collect and preprocess the water quality and hydrological hourly data of multiple monitoring stations in the predetermined area, specifically:
[0057] 1-1) Monitoring station selection: Collect data from multiple different monitoring stations as data sources. In this case, eight monitoring stations including Yangshuo, Jiaozhou, Guanyan, Mopanshan, Qiaotou, Dayongjiang, Cuijia and Qingshitan were collected as data sources;
[0058] 1-2) Pollutant data collection: Water quality data include at least two of dissolved oxygen, permanganate, ammonia nitrogen and total nitrogen; hydrological data include conductivity, pH value, turbidity value and water temperature;
[0059] 1-3) Pollutant data processing: The standardized score Z-score method is used to process missing values and outliers in the monitoring data. The Z-score method subtracts the mean and divides by the standard deviation to make the data conform to the standard normal distribution. Missing values include: the data collected by the monitoring station is empty, and outliers include: the data collected by the monitoring station is non-numeric. The calculation of Z-score is shown in formula (1):
[0060]
[0061] Where X represents a single data value of the time series data, μ represents the mean of the data set, σ represents the standard deviation of the data set, and Z represents the degree of difference between a single data point and the overall data set. In this example, the Lijiang River in Guilin, Guangxi, China was selected as the study area. The study area is the Lijiang River, located in Guilin, China, and enjoys typical subtropical climate characteristics. The river basin has crisscrossing rivers and a complex structure. The water quality process is affected by multiple factors such as agricultural activities, industrial emissions, tourism, and the natural environment. It exhibits extremely complex spatiotemporal coupling characteristics in space and time. Therefore, the Lijiang River can provide ideal conditions for building a graph neural network model. The monitoring data can be used to verify the model designed in this study. The geographical location of the study area and the distribution of monitoring stations are shown in the following figure. Figure 2As shown in the figure, the research data comes from the multi-point continuous online monitoring station of Guilin Ecological Environment Center Station. The collected data covers original pollutants and hydrological information, as shown in Table 1. Table 1 lists the pollutant variables and hydrological parameters in the basic data set. The pollutant variables include total nitrogen (TN), chemical oxygen demand (CODMn), ammonia nitrogen (NH3–N) and dissolved oxygen (DO) parameters. The hydrological parameters include water temperature (WT), pH (PH), electrical conductivity (EC) and turbidity (TB) parameters. In this example, dissolved oxygen (DO) and total nitrogen (TN) are selected as evaluation objects, and two years of hourly data (2020 / 01-2022 / 12) are used as the benchmark training data set for model training and testing. The data set is divided into three parts: training set, validation set and test set, accounting for 60%, 20% and 20% of the total data set respectively. The training set is used to train the model, and the validation set is used for hyperparameter search. The best model obtained by the hyperparameter search is applied to the test set to evaluate the performance of the model.
[0062] Table 1. Variable data
[0063]
[0064] ,Due to the influence of factors such as instrument failure, environmental interference and extreme weather, ,there are missing values and outliers in the monitoring data, which seriously affect the ,completeness and accuracy of the data. In order to improve the data quality, ,the Z-score method is used to screen, fill and eliminate missing values and ,outliers, thereby ensuring the smoothness of the data;
[0065] 2) Constructing a graph topology network: multiple monitoring stations in a predetermined area are represented as nodes of a graph, and the adjacency relationships between monitoring stations are used as edges of the graph, where the weight of the edge is the inverse of the geographical distance of the monitoring stations. Specifically, the monitoring stations, adjacency relationships, water quality data, and hydrological parameters collected in step 1) are used as input features to construct a graph topology network that retains the original spatial distribution characteristics of the basin stations.
[0066] The mathematical expression of the graph topology network is shown in formula (2):
[0067]
[0068] Among them A D represents the adjacency matrix, d i,j represents the distance between site i and site j, R D is the maximum value of the distance, in this case R DSet to 20km. Only when the geographical distance between monitoring stations is less than this value, a connection will be established. In order to study the transport law of pollutants between stations, this example constructs a graph topology network to capture the spatial correlation between water quality monitoring stations. For the target monitoring station, its water quality process is affected by the hydrological and water quality factors of the surrounding area stations. The geographical distance between stations can reflect the similarity and correlation of pollutant concentrations. Specifically, the closer the distance between stations, the higher the similarity of pollutant concentrations. Conversely, the farther the distance between stations, the lower the similarity of pollutant concentrations. For this reason, the monitoring stations are regarded as nodes of the graph, and adjacency is used. The matrix represents the adjacency relationship between stations. If the distance between two stations is less than a preset threshold, it is considered that there is an adjacency relationship, and the inverse of the distance is used as the element value of the adjacency matrix. The collected monitoring stations, adjacency relationships, water quality data and hydrological parameters are integrated as input features to construct a graph topology network, in which the monitoring stations are used as nodes of the graph, the adjacency relationships are edges, and the water quality data and hydrological parameters are used as node features. The original spatial distribution characteristics of the basin stations are retained. This network structure can intuitively reflect the relationship between stations, providing support for the subsequent analysis of water quality evolution laws and improving prediction accuracy.
[0069] 3) Fusion: Construct a spatiotemporal feature fusion module to extract and fuse the graph topology network obtained in step 2) to obtain the spatiotemporal feature data of water pollution and form a deep learning model input data set with a graph topology structure. The spatiotemporal feature fusion module includes a graph convolution network, a gated recurrent unit, and a self-attention mechanism, specifically:
[0070] 3-1) Graph Convolutional Network: Using the message passing paradigm based on graph convolution, the adjacency relationship between monitoring stations and sites is modeled as a graph structure, so that each monitoring station is connected into a spatially interconnected network to effectively extract the spatial features between monitoring stations. The calculation of the graph convolutional network is shown in formula (3):
[0071]
[0072] Where H represents the feature matrix of the graph convolution layer, l is the number of graph convolution layers, and W is the weight matrix. is the adjacency matrix A plus the identity matrix I, yes The degree matrix of , σ is the activation function;
[0073] 3-2) Gated recurrent unit: The gating mechanism is used to achieve a balance between retaining and forgetting past historical information, which helps to more accurately capture the periodicity of pollutants and effectively extract the time characteristics of each monitoring station. The calculation formula of the gated recurrent unit is shown in formula (4), formula (5), formula (6), and formula (7):
[0074] r t =σ(W r ·[h t-1 , x t ]+b r ) (4),
[0075] z t =σ(W z ·[h t-1 , x t ]+b z ) (5),
[0076]
[0077]
[0078] where x t is the input, W r , W z , W h is a trainable weight 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, σ and tanh represent nonlinear activation functions;
[0079] 3-3) Self-attention mechanism: Dynamically allocate weight matrix, calculate the correlation between spatial features and temporal features, obtain water pollution spatiotemporal features by weighted fusion, reduce related redundant features, and obtain water pollution spatiotemporal feature data. The mathematical formula of the self-attention mechanism is shown in formula (8):
[0080]
[0081] Where Q, K, and V represent the Query vector, Key vector, and Value vector, respectively. krepresents the dimension of the Key vector, Softmax(·) is a normalization function, and similarity is calculated. In this example, specifically: a spatiotemporal feature fusion module combining GCN, GRU and Self-attention mechanism is constructed to more effectively extract and fuse the spatiotemporal feature information of water quality; first, the water quality time series is input into the GRU model to extract the deep features of the time dimension; then, the graph structure data of the monitoring station is input into the GCN model to capture the deep features of the spatial dimension; finally, the Self-attention mechanism is used to deeply fuse the extracted spatiotemporal features, thereby improving the model's ability to capture the spatiotemporal relationship of water quality. The working principle of the spatiotemporal feature fusion module is as follows: Figure 3 As shown in the figure, in order to learn the spatial correlation between monitoring stations, this example introduces a message passing paradigm based on graph convolution to capture the complex spatial relationship between stations. GCN connects each monitoring station into a spatially interconnected network by modeling the adjacency relationship between monitoring stations and their inter-stations as a graph structure. With the help of this graph structure, GCN can iteratively aggregate the information of adjacent nodes through an effective message passing mechanism, thereby effectively extracting the potential spatial correlation between monitoring stations; in order to analyze the temporal correlation in water quality data, this example introduces the GRU model to capture the temporal dynamic changes in pollutant concentrations. GRU is a variant of RNN, which effectively alleviates the gradient vanishing and gradient exploding problems of traditional RNN in processing long sequence data through the gating mechanism. GRU uses gating The mechanism achieves a balance between information retention and forgetting, which helps to more accurately extract the periodic laws of pollutants, thereby improving the stability and efficiency of long-term series prediction. Each GRU unit consists of a reset gate and an update gate. Compared with LSTM, GRU has a simpler structure and fewer parameters, so it is faster to train. In water quality prediction, the self-attention mechanism effectively integrates spatiotemporal features by calculating the correlation between spatial and temporal features and assigning weight matrices to them, thereby improving the prediction accuracy of the model. First, three different linear layers are used to map the input into three different new vectors: Query, Key, and Value. Second, the Query vector and the Key vector are multiplied to obtain the Score value, and the Score is divided by To ensure that the model has a stable gradient during training, the SoftMax activation function is used to process the results and map the correlation coefficients to the (0,1) interval so that the sum of the correlation coefficients is one and all are positive. Finally, the correlation matrix is multiplied by the Value vector to obtain the fused spatiotemporal features.
[0082] 4) Dataset processing: Construct a graph time series prediction model to process the deep learning model input data set of the graph topology structure obtained in step 3) to complete the spatiotemporal prediction tasks of multiple monitoring stations. The graph time series prediction model includes spatial graph convolution and fully connected network, specifically:
[0083] 4-1) Spatial graph convolution: The convolution operation is used to process the fused spatiotemporal characteristics of water pollution to generate characteristic information of multiple monitoring stations;
[0084] 4-2) Fully connected network: Adaptively integrate the feature information combination, comprehensively consider the potential impact of hydrological parameters on water quality, and generate water quality prediction results for each monitoring station in the target time period. The graph time series prediction model constructed in this example is used to generate prediction sequences of spatial points. First, the fused spatiotemporal features are input into the spatial graph convolution layer to process the spatial prediction tasks of different monitoring stations. Then, the multi-dimensional feature information of water quality and hydrology is input into the fully connected network and integrated in an adaptive manner to comprehensively consider the potential impact of hydrological parameters on water quality. Finally, the future target water quality sequence prediction results of each monitoring station are generated. Its working principle is as follows: Figure 4 As shown;
[0085] 5) Effect verification: The root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (SMAPE) are used to evaluate the prediction results obtained in step 4). The data is normalized during the model training process. The parameters of the deep learning model are adjusted according to the Adam optimizer. The weight decay method, packet loss method, and early stopping method are combined to suppress overfitting. The effect is verified by comparing with other benchmark models, including:
[0086] 5-1) RMSE, MAE and SMAPE represent the deviation between the predicted results and the actual results. The smaller the deviation, the more accurate the result.
[0087] The calculation of RMSE is shown in formula (9):
[0088]
[0089] The calculation of MAE is shown in formula (10):
[0090]
[0091] The calculation of SMAPE is shown in formula (11):
[0092]
[0093] In the formula, n is the total number of samples, y is i is the time series of monitoring, y′ i is the predicted time series;
[0094] 5-2) Normalization: Normalization is to scale the data to the range of 0 to 1, which accelerates the training process of the model and improves the convergence speed;
[0095] 5-3) Weight decay method: Add a regularization term to the objective function to prevent the model from overfitting;
[0096] 5-4) Packet Dropping: Randomly discarding neural network units to prevent overfitting of the model;
[0097] 5-5) Early stopping method: Monitor the performance of the model on the validation set and stop training when overfitting begins to occur;
[0098] 5-6) Other benchmark models: Other benchmark models are Random Forest, Multilayer Perceptron MLP, Recurrent Neural Network RNN, Long Short-Term Memory Network LSTM and Transformer benchmark models, specifically:
[0099] This example method is a water quality prediction method based on graph neural network and spatiotemporal feature fusion (STF-GNN model) and compared with benchmark models such as Random Forest, MLP, RNN, LSTM and Transformer to verify the superiority of the proposed model. Table 2 shows the specific performance results of the model. The traditional statistical model (Random Forest and MLP) performed the worst among all prediction methods. This is because machine learning models cannot effectively capture the temporal dependencies in time series data. In contrast, time series deep learning models (RNN and LSTM) performed better because they can capture the temporal correlation in time series data, thereby significantly improving the prediction effect. In particular, LSTM performed better than RNN because its gating mechanism effectively solved the problems of "gradient disappearance" and "gradient explosion", enabling it to better capture the long-term and short-term dependencies in time series data. The Transformer model can not only capture the long-term and short-term dependencies in time series data, but also realize global modeling through the Self-Attention mechanism, and its performance in water quality prediction is better than LSTM. Finally, the graph-based model (STF-GNN model) of this example method showed higher performance because it can capture the spatiotemporal characteristics between different monitoring stations, which is often ignored in previous methods. In summary, compared with other baseline models, the STF-GNN model of this example method performed best because it can reveal the long-term spatiotemporal dependencies between different monitoring stations, thereby improving the reliability and stability of the prediction performance and showing a better reasoning effect.
[0100] Table 2. Prediction results of other models
[0101]
[0102]
[0103] In water quality prediction, in-depth mining of potential features in data can significantly improve the accuracy of prediction. As shown in Table 3, the performance of the five baseline models in terms of RMSE, MAE and SMAPE indicators is relatively good. This is because these models try to reveal the laws in the data through deep structures. However, they ignore the spatial associations between different monitoring stations. The water quality system is essentially a complex network. There is a natural connectivity between the water quality of the stations. The change of water quality at one location often affects other locations. Therefore, the method STF-GNN in this example captures the spatial relationship between the stations through the graph structure and shows the best performance in terms of RMSE, MAE and SMAPE indicators. In addition, these baseline models directly input all data into the neural network, which may cause the model to become a black box, thereby reducing its interpretability. For this reason, the design of the model structure is crucial to improving the interpretability of the model. The STF-GNN model in this example models the distribution of monitoring stations as a graph structure and uses the topological relationship of the graph to learn the transmission law of pollutants. Compared with the baseline model, this method significantly enhances the explanatory power of the physical topology, which helps to better understand the decision-making process of the model.
[0104] Based on the results on this basis, this example provides a new method for the prediction of long-sequence data of water environment quality and the interpretability of model behavior, which provides a strong basis for alleviating water pollution, helps to reduce costs, protect ecology and improve human health. At the same time, the method of this application is suitable for the prediction of water environment quality at multiple sites in small and medium-sized cities or in the watershed of multiple cities;
[0105] The experimental results show that this method performs well in water quality prediction and can more accurately capture the transmission patterns of water pollutants in the region. This shows that this method has practical value in real-time monitoring and forecasting of water quality, and can provide theoretical and technical support for water environment protection and pollution control.
Claims
1. A water quality prediction method based on graph neural network and spatiotemporal feature fusion, characterized in that: The steps include: 1) Data collection and preprocessing: Collect and preprocess the water quality and hydrological hourly data of multiple monitoring stations in the predetermined area, specifically: 1-1) Monitoring station selection: Collect data from multiple different monitoring stations as data sources; 1-2) Pollutant data collection: Water quality data include at least two of dissolved oxygen, permanganate, ammonia nitrogen and total nitrogen; hydrological data include conductivity, pH value, turbidity value and water temperature; 1-3) Pollutant data processing: The standardized score Z-score method is used to process missing values and outliers in the monitoring data. The Z-score method subtracts the mean and divides by the standard deviation to make the data conform to the standard normal distribution. Missing values include: the data collected by the monitoring station is empty, and outliers include: the data collected by the monitoring station is non-numeric. The calculation of Z-score is shown in formula (1): Where X represents a single data value of the time series data, μ represents the mean of the data set, σ represents the standard deviation of the data set, and Z represents the degree of difference between a single data point and the overall data set; 2) Constructing a graph topology network: multiple monitoring stations in a predetermined area are represented as nodes of a graph, and the adjacency relationships between monitoring stations are used as edges of the graph, where the weight of the edge is the inverse of the geographical distance of the monitoring stations. Specifically, the monitoring stations, adjacency relationships, water quality data, and hydrological parameters collected in step 1) are used as input features to construct a graph topology network that retains the original spatial distribution characteristics of the basin stations. The mathematical expression of the graph topology network is shown in formula (2): Among them A D represents the adjacency matrix, d i,j represents the distance between site i and site j, R D is the maximum value of the distance, R D Set to 20km. Only when the geographical distance between monitoring stations is less than this value, a connection will be established; 3) Fusion: Construct a spatiotemporal feature fusion module to extract and fuse the graph topology network obtained in step 2) to obtain the spatiotemporal feature data of water pollution and form a deep learning model input data set with a graph topology structure. The spatiotemporal feature fusion module includes a graph convolution network, a gated recurrent unit, and a self-attention mechanism, specifically: 3-1) Graph convolutional network: Using the message passing paradigm based on graph convolution, the adjacency relationship between monitoring stations and sites is modeled as a graph structure, so that each monitoring station is connected into a spatially interconnected network. The calculation of the graph convolutional network is shown in formula (3): Where H represents the feature matrix of the graph convolution layer, l is the number of graph convolution layers, and W is the weight matrix. is the adjacency matrix A plus the identity matrix I, yes The degree matrix of , σ is the activation function; 3-2) Gated recurrent unit: The gating mechanism is used to achieve a balance between retaining and forgetting past historical information. The calculation formulas of the gated recurrent unit are shown in formula (4), formula (5), formula (6), and formula (7): r t =σ(W r ·[h t-1 ,x t ]+b r ) (4), z t =σ(W z ·[h t-1 ,x t ]+b z ) (5), where x t is the input, W r , W z , W h is a trainable weight 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, σ and tanh represent nonlinear activation functions; 3-3) Self-attention mechanism: A dynamic weight matrix is used to calculate the correlation between spatial features and temporal features, and weighted fusion is performed to obtain the spatiotemporal features of water pollution. The mathematical formula of the self-attention mechanism is shown in formula (8): Where Q, K, and V represent the Query vector, Key vector, and Value vector, respectively. k represents the dimension of the Key vector, Softmax(·) is a normalization function to calculate the similarity; 4) Dataset processing: Construct a graph time series prediction model to process the deep learning model input data set of the graph topology structure obtained in step 3) to complete the spatiotemporal prediction tasks of multiple monitoring stations. The graph time series prediction model includes spatial graph convolution and fully connected network, specifically: 4-1) Spatial graph convolution: The convolution operation is used to process the fused spatiotemporal characteristics of water pollution to generate characteristic information of multiple monitoring stations; 4-2) Fully connected network: Adaptively integrate the feature information combination to generate water quality prediction results for each monitoring station in the target time period; 5) Effect verification: The root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (SMAPE) are used to evaluate the prediction results obtained in step 4). The data is normalized during the model training process. The parameters of the deep learning model are adjusted according to the Adam optimizer. The weight decay method, packet loss method, and early stopping method are combined to suppress overfitting. The effect is verified by comparing with other benchmark models, including: 5-1) RMSE, MAE and SMAPE represent the deviation between the predicted results and the actual results. The smaller the deviation, the more accurate the result. The calculation of RMSE is shown in formula (9): The calculation of MAE is shown in formula (10): The calculation of SMAPE is shown in formula (11): In the formula, n is the total number of samples, y is i is the time series of monitoring, y′ i is the predicted time series; 5-2) Normalization: Normalization is to scale the data to the range of 0 to 1, which accelerates the training process of the model and improves the convergence speed; 5-3) Weight decay method: Add a regularization term to the objective function to prevent the model from overfitting; 5-4) Packet Dropping: Randomly discarding neural network units to prevent overfitting of the model; 5-5) Early stopping method: Monitor the performance of the model on the validation set and stop training when overfitting begins to occur; 5-6) Other benchmark models: Other benchmark models include Random Forest, Multilayer Perceptron MLP, Recurrent Neural Network RNN, Long Short-Term Memory Network LSTM and Transformer benchmark models.
Citation Information
Cited By
Non-point source pollutant emission flux prediction and coastal risk identification method and system
CN119886845A
A method and system for predicting the emission flux of non-point source pollutants and identifying coastal risks
CN119886845B
Water quality prediction method based on graph convolution and time-space interlaced attention mechanism
CN119918982A
Water Quality Prediction Method Based on Graph Convolution and Spatiotemporal Interleaved Attention Mechanism
CN119918982B
Aquatic organism management method and system based on big data model
CN120107042A