A method for predicting terminal data of smart Internet of Things based on time series graph network model
By combining the graph attention network and the gated recurrent network into a temporal graph network model, the dynamic and noise interference problems of IoT terminal data are solved, and more efficient data prediction and decision support are achieved, which is suitable for a variety of application scenarios.
Patent Information
- Application Number
- CN202411597327.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2044-11-11
AI Technical Summary
The prediction of IoT terminal data faces the technical problems of strong data dynamics, high uncertainty, noise interference, outliers and missing values, which are difficult to be effectively dealt with by existing technologies. The prediction of IoT terminal data faces the technical problems of strong data dynamics, high uncertainty, noise interference, outliers and missing values, which are difficult to be effectively dealt with by existing technologies. The existing technologies are difficult to effectively deal with the noise, outliers and missing values of IoT terminal data, and traditional prediction methods have poor adaptability.
A method based on the temporal graph network model is adopted, combined with the graph attention network (GAT) and the gated recurrent neural network (GRU). The model parameters are optimized through time and space constraints, the spatiotemporal correlation information is captured, and a temporal graph network model is constructed to process IoT terminal data.
It improves the accuracy and robustness of IoT terminal data prediction and is suitable for various application scenarios such as environmental monitoring, smart cities, industrial control, and healthcare, providing more accurate decision support.
Smart Images

Figure CN119577360B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a graph neural network algorithm, and belongs to the technical field of graph network model learning algorithm models. More specifically, it relates to a smart Internet of Things terminal data prediction method based on a time-series graph network model. Background Art
[0002] With the rapid development of the Internet of Things (IoT), a large number of IoT devices (such as sensors, embedded devices, and smartphones) are being deployed worldwide to collect and transmit a variety of environmental data. The time series data generated by these IoT devices has a wide range of applications, including but not limited to environmental monitoring, smart city management, industrial production control, healthcare, and intelligent transportation systems. Therefore, accurately predicting and analyzing this data is crucial for optimizing resource utilization, improving efficiency, and enabling intelligent decision-making.
[0003] However, predicting IoT device data faces multiple challenges. First, this data is often time-series data, which is highly dynamic and uncertain. Second, the data may be affected by noise, outliers, and missing values, which can affect prediction accuracy. Furthermore, the data generated by different types of devices is diverse, requiring adaptation to a variety of prediction models. Traditional prediction methods struggle to effectively address these challenges, necessitating a new approach to improve the accuracy and robustness of predictions for IoT device data. Summary of the Invention
[0004] In view of this, the present invention provides a smart Internet of Things terminal data prediction method based on a time-series graph network model, which can solve the problems faced by the above-mentioned smart Internet of Things terminal data prediction, such as strong data dynamics, high uncertainty, noise interference, outliers, missing values and limited application.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] An embodiment of the present invention provides a method for predicting data of a smart IoT terminal based on a time sequence graph network model, comprising the following steps:
[0007] Step 1: Input the raw IoT terminal interaction data without batch processing, perform dot product operations on it with the time constraints of different time periods, and obtain the IoT information time series features with time constraints;
[0008] Step 2: Build a temporal graph network model, including the graph attention network GAT and the gated recurrent network GRU;
[0009] Step 3: After batch processing, the IoT interaction features with time constraints are passed through the graph attention network (GAT) to capture the spatial correlation of the IoT interaction network.
[0010] Step 4: Use the output of the graph attention network (GAT) as the input of the gated recurrent network (GRU) to capture temporal correlations and output the predicted value using a linear function.
[0011] Step 5: Calculate the loss function between the predicted value and the true value and perform a dot product operation with the spatial constraints based on the spatial architecture to optimize the parameters of the temporal graph network model;
[0012] Step 6: Input the historical data of the IoT terminal to be predicted into the optimized time series graph network model to obtain the corresponding prediction results.
[0013] Furthermore, the step 2 constructs a timing diagram network model, which is expressed as follows:
[0014]
[0015] Where, represents the prediction result at time step t, that is, the IoT interaction feature matrix for the next p time steps; q(·): represents the prediction function, and the input is the IoT interaction network Historical and current IoT interaction feature matrix Q t and space-time constraints
[0016] Furthermore, the step 1 further includes: performing a normalization operation on the time constraints t of different time periods, which is represented by T as follows:
[0017] T=α·e minmax_scaler(1-t) (2)
[0018] Where T represents the normalized time constraint, which is used for model input; t represents the time step index; α represents the hyperparameter used to adjust the influence of the time constraint; e represents the exponential function e x ; minmax_scaler() represents the maximum and minimum normalization function, which normalizes the input data to (0, 1);
[0019] So f can be expressed as:
[0020]
[0021] In formula (3), T represents the set of all normalized time constraints, including constraints of f time steps; i represents the normalized temporal constraint term at time step i.
[0022] Furthermore, step S3 includes:
[0023] The graph attention network GAT uses the self-attention mechanism to calculate the attention coefficient between nodes using the following formula:
[0024] e ij =a([Q tco t ] i,: W qx , [Q tco t ] j,: W qx ) (7)
[0025] Note the coefficient e ij Indicates the importance of the feature of node j to node i; the attention mechanism a represents a single-layer feedforward neural network, which is composed of the weight vector Parameterized and applied LeakyReLU nonlinear activation function with input slope of negative 0.2; [Q tco t ] i,: W qx represents the high-order features of node i; [Q tco t ] j,: W qx represents the high-order features of node j; W qx Represents the weight matrix, which is used to convert node features into high-order features; that is, formula (7) is expanded to:
[0026]
[0027] in,. T represents transposition, and || represents concatenation.
[0028] Furthermore, the step 3 further includes:
[0029] For the attention coefficient e ij Normalization is performed through the Softmax function:
[0030]
[0031] Among them, α ij Represents the normalized attention coefficient; softmax j represents the softmax function, which is used to normalize the correlation between node i and all neighboring nodes; represents the neighbor nodes of node i in the IoT interaction network; e ik Indicates the importance of the feature of node k to node i; v k Represents the feature vector of node k.
[0032] Furthermore, in step 4, the gated recurrent network GRU calculates the reset gate and the update gate using the following formula:
[0033] R t =σ(X tco t W xr +H t-1 W hr +b r ) (13)
[0034] Z t =σ(X tco t W xz +H t-1 W hz +b z ) (14)
[0035] Among them, R t Represents the reset gate; σ represents the sigmoid function, which is used to compress the input data into the range of (0, 1); X tco t W xr Represents the input and weight matrix W at time step t xr The product of t-1 W hr Represents the hidden state matrix and weight matrix W of the previous time step hr The product of
[0036] Z t represents the update gate; X tco t W xz Represents the input and weight matrix W at time step t xz The product of t-1 W hz Represents the hidden state matrix and weight matrix W of the previous time step hz The product of
[0037] and is the weight matrix, is the bias vector.
[0038] Furthermore, in step 4, the candidate hidden state matrix of the gated recurrent network GRU at time step t is expressed as:
[0039]
[0040] Among them, H t represents the hidden state matrix at time step t; H t-1 represents the hidden state matrix of the previous time step; represents the candidate hidden state matrix.
[0041] Furthermore, the spatial constraints in step 5 need to be normalized by maximization and minimization, which can be expressed as follows:
[0042]
[0043] Among them, minmax_scaler() represents the maximum and minimum normalization function, which normalizes the input data to (0, 1); Represents spatial constraints, including spatial features of n nodes.
[0044] Furthermore, the loss function in step 5 is expressed as follows:
[0045]
[0046] in, represents the regularization term used to avoid overfitting problems, φ represents all parameters in the temporal graph network model, λ represents the hyperparameter; p represents the number of prediction steps; represents the true value of node j at time step t+j; represents the predicted value of node j at time step t+j; S i represents the normalized spatial constraint term of node i.
[0047] Furthermore, in step 4, the graph attention network GAT and the gated recurrent network GRU exchange information through shared parameters, and the weight matrix and bias vector are shared by all time steps.
[0048] It can be seen from the above technical solutions that compared with the prior art, the present invention has the following advantages:
[0049] This method combines a graph attention network (GAT) and a gated recurrent neural network (GRU). It effectively captures spatiotemporal correlations in data and leverages temporal and spatial constraints to improve predictions. This method is applicable to a variety of IoT applications, such as environmental monitoring, smart cities, industrial control, and healthcare, providing more accurate support for decision-making. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0051] Figure 1Flowchart of the method for predicting data of smart IoT terminals based on a time sequence diagram network model provided by the present invention.
[0052] Figure 2 This is a structural diagram of the timing diagram network model provided by the present invention.
[0053] Figure 3 The timing diagram network model provided by the present invention generates a schematic diagram. DETAILED DESCRIPTION
[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0055] The present invention aims to address the above challenges and provides a method for predicting data of smart IoT terminals based on a time-series graph network model. The time-series graph network model is an emerging machine learning method that combines the techniques of graph neural networks and time series analysis, and can effectively capture the spatiotemporal correlation information in time series data. The model has the following key features: 1) It can process different types of time series data, including univariate and multivariate time series data. 2) It has powerful representation learning capabilities and can automatically learn features and patterns in the data. 3) It can handle noise, outliers and missing values, improving the robustness of the prediction. 4) It can perform long-term and short-term predictions and is suitable for a variety of application scenarios.
[0056] The overall solution of the present invention: 1) For the problems of low prediction accuracy and model incompatibility caused by input data of different spatial structures, a spatiotemporal network model combining Graph Attention Networks (GAT) and Gate Recurrent Unit (GRU) is proposed. 2) For the influence of the distribution characteristics of spatial buildings around the sensor information collection point that cannot be fully exploited, valuable information composed of external conditions is embedded into the spatiotemporal network model and constructed as spatiotemporal constraints. The present invention is an efficient, accurate and robust method for predicting IoT terminal data to meet the growing demand for IoT applications. Compared with traditional prediction methods, the method based on the time-series graph network model has better performance and adaptability, and can be applied in various complex environments. By combining graph neural networks and time series analysis, the present invention can better understand and utilize IoT terminal data, providing more support for decision-making.
[0057] This invention represents a significant technological breakthrough in the field of IoT terminal data prediction and is expected to have a profound impact in areas such as environmental monitoring, smart cities, industrial control, and healthcare. Below, we describe the technical implementation and innovations of this invention, as well as its practical applications in related fields.
[0058] The present invention provides a method for predicting data of intelligent IoT terminals based on a time-series graph network model. The method mainly uses GAT to construct the spatial features of IoT interaction data, which is then input into GRU in the form of a time series to extract the temporal features. The model adds time constraints and spatial constraints to the input and loss functions to improve the prediction effect:
[0059] Reference Figure 1 As shown, the following steps 1-6 are included:
[0060] Step 1: Input the raw IoT terminal interaction data information without batch processing, perform dot product operation on it with the time constraints of different time periods, and obtain the IoT information time series features with time constraints.
[0061] Raw data is the interactive information from IoT devices, which may come from a variety of sensors, devices, or systems. First, the raw data is directly input without any processing. Because IoT device data is time-series, the model introduces a time constraint in this step to capture the data's temporal characteristics. The calculation of the time constraint involves performing a dot product operation on the data, ensuring that the temporal characteristics are fully preserved during data processing. This operation generates data with temporal characteristics, ensuring that the model can better understand the temporal changes in IoT data.
[0062] Step 2: Build a timing diagram network model, refer to Figure 2 As shown, it includes: graph attention network GAT and gated recurrent network GRU.
[0063] The construction of the temporal graph network model includes two core components: the Graph Attention Network (GAT) and the Gated Recurrent Unit (GRU), which process information in the spatial and temporal dimensions respectively.
[0064] GAT: Focuses on capturing the spatial relationships between IoT devices. Through information exchange between neighboring nodes, GAT can learn the spatial dependencies between nodes.
[0065] GRU: Processes information in the time dimension and is particularly adept at processing long sequences of data. It uses a memory and forgetting mechanism to effectively extract important features from time series while ignoring irrelevant or noisy data.
[0066] The model as a whole combines these two parts to form the ability to process spatiotemporal data simultaneously.
[0067] Step 3: After batch processing, the IoT interaction features with time constraints are fed into the Graph Attention Network (GAT) to capture the spatial correlation of the IoT interaction network. In this step, the feature data with time constraints are batch processed and then fed into the Graph Attention Network (GAT).
[0068] The task of GAT is to capture the spatial correlation in the IoT interaction network, that is, the mutual influence between devices, through the attention mechanism. This mechanism calculates the relationship weight between each node (i.e., IoT device) and its neighboring nodes to generate features that reflect spatial dependencies.
[0069] During batch processing, data is passed through a shared attention mechanism of multiple nodes to calculate the weights between nodes and obtain the spatial features of each node.
[0070] Step 4: Use the output of the graph attention network GAT as the input of the gated recurrent network GRU to capture temporal correlation; and use a linear function to output the predicted value.
[0071] The spatial feature output generated by the Graph Attention Network (GAT) is then fed into a Gated Recurrent Unit (GRU). The GRU's task is to further process the temporal information in the data while capturing correlations in the time series. By updating and resetting gates, the GRU can effectively remember historical information or discard useless information, capturing dependencies between different time steps.
[0072] Output prediction value: After the GRU processes the information in the time dimension, it uses a linear function to convert the network output into a prediction value. This linear function performs a weighted summation of the extracted features to obtain the prediction result.
[0073] Step 5: Calculate the loss function between the predicted value and the true value and perform dot product operation with the spatial constraints based on spatial architecture to optimize the parameters of the time series graph network model. The principle can be referred to Figure 3 shown.
[0074] This step aims to optimize the model using a loss function. The loss function is calculated by comparing the error between the predicted value and the actual value.
[0075] Introducing spatial constraints: To further improve the model's prediction accuracy, the model not only considers temporal information but also the spatial environment (such as building layout) in which the IoT devices reside. By performing a dot product operation on the predicted values and the spatial constraints, the model parameters can be optimized to better align with spatial relationships in the physical world.
[0076] Through an optimization process of the loss function and spatial constraints, the model gradually adjusts its parameters to improve the accuracy of future predictions.
[0077] Step 6: Input the historical data of the IoT terminals to be predicted into the optimized time-series graph network model to obtain the corresponding prediction results. Finally, the optimized time-series graph network model can be used for actual IoT data prediction. Specifically, the historical data of the IoT terminals is input into the optimized model, which combines spatial and temporal features to generate the final prediction results. These prediction results can be used for intelligent decision-making in various IoT application scenarios, such as environmental monitoring and equipment control.
[0078] The key to this method is to process spatiotemporal data simultaneously and achieve efficient prediction of IoT terminal data through the collaboration of GAT and GRU. The design of each step helps to improve the prediction accuracy and adaptability of the model.
[0079] The technical solution of the present invention is described in detail below:
[0080] Given an IoT interaction network Space-time constraints Combined with the history at time t and the current IoT interaction feature matrix The prediction result of time step t is modeled as the IoT interaction feature matrix of the next p time steps, recorded as Represents the predicted IoT interaction feature matrix of the IoT interaction information collection point at time step t; Q represents a node, representing an IoT terminal device, such as a sensor, embedded device, smart phone, etc.; ε represents an edge, representing the interaction relationship between IoT terminal devices, such as communication connection, data transmission, etc. t Represents the IoT interaction feature matrix, which contains historical data at time t and before. The meanings of each parameter are as follows:
[0081] q t-l : represents the IoT interaction feature vector at time step tl.
[0082] q t-1 : represents the IoT interaction feature vector at time step t-1.
[0083] q t : Represents the IoT interaction feature vector at the current time t.
[0084] n: represents the number of nodes in the IoT interaction network.
[0085] l: represents the length of the historical time step, that is, the range of historical data considered by the model.
[0086] Q tIt is an nx(l+1) matrix, where n represents the number of nodes and 1 represents the length of the historical time step. Each row represents a node and each column represents the feature of a time step.
[0087] Represents the predicted IoT interaction feature matrix, which contains the predicted data at time t and p time steps thereafter.
[0088] Predicted IoT interaction feature vector at time step t+1.
[0089] Predicted IoT interaction feature vector at time step t+2.
[0090] The predicted IoT interaction feature vector at time step t+p.
[0091] n: represents the number of nodes in the IoT interaction network. p: represents the number of time steps for prediction.
[0092] It is an n x p matrix, where n represents the number of nodes and p represents the number of predicted time steps. Each row represents a node and each column represents the predicted features for a time step.
[0093] The timing diagram network model constructed in step 2 is expressed as:
[0094]
[0095] In formula (1), It represents the prediction result of time step t, that is, the IoT interaction feature matrix of the next p time steps. q represents the prediction function, and the input is the IoT interaction network Historical and current IoT interaction feature matrix Q t and space-time constraints
[0096] It represents the interactive network of the Internet of Things, which consists of nodes and edges. Nodes represent IoT terminal devices, and edges represent the interactive relationships between devices.
[0097] Q t : Represents the history of time step t and the current IoT interaction feature matrix, which contains the feature information of n nodes from time step tl to t.
[0098] Represents spatiotemporal constraints, including time constraints and space constraints.
[0099] Preferably, in order to avoid data dispersion, the time constraints of different time periods are The normalization operation is performed and the result is expressed as T as follows:
[0100] T=α·e minmax_scaler(1-t) (2)
[0101] Among them, α is a hyperparameter used to adjust the influence of time constraints; e represents the exponential function e x minmax_scaler() represents the maximum and minimum normalization function, which normalizes the input data to (0, 1). T represents the time constraint after normalization, which is used for model input.
[0102] t represents the time step index, so So T can be expressed as:
[0103]
[0104] T in formula (3) represents the set of all normalized time constraints, including constraints of f time steps. f represents the time constraint term normalized at time step f; that is, T i represents the normalized temporal constraint term at time step i.
[0105] Preferably, a graph attention network is used to construct the spatial structure relationship of the IoT interaction network. GAT automatically captures the spatial relationship between nodes and between nodes and lines through the attention coefficient. The input of the graph attention layer is the IoT interaction feature matrix Q with time constraints tco The result after batch processing, at the input of time step t, can be obtained:
[0106]
[0107] in, It is represented as the IoT interaction characteristics of n nodes with time constraints at time step i. tco t represents the IoT interaction feature matrix with time constraints for the historical time step of length l and the current time step t, and Q tco t It can also be expressed as:
[0108]
[0109] in Represents node v i The feature vector of IoT interactions with time constraints at the historical time step l and the current time step t.
[0110] Preferably, the input of each node is mined for spatial correlation using GAT to obtain the output of the graph attention network.
[0111] The output of the graph attention layer is a set of high-level IoT interaction feature matrices with time constraints, expressed as:
[0112]
[0113] Among them, X tco t Represents the output of the graph attention layer, which contains n nodes of higher-level IoT interaction feature vectors with time constraints. x is the output feature dimension, Represents the Internet of Things interaction network Midpoint v i A more advanced IoT interaction feature vector with time constraints. GAT specifically implements the following:
[0114] First, for each node of the input, the weight matrix The parameterized shared linear transformation [Q tco t ] i,: W qx Converted into high-order features, the nodes are then shared through the self-attention mechanism to calculate the attention coefficient as follows:
[0115] e ij =a([Q tco t ] i,: W qx , [Q tco t ] j,: W qx ) (7)
[0116] Note the coefficient e ij Indicates the importance of the feature of node j to node i. The attention mechanism a is a single-layer feedforward neural network composed of a weight vector Parameterized and applied with a LeakyReLU nonlinear activation function with an input slope of negative 0.2. [Q tco t ] i,: W qx represents the high-order features of node i; [Q tco t ] j,: W qx represents the high-order features of node j; W qx represents the weight matrix, which is used to convert node features into high-order features; that is, formula (7) can be expanded to:
[0117]
[0118] in, represents transposition, and || represents concatenation.
[0119] In order to gather the information of neighboring nodes, it is necessary to calculate the correlation e between the target node and all neighboring nodes. ij Perform unified normalization and apply the softmax function to obtain the normalized attention coefficient as follows:
[0120]
[0121] Among them, α ij Represents the normalized attention coefficient; softmax j represents the softmax function, which is used to normalize the correlation between node i and all neighboring nodes; Represents the neighbor nodes of node i in the IoT interaction network. ik Indicates the importance of the feature of node k to node i; v k Represents the feature vector of node k.
[0122] Normalized attention coefficient α ii It is used to calculate the linear combination of the corresponding feature vectors, to aggregate information, and to obtain the output feature vector of each node through a nonlinear activation function:
[0123]
[0124] [X tco t ] i,: Represents the output feature vector of node i. Activation represents a nonlinear activation function, which is used to increase the nonlinear expression capability of the model.
[0125] Represents the linear combination of the feature vector of the neighboring nodes of node i and the attention coefficient.
[0126] Finally, the output feature matrix at time step t is constructed as follows:
[0127]
[0128] X tco t The output feature matrix of time step t contains the more advanced IoT interaction features with time constraints of n nodes. The temporal graph network model TSGAT only uses one graph attention layer. In the above process, the weight matrix and weight vector are shared by all nodes and all pairs of nodes, respectively, at all time steps.
[0129] Preferably, the output of the graph attention layer is used as the input of the gated recurrent network, which can be expressed as:
[0130]
[0131] Among them, X tco t Represents the input at time step t, which contains the high-level IoT interaction features with time constraints of n nodes from time step tl to t.
[0132] x tco i represents the high-level time-constrained IoT interaction features of n nodes at time step i. Assuming the number of units in the GRU hidden layer is h, Represents the hidden state matrix at time step t-1. Given a mini-batch input X at time step t tco t and the hidden state matrix of the previous time step t-1 Reset Gate and update gate The calculations are as follows:
[0133] R t =σ(X tco t W xr +H t-1 W hr +b r ) (13)
[0134] Z t =σ(X tco t W xz +H t-1 W hz +b z ) (14)
[0135] in, and is the weight matrix, is the bias vector. σ represents the sigmoid function, which is used to compress the input data into the range of (0, 1); X tco t W xr Represents the input and weight matrix W at time step t xr The product of t-1 W hr Represents the hidden state matrix and weight matrix W of the previous time step hr The product of tco t W xz Represents the input and weight matrix W at time step t xz The product oft-1 W hz Represents the hidden state matrix and weight matrix W of the previous time step hz The product of
[0136] The candidate hidden state matrix at time step t is expressed as:
[0137]
[0138] Among them, the tanh function is used to compress the input data into the range of (-1, 1). tco t W xh Represents the input and weight matrix W at time step t xh The product of .
[0139] (R t ⊙H t-1 )W hh Represents the product of the reset gate and the previous hidden state matrix and the weight matrix W hh ⊙ represents the Hadamard product, which is the product of corresponding elements. is the weight matrix, is the bias vector. Reset gate R t Controls how the hidden state matrix at the previous time step flows into the candidate hidden state matrix at the current time step.
[0140] Based on the hidden state matrix H of the previous time step t-1 and the candidate hidden state matrix The hidden state matrix at time step t can be calculated as the update gate Z t A weighted linear combination, that is:
[0141]
[0142] Among them, H t represents the hidden state matrix at time step t; H t-1 represents the hidden state matrix of the previous time step; represents the candidate hidden state matrix.
[0143] Finally, based on the hidden state matrix, a fully connected layer is used to calculate the output of the entire IoT interaction network at time step t, that is, the prediction result as follows:
[0144]
[0145] Among them, H t W represents the hidden state matrix at time step t. hpRepresents the weight matrix used to transform the hidden state matrix into the prediction result. is the weight matrix, is the bias vector.
[0146] In the above process, the weight matrix at the same time Shared by all time steps. Bias vector is also shared by all time steps.
[0147] Preferably, in order to avoid data dispersion, the spatial constraint Normalized to get:
[0148]
[0149] Among them, minmax_scaler() represents the maximum and minimum normalization function, which normalizes the input data to (0, 1). So S is expressed as:
[0150]
[0151] That is, the set of all normalized space constraints. i represents the normalized spatial constraint term at node i. During the training process, let Represents the prediction results of all nodes in the next p time steps, Represents the corresponding true result, and the loss function is as follows:
[0152]
[0153] in is a regularization term used to avoid overfitting, φ is all the parameters in the TSGAT model, and λ is a hyperparameter. ; p represents the number of prediction steps; represents the true value of node j at time step t+j; represents the predicted value of node j at time step t+j; S i represents the normalized spatial constraint term of node i.
[0154] The following takes urban transportation as an example to illustrate:
[0155] Assume that a large number of traffic sensors are deployed in a city to collect vehicle flow data at different intersections. Each intersection is considered a node, and the connections between nodes represent road connections. The flow data collected by each node is time series data, for example, recording flow every 5 minutes.
[0156] Step 1: Input the vehicle flow data from traffic sensors at urban intersections without batch processing, perform dot product operations on it with the time constraints of different time periods, and obtain the time series features of vehicle flow data with time constraints;
[0157] Step 2: Build a temporal graph network model, including the graph attention network GAT and the gated recurrent network GRU;
[0158] Step 3: After batch processing, the time series features of vehicle flow data with time constraints are passed through the graph attention network (GAT) to capture the spatial correlation between urban intersections.
[0159] Step 4: Use the output of the graph attention network (GAT) as the input of the gated recurrent network (GRU) to capture the temporal correlation of traffic flow and output the predicted value using a linear function.
[0160] Step 5: Calculate the loss function between the predicted value and the true value and perform a dot product operation with the spatial constraints based on the spatial architecture to optimize the parameters of the temporal graph network model;
[0161] Step 6: Input the historical traffic data of the intersection to be predicted into the optimized time series graph network model to obtain the corresponding traffic prediction results.
[0162] Specific steps:
[0163] 1. Data preprocessing:
[0164] The historical traffic data of each intersection is used as input to generate time series data. Based on the road connections between intersections, a graph structure is constructed to represent the IoT interaction network.
[0165] Define time constraints, such as setting different weights for different time periods of the day to reflect the temporal patterns of traffic flow.
[0166] Define spatial constraints, such as setting different weights based on the distance between intersections or road types to reflect the spatial patterns of traffic flow.
[0167] 2. Build a spatiotemporal network model:
[0168] GAT layer: Inputs time-constrained traffic data and uses the GAT layer to capture the spatial correlation between intersections. The GAT layer learns the feature representation of each intersection based on the connection relationship between nodes and the attention mechanism.
[0169] GRU layer: The output of the GAT layer is used as input to further capture temporal correlations. The GRU layer learns how traffic changes over time based on historical traffic data.
[0170] Linear layer: The output of the GRU layer is passed through the linear layer to obtain the traffic prediction value of each intersection in the future.
[0171] 3. Model training and optimization:
[0172] Calculate the loss function between the predicted value and the true value, such as the mean squared error (MSE). Perform a dot product operation on the loss function and the spatial constraints to further optimize the model parameters. Repeat the training process until the model converges.
[0173] 4. Prediction:
[0174] The historical traffic data of the intersection to be predicted is input into the optimized spatiotemporal network model to obtain the corresponding traffic prediction results.
[0175] For example:
[0176] Time constraint: The traffic weight between 7:00 AM and 9:00 AM is 1.2, indicating that traffic is heavier during the morning rush hour.
[0177] Spatial constraint: The intersections closer to the city center have a weight of 1.1, indicating that the traffic volume in the city center is larger.
[0178] Prediction: Predict the vehicle flow at each intersection in the next 15 minutes.
[0179] Through the above steps, the spatiotemporal network model can effectively capture the spatiotemporal patterns of traffic flow and make accurate predictions, thereby providing decision support for traffic management.
[0180] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0181] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for predicting terminal data of intelligent Internet of Things based on a time sequence graph network model, characterized in that: The following steps are involved: Step 1: Input the raw IoT terminal interaction data without batch processing, perform dot product operations on it with the time constraints of different time periods, and obtain the IoT information time series features with time constraints; Step 2: Build a temporal graph network model, including the graph attention network GAT and the gated recurrent network GRU; Step 3: After batch processing, the IoT interaction features with time constraints are passed through the graph attention network (GAT) to capture the spatial correlation of the IoT interaction network. Step 4: Use the output of the graph attention network (GAT) as the input of the gated recurrent network (GRU) to capture temporal correlations and output the predicted value using a linear function. Step 5: Calculate the loss function between the predicted value and the true value and perform a dot product operation with the spatial constraints based on the spatial architecture to optimize the parameters of the temporal graph network model; Step 6: Input the historical data of the IoT terminal to be predicted into the optimized time series graph network model to obtain the corresponding prediction results; Wherein, the step 1 further includes: performing a normalization operation on the time constraints t of different time periods, which is represented by T as follows: T=α·e minmax_scaler(1-t) (2) Where T represents the normalized time constraint, which is used for model input; t represents the time step index; α represents the hyperparameter used to adjust the influence of the time constraint; e represents the exponential function e x ; minmax_scaler() represents the maximum and minimum normalization function, which normalizes the input data to (0,1); So T can be expressed as: In formula (3), T represents the set of all normalized time constraints, including constraints of f time steps; i represents the normalized time constraint term at time step i; In step 4, the graph attention network GAT and the gated recurrent network GRU exchange information through shared parameters, and the weight matrix and bias vector are shared by all time steps; The spatial constraints in step 5 need to be processed by maximization and minimization normalization, which can be expressed as follows: Among them, minmax_scaler() represents the maximum and minimum normalization function, which normalizes the input data to (0,1); Represents spatial constraints, including spatial features of n nodes; The loss function in step 5 is expressed as follows: in, represents the regularization term used to avoid overfitting problems, φ represents all parameters in the temporal graph network model, λ represents the hyperparameter; p represents the number of prediction steps; represents the true value of node j at time step t+j; represents the predicted value of node j at time step t+j; S i represents the normalized spatial constraint term of node i.
2. The method for predicting terminal data of smart Internet of Things based on a time sequence graph network model according to claim 1, characterized in that: The step 2 constructs a timing diagram network model, and the expression is as follows: Where, represents the prediction result at time step t, that is, the IoT interaction feature matrix for the next p time steps; q(·): represents the prediction function, and the input is the IoT interaction network Historical and current IoT interaction feature matrix Q t and space-time constraints 3. The method for predicting terminal data of intelligent Internet of Things based on a time sequence graph network model according to claim 1 is characterized in that: The step 3 comprises: The graph attention network GAT uses the self-attention mechanism to calculate the attention coefficient between nodes using the following formula: e ij =a([Q tco t ] i,: W qx ,[Q tco t ] j,: W qx ) (7) Note the coefficient e ij Indicates the importance of the feature of node j to node i; the attention mechanism a represents a single-layer feedforward neural network, which is composed of the weight vector Parameterized and applied LeakyReLU nonlinear activation function with input slope of negative 0.2; [Q tco t ] i,: W qx represents the high-order features of node i; [Q tco t ] j,: W qx represents the high-order features of node j; W qx Represents the weight matrix, which is used to convert node features into high-order features; that is, formula (7) is expanded to: in, represents transposition, and || represents concatenation.
4. The method for predicting terminal data of intelligent Internet of Things based on a time sequence graph network model according to claim 3 is characterized in that: The step 3 further comprises: For the attention coefficient e ij Normalization is performed through the Softmax function: Among them, α ij Represents the normalized attention coefficient; softmax j represents the softmax function, which is used to normalize the correlation between node i and all neighboring nodes; represents the neighbor nodes of node i in the IoT interaction network; e ik Indicates the importance of the feature of node k to node i; v k Represents the feature vector of node k.
5. The method for predicting terminal data of intelligent Internet of Things based on a time sequence graph network model according to claim 1 is characterized in that: In step 4, the gated recurrent network GRU calculates the reset gate and the update gate using the following formula: R t =σ(X tco t W xr +H t-1 W hr +b r ) (13) Z t =σ(X tco t W xz +H t-1 W hz +b z ) (14) Among them, R t Represents the reset gate; σ represents the sigmoid function, which is used to compress the input data into the range of (0,1); X tco t W xr Represents the input and weight matrix W at time step t xr The product of t-1 W hr Represents the hidden state matrix and weight matrix W of the previous time step hr The product of Z t represents the update gate; X tco t W xz Represents the input and weight matrix W at time step t xz The product of t-1 W hz Represents the hidden state matrix and weight matrix W of the previous time step hz The product of and is the weight matrix, is the bias vector.
6. The method for predicting terminal data of intelligent Internet of Things based on a time sequence graph network model according to claim 5, characterized in that: In step 4, the candidate hidden state matrix of the gated recurrent network GRU at time step t is expressed as: Among them, H t represents the hidden state matrix at time step t; H t-1 represents the hidden state matrix of the previous time step; represents the candidate hidden state matrix.
Citation Information
Patent Citations
Water quality prediction method, device and equipment based on space-time fusion and storage medium
CN111882138A
Flood forecasting method based on distributed adaptive graph attention network
CN116702959A