A method, apparatus, electronic device and storage medium for spatiotemporal prediction of water quality

CN121415905BActive Publication Date: 2026-08-11LIHE TECH (HUNAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-29
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0004]本申请一方面提供了水质时空预测方法,用于解决现有基于时空图神经网络的预测方法存在计算复杂度随着节点数增加而快速上升不利于在大规模水质预测模型中推广、动态环境下精度下降的技术问题

Benefits of technology

本申请提出一种水质时空预测方法、装置、电子设备及存储介质,所述水质时空预测方法基于图神经网络与状态空间建模相结合,通过在短期、中期和长期三个时间尺度下分别构建处理分支,并利用图选择性状态空间建模GSSSM(Graph State Space SelectionMechanism)对时空特征进行动态选择与加权,同时引入自适应动态更新水质预测模型的邻接矩阵对空间依赖进行自适应建模,实现了对监测站点间复杂拓扑关系和水质演变规律的高效捕捉,具体包括:

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121415905B_ABST
    Figure CN121415905B_ABST
Patent Text Reader

Abstract

This application discloses a spatiotemporal prediction method, apparatus, electronic device, and storage medium for water quality. The method includes the following steps: S1, constructing input sequences for short-term, medium-term, and long-term time scales of a water quality prediction model based on the observed water quality index values ​​at different time scales of each monitoring station. A graph structure for each input sequence is constructed based on the graph structure formed by the monitoring stations. Each node in each graph structure represents the observed water quality index values ​​at different time scales of each monitoring station, and each edge represents the spatial relationship between monitoring stations, represented by an adjacency matrix A. S2, constructing a water quality prediction model combining graph neural networks and graph selective state space modeling for water quality prediction. This application utilizes historical water quality indicators from multiple monitoring points and external environmental factors, combined with the spatial topological relationships between monitoring stations, to effectively model long-term temporal dependencies and inter-node propagation mechanisms, achieving high-precision, low-latency prediction of water quality indicators for future moments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of environmental monitoring technology, and in particular to a method, apparatus, electronic device and storage medium for spatiotemporal prediction of water quality. Background Technology

[0002] Water quality prediction is a key research direction in the field of water resources management and environmental protection. Its core objective is to scientifically predict the dynamic trends of key water quality indicators (such as dissolved oxygen, pH, ammonia nitrogen, total phosphorus, and turbidity) in the future by systematically analyzing historical monitoring data and related influencing factors. This research not only helps to reveal the evolutionary laws of aquatic ecosystems, but also provides decision-making basis for water authorities, environmental protection agencies, and smart water systems. Thus, it plays an important role in water resource allocation, water pollution prevention and control, and ecological protection and restoration, promoting the sustainable use of water resources and the continuous improvement of water environment quality.

[0003] Currently, common water quality prediction methods mainly include numerical methods based on mechanistic models, methods based on traditional machine learning, time-series prediction methods based on deep learning, and prediction methods based on spatiotemporal graph neural networks (ST-GNN). Among these, existing ST-GNN-based methods can integrate spatial and temporal dependencies within the same framework, but the overall model structure is complex, and the training and inference processes require high computational resources. Furthermore, there is a lack of unified standards for graph structure construction and edge weight selection, limiting the model's transferability across different scenarios. In existing research, the ST-GAT model, with its graph attention mechanism at its core, is one of the representative implementations of ST-GNN. It effectively reveals the spatial relationships between points by adaptively assigning weights to different neighboring nodes, enhancing its spatial feature modeling capabilities. However, ST-GAT requires pairwise attention calculations when capturing spatial dependencies, and the computational complexity increases rapidly with the number of nodes, hindering its application in large-scale monitoring networks. Simultaneously, its attention distribution may exhibit instability in dynamic environments, easily leading to decreased accuracy in long-sequence or multi-step predictions. Summary of the Invention

[0004] This application provides a spatiotemporal prediction method for water quality, which addresses the technical problems of existing prediction methods based on spatiotemporal graph neural networks, where the computational complexity increases rapidly with the number of nodes, making them unsuitable for large-scale water quality prediction models, and the accuracy decreases in dynamic environments.

[0005] This application is achieved through the following solution: A spatiotemporal prediction method for water quality includes the following steps: S1. Construct the short-term time-scale input sequence X of the water quality prediction model based on the observed water quality indicators at different time scales of each monitoring station.s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Based on the graph structure G formed by the monitoring stations, graph structures G for each input sequence are constructed respectively. s G m G l Graph structure G s G m G l Each node represents the water quality index observation value of each monitoring station at different time scales, and each edge represents the spatial relationship between monitoring stations, which is represented by the adjacency matrix A. S2. Construct a water quality prediction model that combines graph neural networks and graph selective state space modeling for water quality prediction. The water quality prediction model includes three input sequences X that each receive a short-term timescale. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l The processing branches are based on the graph structure G of each input sequence. s G m G l After adaptively and dynamically updating the adjacency matrix of the water quality prediction model, extracting time evolution features at different time scales, and filtering key information, the features are spliced, fused, and dimensionality reduced to obtain the water quality prediction value.

[0006] Furthermore, in step S1, the input sequence at a short time scale is used to record the fluctuation characteristics of water quality indicators observed in minute-level or hour-level monitoring; the input sequence at a medium time scale is used to record the phased change patterns of water quality indicators observed in daily or weekly scales; and the input sequence at a long time scale records the phased change patterns of water quality indicators observed in monthly or seasonal scales.

[0007] Furthermore, in step S1, the input sequence X of the water quality prediction model at a short time scale... s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Represented as: , , ; Where R represents the set of real numbers, T s T represents the time series length of the input sequence at a short time scale. m T represents the time series length of the input sequence at a medium-term time scale. lThe input sequence represents the time series length over a long time scale, N represents the number of monitoring stations included in the water quality prediction model, and F represents the feature quantity at each time point.

[0008] Furthermore, each processing branch includes an adaptive adjacency matrix adjustment module, which is used for: Updating the adjacency matrix A yields the following results: ; ; (•) represents the neighborhood attention function, and M is a learnable parameter matrix. ; Perform graph convolution operations using the updated adjacency matrices A1 and A2 respectively: ; ; ; Where X represents the input sequence at the corresponding time scale. Let represent the set of features of each node obtained after graph convolution operation on the adjusted branch of the neighborhood self-attention adjacency matrix. This represents the set of features for each node obtained after graph convolution in the branch where the adjacency matrix is ​​adaptively adjusted by introducing a learnable parameter matrix M. This represents the node features output by the graph convolutional neural network and B represents the training batch, d model This represents the dimension of the vector after feature extraction for each node. Represents a non-linear activation function. This represents the learnable weight matrix of the convolutional layer in branch two. Let denote the learnable weight matrix of the convolutional layer in branch one. This indicates the bias term corresponding to the convolutional layer in branch one. This represents the bias term corresponding to the convolutional layer in branch two.

[0009] Furthermore, each processing branch also includes a state space modeling and filtering module, which is used for: The node features output by the adaptive adjacency matrix adjustment module are mapped and compressed using a linear layer; The node features, after feature dimension mapping and compression, are introduced into a one-dimensional convolutional layer to capture local temporal patterns, and then the SiLU activation function is used to enhance the non-linearity of feature representation. The processed node features are input into the graph-selective state-space modeling module to achieve joint modeling of temporal dependencies and spatial structure, thus obtaining the first feature space: ; The first feature space is mapped to the feature dimension before the introduction of the one-dimensional convolutional layer and the compressed node features are multiplied point by point and then input into the linear layer for dynamic weighting and residual adjustment filtering to obtain the second feature space. : ; The original feature space f of the input sequence at the time scale corresponding to the current processing branch is superimposed onto the second feature space. The third feature space at the corresponding time scale is obtained. To align and integrate it with the feature selection results: .

[0010] Furthermore, the step of performing feature splicing, fusion, and dimensionality reduction to obtain the water quality prediction value specifically includes the following steps: The third feature space from the three different time scales output by each processing branch is concatenated, then input into a linear layer for feature fusion and dimensionality reduction to obtain the predicted value: ; in, The third feature space represents the short-term timescale. The third feature space represents the intermediate timescale. The third feature space represents the long-term timescale.

[0011] Furthermore, step S2 also includes the step of: constructing a loss function for a water quality prediction model that combines graph neural networks and graph selective state space modeling. ; in, α and β The adjustable weighting coefficients are used to balance the ability of the mean squared error to fit the overall error with the robustness of Huber Loss to outliers; δ>0 is the threshold parameter of Huber Loss. T Indicates the prediction time step. V This refers to the types and quantities of water quality indicators. t For a specific time step, v For a specific water quality indicator, and These represent the time steps. t and water quality indicators v The actual value and the predicted value are as follows. r Represents the true value Compared with the predicted value The residual.

[0012] This application also provides a water quality spatiotemporal prediction device, comprising: The input feature construction module is used to construct the short-term time-scale input sequence X of the water quality prediction model based on the observed water quality indicators at different time scales of each monitoring station. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Based on the graph structure G formed by the monitoring stations, graph structures G for each input sequence are constructed respectively. s G m G l Graph structure G s G m G l Each node represents the water quality index observation value of each monitoring station at different time scales, and each edge represents the spatial relationship between monitoring stations, which is represented by the adjacency matrix A. The water quality prediction module is used to construct a water quality prediction model that combines graph neural networks and graph selective state space modeling for water quality prediction. The water quality prediction model includes three input sequences X that each receive a short-term timescale. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l The processing branches are based on the graph structure G of each input sequence. s G m G l After adaptively and dynamically updating the adjacency matrix of the water quality prediction model, extracting time evolution features at different time scales, and filtering key information, the features are spliced, fused, and dimensionality reduced to obtain the water quality prediction value.

[0013] In another aspect, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the steps of the spatiotemporal prediction method for water quality.

[0014] This application also provides a storage medium including a stored program that, when the program is executed, controls the device containing the storage medium to perform the steps of the spatiotemporal prediction method for water quality.

[0015] Compared with the prior art, this application has the following advantages: This application proposes a spatiotemporal prediction method, device, electronic device, and storage medium for water quality. The method combines graph neural networks with state-space modeling. It constructs processing branches at short-term, medium-term, and long-term time scales and utilizes Graph State Space Selection Mechanism (GSSSM) to dynamically select and weight spatiotemporal features. Simultaneously, it introduces an adaptively dynamically updated adjacency matrix to model spatial dependencies, achieving efficient capture of complex topological relationships between monitoring stations and water quality evolution patterns. Specifically, it includes: This application proposes a spatiotemporal prediction method, device, electronic device, and storage medium for water quality. The method combines graph neural networks with graph selective state-space modeling (GSSSM). It constructs processing branches at short-term, medium-term, and long-term time scales and uses GSSSM to dynamically select and weight spatiotemporal features. Simultaneously, it introduces an adaptive adjacency matrix adjustment module that dynamically updates the adjacency matrix of the water quality prediction model, adaptively modeling spatial dependencies. This achieves efficient capture of complex topological relationships between monitoring stations and water quality evolution patterns. Specifically, it includes: 1. Significantly improved prediction accuracy: Through multi-scale feature fusion and graph-selective state-space dynamic modeling, it effectively captures short-term fluctuations, medium-term trends and long-term dependencies, significantly reducing the prediction error of key water quality indicators such as dissolved oxygen, ammonia nitrogen, COD and pH. 2. Enhanced robustness: Through a dynamic weighting mechanism, the interference of abnormal water quality index observations on prediction results is reduced, thereby improving the stability of the water quality prediction model; 3. Optimized computational efficiency: Compared with traditional numerical simulation methods, this application does not require solving large-scale partial differential equations, and the computational load is small, which can meet the requirements of high-frequency updates and real-time prediction. Compared with traditional spatiotemporal self-attention graph neural networks, it significantly reduces the computational time complexity, which is beneficial for rapid model updates. 4. Wide range of applications: The water quality prediction method of this application can adapt to different watersheds, river sections and multi-node monitoring networks. By adaptively and dynamically updating the adjacency matrix of the water quality prediction model, it can flexibly adapt to changes in spatial structure, thus improving the versatility and scalability of the application. 5. Enhanced interpretability and controllability: Through the feature selection mechanism and learnable parameters of the adjacency matrix of GSSSM, researchers can analyze the contribution of each node and each time scale to the prediction results, achieving partial interpretability.

[0016] In addition to the purposes, features, and advantages described above, this application has other purposes, features, and advantages. A further detailed description of this application will be provided below with reference to the figures. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1 This is a flowchart illustrating the spatiotemporal prediction method for water quality according to a preferred embodiment of this application. Figure 2 This is a schematic diagram of the water quality prediction model according to a preferred embodiment of this application; Figure 3 This is a schematic diagram of a water quality spatiotemporal prediction device module according to a preferred embodiment of this application; Figure 4 This is a schematic block diagram of an electronic device according to a preferred embodiment of this application; Figure 5 This is an internal structural diagram of a computer device according to a preferred embodiment of this application. Detailed Implementation

[0019] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0020] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0021] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or a water quality spatiotemporal prediction device capable of performing the above functions. The following description uses a water quality spatiotemporal prediction device as the executing entity to illustrate this embodiment and the subsequent embodiments.

[0022] Terminology Explanation 1. Explanation of the principle of Neighborhood Attention Basic symbol explanation: X: The input adjacency matrix, which can be understood as a topological graph containing whether each node is connected, with a size of N×N; Q, K, V: These are three matrices obtained after linear transformation of the input features, representing "Query," "Key," and "Value," respectively. Their function is similar to: Q: What kind of information am I looking for (search)? K: The "tag" (key) carried by each pixel; V: The "content" (value) carried by each pixel; i: The current node position being processed; k: Neighborhood size, for example, k=7 means that a 7×7 neighborhood range around the pixel is considered; The set of neighboring nodes of node i can be understood as "the nodes near i", and it is dynamically determined. d: The dimensions of Q and K, used for numerical scaling; B: Relative position offset, indicating that within the neighborhood, different relative positions may have additional weighting parameters;

[0023] Core formulas and their physical meaning: first step: For the current node i, it calculates "similarity" with each node j in its neighborhood: ; Meaning: Pixel i will "query" its neighbor node j to see if they are similar in features. The dot product represents the similarity, and dividing by d is for numerical stability. Bias B: Neighbors at different relative positions may have different importance; for example, a neighbor directly above may be more relevant to the target. Here, h and w represent the scanning processes in the horizontal and vertical directions, respectively. Step 2: Weight Normalization Convert the similarity of all neighboring nodes of the given node into a probability distribution; ); The importance of all neighboring nodes is summed to 1. The more similar the neighboring nodes are, the greater the weight they receive. In subsequent graph convolution operations, the features of node i will be biased towards the features of nodes with larger aggregate weights. Step 3: Obtain the new node relationship representation: The final output is the weighted sum of the contents of all neighbors within the neighborhood: ; The new representation of node i is a weighted average of the "content" of its neighboring nodes, with the weights determined by similarity.

[0024] 2. Explanation of the principles of Graph Selective State-Space Modeling (GSSSM) The core idea of ​​GSSSM is to introduce dynamic graph structure information into the selection mechanism of the Selective State-Space Model (SSSM) to achieve joint modeling of spatiotemporal data. Its computational process consists of three steps: Step 1: Generating the initial selection parameters Input spatiotemporal sequence After linear mapping and SoftPlus activation, the original selection parameters are obtained. : ; The time-dependent selection signal represents the input-dependent trend, which characterizes the changing trend of the input sequence at different time steps. Step 2: Graph Structure Information Modulation Dynamic graph adjacency matrix generated by the dynamic adjacency matrix adjustment module After dimensional transformation and with Fusion: ; This step deeply couples the temporal selection signal of the input sequence with the spatial dependencies between nodes. Matrix multiplication means that the selection signal of each node depends not only on its own features but also on the connection strength of its neighboring nodes, achieving spatiotemporal collaborative modeling. Step 3: State Update and Output Generation Using the modulated parameter Δ′, the state-space model parameters are discretized and recursively updated: Dynamic state transition matrix: ; Control input modulation: ; State update equation: ; Output result: ; : The state transition matrix combining input dynamics and graph structure; : Control the modulation form of the input so that the range of influence of the input depends on the spatial adjacency relationship; The implicit state of the system at time i reflects the dynamic spatiotemporal evolution; : The explicit output at time i.

[0025] like Figure 1As shown, a preferred embodiment of this application provides a method for spatiotemporal prediction of water quality, including the following steps: S1. Construct the short-term time-scale input sequence X of the water quality prediction model based on the observed water quality indicators at different time scales of each monitoring station. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Based on the graph structure G formed by the monitoring stations, graph structures G for each input sequence are constructed respectively. s G m G l Graph structure G s G m G l Each node represents the water quality index observation value of each monitoring station at different time scales, and each edge represents the spatial relationship between monitoring stations, which is represented by the adjacency matrix A. S2. Construct a water quality prediction model that combines graph neural networks and graph selective state space modeling for water quality prediction. The water quality prediction model includes three input sequences X that each receive a short-term timescale. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l The processing branches are based on the graph structure G of each input sequence. s G m G l After adaptively and dynamically updating the adjacency matrix of the water quality prediction model, extracting time evolution features at different time scales, and filtering key information, the features are spliced, fused, and dimensionality reduced to obtain the water quality prediction value.

[0026] This embodiment proposes a spatiotemporal water quality prediction method based on a combination of graph neural networks and graph selective state space modeling. It constructs processing branches at short-term, medium-term, and long-term time scales, and utilizes Graph State Space Selection Mechanism (GSSSM) to dynamically select and weight spatiotemporal features. Simultaneously, it introduces an adaptive adjacency matrix adjustment module that dynamically updates the adjacency matrix of the water quality prediction model and adaptively models spatial dependencies. This achieves efficient capture of complex topological relationships between monitoring stations and water quality evolution patterns, specifically including: 1. Significantly improved prediction accuracy: Through multi-scale feature fusion and graph-selective state-space dynamic modeling, it effectively captures short-term fluctuations, medium-term trends and long-term dependencies, significantly reducing the prediction error of key indicators such as dissolved oxygen, ammonia nitrogen, COD and pH. 2. Enhanced robustness: Through a dynamic weighting mechanism, the interference of abnormal water quality index observations on prediction results is reduced, thereby improving the stability of the water quality prediction model; 3. Optimized computational efficiency: Compared with traditional numerical simulation methods, the solution in this embodiment mainly adopts linear time complexity, without the need to solve large-scale partial differential equations, and the amount of computation is small, which can meet the requirements of high-frequency updates and real-time prediction. Compared with traditional spatiotemporal self-attention graph neural networks, it significantly reduces the computational time complexity, which is conducive to rapid model updates. 4. Wide range of applications: The water quality prediction method of this application can adapt to different watersheds, river sections and multi-node monitoring networks. By adaptively and dynamically updating the adjacency matrix of the water quality prediction model, it can flexibly adapt to changes in spatial structure, thus improving the versatility and scalability of the application. 5. Enhanced interpretability and controllability: Through the feature selection mechanism and learnable parameters of the adjacency matrix of GSSSM, researchers can analyze the contribution of each node and each time scale to the prediction results, achieving partial interpretability.

[0027] Preferably, in step S1, the input sequence of the short-term time scale is used to record the fluctuation characteristics of the water quality index observation values ​​in minute-level or hour-level monitoring; the input sequence of the medium-term time scale is used to record the phased change pattern of the water quality index observation values ​​in the daily or weekly scale; and the input sequence of the long-term time scale is used to record the phased change pattern of the water quality index observation values ​​in the monthly or seasonal scale.

[0028] In this embodiment, the input to the water quality prediction model consists of three graph neural network inputs at different time scales, corresponding to short-term, medium-term, and long-term time scales, respectively. The short-term input captures the rapid fluctuations of water quality indicators in minute- or hourly monitoring; the medium-term input characterizes the phased changes within daily or weekly scales; and the long-term input reflects monthly or even seasonal trends. Each type of input is based on a graph structure composed of monitoring stations, where nodes represent observed water quality indicators at each station, edges represent spatial relationships between stations, and the input feature vector includes key water quality indicators such as dissolved oxygen, pH, ammonia nitrogen, total phosphorus, and turbidity. Because the water quality prediction model consists of three separate spatiotemporal branches, it can process and fuse variables at the short-term, medium-term, and long-term time scales independently. This ensures that the prediction results are effective for data at all three time scales, guaranteeing that the prediction results integrate spatial and temporal dependencies, resulting in more comprehensive and reliable predictions.

[0029] Preferably, for ease of formal description, in step S1, the input sequence X of the water quality prediction model at a short time scale is... sInput sequence X at a medium-term time scale m Input sequence X on a long time scale l Represented as: , , ; Where R represents the set of real numbers, T s T represents the time series length of the input sequence at a short time scale. m T represents the time series length of the input sequence at a medium-term time scale. l The input sequence represents the time series length over a long time scale, N represents the number of monitoring stations included in the water quality prediction model, and F represents the feature quantity at each time point.

[0030] For ease of formal description, this embodiment assumes that the water quality prediction model includes N monitoring stations, a time series length, and a feature quantity F at each time point (including the number of water quality indicators such as total phosphorus and total nitrogen). Expressions for the input sequences at three different time scales are given, which are related to the number of monitoring stations N and the corresponding time series length. The feature quantity F at each time step is associated, and the spatial relationships of the water quality prediction model at each time scale are determined by the adjacency matrix. It means that, among them This indicates whether the i-th node is connected to the j-th node.

[0031] Preferably, such as Figure 2 As shown, in step S2, each processing branch includes an adaptive adjacency matrix adjustment module. This module is used to dynamically update the spatial dependencies of the water quality prediction model, specifically for: Updating the adjacency matrix A yields the following results: ; ; (•) represents the neighborhood attention function, and M is a learnable parameter matrix. ; After adjusting the adjacency matrices in both branches, graph convolution operations are performed using the updated adjacency matrices A1 and A2 respectively: ; ; ; Where X represents the input sequence at the corresponding time scale. Let represent the set of features of each node obtained after graph convolution operation on the adjusted branch of the neighborhood self-attention adjacency matrix. This represents the set of features for each node obtained after graph convolution in the branch where the adjacency matrix is ​​adaptively adjusted by introducing a learnable parameter matrix M. This represents the node features output by the graph convolutional neural network and B represents the training batch, d model This represents the dimension of the vector after feature extraction for each node. Represents a non-linear activation function. This represents the learnable weight matrix of the convolutional layer in branch two. Let denote the learnable weight matrix of the convolutional layer in branch one. This indicates the bias term corresponding to the convolutional layer in branch one. This represents the bias term corresponding to the convolutional layer in branch two.

[0032] In this embodiment, the adaptive adjacency matrix adjustment module performs spatial dependency modeling in each processing branch using two parallel mechanisms: on the one hand, it utilizes Neighborhood Attention (Nattn) to adaptively adjust or enhance the spatial topological relationships between monitoring stations, enabling the adjacency matrix to not only depend on a fixed graph structure but also extract potential connections by combining the similarity of node features; on the other hand, it introduces a learnable parameter matrix. This parameter matrix M is used to supplement potential edge information beyond the initial topology to ensure global connectivity of the entire graph structure. It is initialized as a zero matrix and is continuously updated during training to flexibly enhance the expressive power of adjacency relationships.

[0033] This embodiment is obtained through calculation. The node features output by the graph convolutional neural network are remapped to the dimensions required by the current task, thereby achieving feature selection and compression while retaining key information, providing more effective input for subsequent time series modeling.

[0034] Preferably, such as Figure 2 As shown, each processing branch also includes a graph-selective state-space modeling and filtering module. This module is responsible for extracting temporal evolution features and filtering key information, specifically for: The node features output by the adaptive adjacency matrix adjustment module are mapped and compressed using a linear layer. The node features, after feature dimension mapping and compression, are introduced into a one-dimensional convolutional layer (1D Convolution) to capture local temporal patterns, and then the SiLU activation function is used to enhance the non-linearity of feature representation. The processed node features are input into the Graph StateSpace Selection Mechanism (GSSSM) module to achieve joint modeling of temporal dependencies and spatial structure, resulting in the first feature space. ; It is the first feature space obtained in graph selective state-space modeling, which completes the spatial and temporal modeling. GSSSM (Graph State Space Selection Mechanism), as the core component of the module, is responsible for realizing the spatiotemporal feature selection capability of input dependence. Its basic idea is to combine the dynamic characteristics of the continuous state-space model (SSM) with the spatial dependencies of the graph structure, thereby simultaneously capturing the time series evolution and the topological connections between monitoring stations.

[0035] The first feature space is mapped to the feature dimension before the introduction of the one-dimensional convolutional layer and the compressed node features are multiplied point by point and then input into the linear layer for dynamic weighting and residual adjustment filtering to obtain the second feature space. : ; The original feature space f of the input sequence at the time scale corresponding to the current processing branch is superimposed onto the second feature space. The third feature space at the corresponding time scale is obtained. This aligns and integrates the results with the feature selection results, thereby preventing gradient explosion during the learning process. .

[0036] Preferably, such as Figure 2 As shown, the step of performing feature stitching and then connecting to a linear layer, fusing and reducing dimensionality to obtain the water quality prediction value specifically includes the following steps: The third feature space from the three different time scales output by each processing branch is concatenated, then input into a linear layer for feature fusion and dimensionality reduction to obtain the predicted value: ; in, The third feature space represents the short-term timescale. The third feature space represents the intermediate timescale. The third feature space represents the long-term timescale.

[0037] In this embodiment, by splicing the third feature spaces of three different time scales output from each processing branch, and then inputting them into a linear layer for feature fusion and dimensionality reduction, it is possible to integrate feature representations at different time scales, achieve unified modeling of short-term changes, medium-term trends and long-term dependencies, thereby improving the accuracy and robustness of prediction.

[0038] Preferably, step S2 further includes the step of: constructing a loss function for a water quality prediction model that combines graph neural networks and graph selective state space modeling. ; To balance the ability of mean squared error (MSE) to fit the overall error with the robustness of Huber Loss to outliers, a combined loss function is constructed by integrating the two. α and β The adjustable weighting coefficients are used to balance the ability of the mean squared error to fit the overall error with the robustness of Huber Loss to outliers; δ>0 is the threshold parameter of Huber Loss. T Indicates the prediction time step. V This refers to the types and quantities of water quality indicators. t For a specific time step, v For a specific water quality indicator, and These represent the time steps. t and water quality indicators v The actual value and the predicted value are as follows. r Represents the true value Compared with the predicted value The residual.

[0039] In the water quality prediction model, to achieve accurate prediction of multiple time steps and multiple monitoring indicators, and to improve the robustness of abnormal water quality indicator observations, the model adopts a loss function that combines mean squared error (MSE) and Huber Loss. Through this loss function, the water quality prediction model can effectively suppress the excessive influence of abnormal water quality indicator observations on the prediction results while maintaining the ability to fit the main trends, thereby improving the overall accuracy and stability of the prediction.

[0040] like Figure 3 As shown, another preferred embodiment of this application also provides a water quality spatiotemporal prediction device, including: The input feature construction module is used to construct the short-term time-scale input sequence X of the water quality prediction model based on the observed water quality indicators at different time scales of each monitoring station. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale lBased on the graph structure G formed by the monitoring stations, graph structures G for each input sequence are constructed respectively. s G m G l Graph structure G s G m G l Each node represents the water quality index observation value of each monitoring station at different time scales, and each edge represents the spatial relationship between monitoring stations, which is represented by the adjacency matrix A. The water quality prediction module is used to construct a water quality prediction model that combines graph neural networks and graph selective state space modeling for water quality prediction. The water quality prediction model includes three input sequences X that each receive a short-term timescale. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l The processing branches are based on the graph structure G of each input sequence. s G m G l After adaptively and dynamically updating the adjacency matrix of the water quality prediction model, extracting time evolution features at different time scales, and filtering key information, the features are spliced, fused, and dimensionality reduced to obtain the water quality prediction value.

[0041] The water quality spatiotemporal prediction device provided in this embodiment employs the water quality spatiotemporal prediction method described in the above embodiments, addressing the technical problems of existing prediction methods based on spatiotemporal graph neural networks, where computational complexity increases rapidly with the number of nodes, hindering their application in large-scale water quality prediction models and leading to decreased accuracy in dynamic environments. Compared to the prior art, the beneficial effects of the water quality spatiotemporal prediction device provided in this embodiment are the same as those of the water quality spatiotemporal prediction method described in the above embodiments, and other technical features of the water quality spatiotemporal prediction device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0042] like Figure 4 As shown, a preferred embodiment of this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the water quality spatiotemporal prediction method described in the above embodiments.

[0043] This application provides an electronic device that employs the spatiotemporal water quality prediction method described in the above embodiments. This addresses the technical problems of existing prediction methods based on spatiotemporal graph neural networks, where computational complexity increases rapidly with the number of nodes, hindering their application in large-scale water quality prediction models and leading to decreased accuracy in dynamic environments. Compared to existing technologies, the electronic device provided in this application has the same beneficial effects as the spatiotemporal water quality prediction method described in the above embodiments, and other technical features of the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be elaborated upon here.

[0044] like Figure 5 As shown, a preferred embodiment of this application also provides a computer device, which may be a terminal or a liveness detection server, and its internal structure diagram may be as follows. Figure 5 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computational and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with other external computer devices via a network connection. When the computer program is executed by the processor, it implements the steps of the aforementioned spatiotemporal water quality prediction method.

[0045] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0046] The computer device provided in this application employs the spatiotemporal water quality prediction method described in the above embodiments, addressing the technical problems of existing prediction methods based on spatiotemporal graph neural networks, where computational complexity increases rapidly with the number of nodes, hindering their application in large-scale water quality prediction models and leading to decreased accuracy in dynamic environments. Compared to existing technologies, the beneficial effects of the computer device provided in this application are the same as those of the spatiotemporal water quality prediction method provided in the above embodiments, and other technical features in the electronic device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0047] A preferred embodiment of this application also provides a storage medium, the storage medium including a stored program, which, when the program is executed, controls the device where the storage medium is located to perform the steps of the water quality spatiotemporal prediction method in the above embodiments.

[0048] As can be seen, the key improvement of this application lies in proposing a multi-scale water quality prediction network that combines graph neural networks and state space modeling. This network includes three processing branches: short-term, medium-term, and long-term. A feature fusion module based on Kalman filtering is set at the upper layer to achieve unified modeling of the spatial dependencies of monitoring stations and the time dependencies of water quality evolution, thereby improving the accuracy and robustness of multi-scale, multi-node water quality prediction. Simultaneously, an adjacency matrix adaptive adjustment module is introduced into each processing branch. Through the joint action of Neighborhood Attention and a learnable parameter matrix, the original graph topology is dynamically optimized, maintaining the basic spatial connections between nodes while enhancing the correlation of potential features. The multi-scale branching and fusion design of the overall network structure, and the innovative combination of the adjacency matrix adaptive adjustment module, constitute the core technology of this application, enabling the model to achieve efficient, stable, and scalable performance in complex water quality prediction scenarios.

[0049] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0050] If the functions described in this embodiment are implemented as software functional units and sold or used as independent products, they can be stored in one or more computing device-readable storage media. Based on this understanding, the parts of this application's embodiments that contribute to the prior art or the technical solutions can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computing device (which may be a personal computer, server, mobile computing device, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage media include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.

[0051] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language C++ and the embedded programming language C.

[0052] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0053] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0054] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0055] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the water quality spatiotemporal prediction method described above.

[0056] The computer program product provided in this application solves the technical problems of existing prediction methods based on spatiotemporal graph neural networks, such as the rapid increase in computational complexity with the number of nodes, which is not conducive to the promotion in large-scale water quality prediction models, and the decrease in accuracy in dynamic environments. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the spatiotemporal water quality prediction method provided in the above embodiments, and will not be repeated here.

[0057] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0058] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for spatiotemporal prediction of water quality, characterized in that, Including the following steps: S1. Construct the short-term time-scale input sequence X of the water quality prediction model based on the observed water quality indicators at different time scales of each monitoring station. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Based on the graph structure G formed by the monitoring stations, graph structures G for each input sequence are constructed respectively. s G m G l Graph structure G s G m G l Each node represents the water quality index observation value of each monitoring station at different time scales, and each edge represents the spatial relationship between monitoring stations, which is represented by the adjacency matrix A. S2. Construct a water quality prediction model that combines graph neural networks and graph selective state space modeling for water quality prediction. The water quality prediction model includes three input sequences X that each receive a short-term timescale. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l The processing branches are based on the graph structure G of each input sequence. s G m G l After adaptively and dynamically updating the adjacency matrix of the water quality prediction model, extracting temporal evolution features at different time scales, and filtering key information, the features are concatenated, fused, and dimensionality reduced to obtain the predicted water quality value. Each processing branch includes an adaptive adjacency matrix adjustment module, which is used for: Updating the adjacency matrix A yields the following results: ; ; (•) represents the neighborhood attention function, and M is a learnable parameter matrix. ; Perform graph convolution operations using the updated adjacency matrices A1 and A2 respectively: ; ; ; Where X represents the input sequence at the corresponding time scale. Let represent the set of features of each node obtained after graph convolution operation on the adjusted branch of the neighborhood self-attention adjacency matrix. This represents the set of features for each node obtained after graph convolution in the branch where the adjacency matrix is ​​adaptively adjusted by introducing a learnable parameter matrix M. This represents the node features output by the graph convolutional neural network and B represents the training batch, d model This represents the vector dimension of each node after feature extraction. Represents a non-linear activation function. This represents the learnable weight matrix of the convolutional layer in branch two. Let denote the learnable weight matrix of the convolutional layer in branch one. This indicates the bias term corresponding to the convolutional layer in branch one. This represents the bias term corresponding to the convolutional layer in branch two.

2. The spatiotemporal prediction method for water quality according to claim 1, characterized in that, In step S1, the input sequence at a short time scale is used to record the fluctuation characteristics of water quality indicators observed in minute-level or hour-level monitoring; the input sequence at a medium time scale is used to record the phased change patterns of water quality indicators observed in daily or weekly scales; and the input sequence at a long time scale is used to record the phased change patterns of water quality indicators observed in monthly or seasonal scales.

3. The spatiotemporal prediction method for water quality according to claim 1, characterized in that, In step S1, the input sequence X of the water quality prediction model at the short-term time scale s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Represented as: , , ; Where R represents the set of real numbers, T s T represents the time series length of the input sequence at a short time scale. m T represents the time series length of the input sequence at a medium-term time scale. l The input sequence represents the time series length over a long time scale, N represents the number of monitoring stations included in the water quality prediction model, and F represents the feature quantity at each time point.

4. The spatiotemporal prediction method for water quality according to claim 1, characterized in that, Each processing branch also includes a state space modeling and filtering module, which is used for: The node features output by the adaptive adjacency matrix adjustment module are mapped and compressed using a linear layer; The node features, after feature dimension mapping and compression, are introduced into a one-dimensional convolutional layer to capture local temporal patterns, and then the SiLU activation function is used to enhance the non-linearity of feature representation. The processed node features are input into the graph-selective state-space modeling module to achieve joint modeling of temporal dependencies and spatial structure, thus obtaining the first feature space: ; The first feature space is mapped to the feature dimension before the introduction of the one-dimensional convolutional layer and the compressed node features are multiplied point by point and then input into the linear layer for dynamic weighting and residual adjustment filtering to obtain the second feature space. : ; The original feature space f of the input sequence at the time scale corresponding to the current processing branch is superimposed onto the second feature space. The third feature space at the corresponding time scale is obtained. To align and integrate it with the feature selection results: 。 5. The spatiotemporal prediction method for water quality according to claim 4, characterized in that, The step of performing feature splicing, fusion, and dimensionality reduction to obtain the water quality prediction value specifically includes the following steps: The third feature space from the three different time scales output by each processing branch is concatenated, then input into a linear layer for feature fusion and dimensionality reduction to obtain the predicted value: ; in, The third feature space represents the short-term timescale. The third feature space represents the intermediate timescale. The third feature space represents the long-term timescale.

6. The spatiotemporal prediction method for water quality according to claim 5, characterized in that, Step S2 further includes the step of: constructing a loss function for a water quality prediction model that combines graph neural networks and graph selective state space modeling. ; in, α and β δ is an adjustable weighting coefficient used to balance the mean squared error's ability to fit the overall error with Huber Loss's robustness to outliers; δ>0 is the threshold parameter for Huber Loss. T Indicates the prediction time step. V This refers to the types and quantities of water quality indicators. t For a specific time step, v For a specific water quality indicator, and These represent the time steps. t and water quality indicators v The actual value and the predicted value are as follows. r Represents the true value Compared with the predicted value The residual.

7. A water quality spatiotemporal prediction device, characterized in that, include: The input feature construction module is used to construct the short-term time-scale input sequence X of the water quality prediction model based on the observed water quality indicators at different time scales of each monitoring station. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l Based on the graph structure G formed by the monitoring stations, graph structures G for each input sequence are constructed respectively. s G m G l Graph structure G s G m G l Each node represents the water quality index observation value of each monitoring station at different time scales, and each edge represents the spatial relationship between monitoring stations, which is represented by the adjacency matrix A. The water quality prediction module is used to construct a water quality prediction model that combines graph neural networks and graph selective state space modeling for water quality prediction. The water quality prediction model includes three input sequences X that each receive a short-term timescale. s Input sequence X at a medium-term time scale m Input sequence X on a long time scale l The processing branches are based on the graph structure G of each input sequence. s G m G l After adaptively and dynamically updating the adjacency matrix of the water quality prediction model, extracting temporal evolution features at different time scales, and filtering key information, the features are concatenated, fused, and dimensionality reduced to obtain the predicted water quality value. Each processing branch includes an adaptive adjacency matrix adjustment module, which is used for: Updating the adjacency matrix A yields the following results: ; ; (•) represents the neighborhood attention function, and M is a learnable parameter matrix. ; Perform graph convolution operations using the updated adjacency matrices A1 and A2 respectively: ; ; ; Where X represents the input sequence at the corresponding time scale. Let represent the set of features of each node obtained after graph convolution operation on the adjusted branch of the neighborhood self-attention adjacency matrix. This represents the set of features for each node obtained after graph convolution in the branch where the adjacency matrix is ​​adaptively adjusted by introducing a learnable parameter matrix M. This represents the node features output by the graph convolutional neural network and B represents the training batch, d model This represents the vector dimension of each node after feature extraction. Represents a non-linear activation function. This represents the learnable weight matrix of the convolutional layer in branch two. Let denote the learnable weight matrix of the convolutional layer in branch one. This indicates the bias term corresponding to the convolutional layer in branch one. This represents the bias term corresponding to the convolutional layer in branch two.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the spatiotemporal prediction method for water quality as described in any one of claims 1 to 6.

9. A storage medium comprising a stored program, characterized in that, When the program is running, it controls the device containing the storage medium to perform the steps of the spatiotemporal prediction method for water quality as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Water quality prediction method based on graph neural network and spatial-temporal feature fusion

    CN119598402A

  • Marine environmental element prediction method based on STEOF-LSTM

    JP7175415B1