A time series data prediction method with associated spatiotemporal relationships
By using the graph attention network and self-attention mechanism to extract spatial and temporal features in meteorological humidity data prediction, and combining the gating mechanism for spatio-temporal feature fusion, the problem of ignoring spatial dependence and long-term dependence in the existing technology is solved. Improved prediction accuracy and model generalization.
Patent Information
- Application Number
- CN202311394688.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-10-26
AI Technical Summary
The existing technology ignores the spatial dependence between data in time series prediction of meteorological humidity data. Traditional recurrent neural networks have long-term dependencies that are difficult to mine, and graph neural networks fail to effectively integrate spatiotemporal features, resulting in low prediction accuracy and poor generalization.
Using the space-dependent feature extraction module based on the graph attention network and the time-dependent feature extraction module of the self-attention mechanism, combined with the spatio-temporal feature fusion module of the gating mechanism, a comprehensive prediction model is constructed. By constructing a directed graph structure and a multi-head attention mechanism Extract the spatial and temporal characteristics of meteorological humidity data and dynamically assign weights during the fusion process.
It effectively solves the problem of traditional methods ignoring spatial dependence and long-term dependence phenomena, improves the spatiotemporal feature extraction and prediction accuracy of meteorological humidity data, and enhances the generalization and robustness of the model.
Smart Images

Figure CN117668743B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of data processing and regression prediction, and in particular relates to a method for predicting time series data with associated spatiotemporal relationships. Background Art
[0002] Time series forecasting is to predict the future based on existing historical data. It is widely used in meteorological humidity data, oil field production forecasting, stock market, fault detection and other aspects. The time series data (especially meteorological humidity data) obtained in the actual production process is nonlinear, non-steady-state, and has strong spatial correlation. Since traditional methods do not consider spatial correlation, the prediction accuracy is not high. In addition, since the spatial correlation between data is difficult to mine, especially how to fuse time and space features, there is currently no good solution. Therefore, how to fine-grainedly characterize the spatiotemporal characteristics of meteorological humidity data and then fuse spatiotemporal features is the key to affecting prediction accuracy, and it is also the focus of production dynamic prediction research.
[0003] Early research mainly focused on establishing autoregressive parameter models such as weighted moving average models and differential integrated moving average autoregressive models for prediction, which are simple and intuitive, but are very easy to lose dynamic dependency information between variables. At present, typical time series data mostly use traditional shallow machine learning such as artificial neural networks and support vector machines, which are difficult to mine the dynamic dependency relationship between data. If parameters are added, it is very easy to produce overfitting. Recurrent neural network models such as long short-term memory networks, gated recurrent units, minimum gated units, hybrid gated units and other variant models have problems such as long-term dependency and cumulative error. Therefore, some scholars have introduced self-attention mechanisms to carry out time series prediction, such as time fusion transformation networks, to capture long-term dependencies between sequences, and process them in parallel with fast calculation speed. However, typical time series data such as meteorological humidity data all have spatial correlations. For example, the data from multiple air humidity collection points are correlated. Wind direction and wind speed will disperse the moisture from a certain collection point to different collection points, causing the moisture at different collection points to influence each other. If there is a physical barrier between the collection points, such as a mountain, the spatial impact between the collection points may be smaller. If there is a power plant steam tower between the collection points, the airborne impact of the sensor collection point will become larger. Traditional shallow machine learning only considers time series features. Although the self-attention mechanism can reduce long-term dependence, it ignores the spatial correlation of the data, resulting in poor model generalization.
[0004] Graph neural network is a representation method for non-Euclidean spatial graph data. It is good at extracting the spatiotemporal structural features of graphs, which are divided into frequency domain and spatial domain. Spatial domain graph neural network methods such as message passing networks can process directed graphs but require full graph aggregation and have low computational efficiency. The latest space-time transform network (STTNS) provides spatial and temporal Transformer modules based on graph convolutional networks, which can effectively overcome the problem of cumulative errors. However, the graph convolutional network used in this network can only process undirected graphs, not directed graphs. However, air humidity is affected by wind direction and wind speed, and the results of winds in different wind directions are not the same. Therefore, a directed graph should be used to describe the spatial relationship of humidity sensor collection points, which is more universal, generalizable and robust. The graph attention network aggregates the spatial influence characteristics of its adjacent nodes by calculating the attention weights of the first-order neighbors of the current humidity collection point. It is suitable for directed graph calculations and has high accuracy and can be used to extract spatial dependencies.
[0005] In summary, the existing typical meteorological time series forecasting has the following problems: 1) It only starts from a single data and ignores the spatial dependency between data from different collection points. 2) The traditional recurrent neural network method has long-term dependencies, making it difficult to mine the long-range correlation between data and prone to data loss. 3) The existing graph neural network spatial feature extraction does not consider the fusion of spatiotemporal features, does not assign dynamic weights to temporal and spatial feature data, and reduces the accuracy of image data.
[0006] The difficulty of solving the above problems and defects is:
[0007] Early research was limited and it was almost impossible to predict highly nonlinear data such as temperature, air humidity, wind direction, and wind speed in meteorological humidity data. Adding mathematical constraints would increase the complexity of the calculation and fail to significantly improve the accuracy. Currently, few people use traditional methods for prediction.
[0008] In terms of extracting time features, shallow machine learning parameters are very complex, resulting in slow algorithm convergence, which makes it almost impossible to improve the multivariate time prediction effect by optimizing the model. In addition, its learning algorithm uses the principle of empirical risk minimization and cannot guarantee the minimization of expected risk, which makes the model prone to overfitting problems and easy to fall into local optimality.
[0009] In terms of extracting spatial features, the currently widely used basic graph convolutional network can only process undirected graphs. If the graph attention network is used to process directed graph data, it is necessary to consider how to adapt to time series data and use directed graphs to represent the spatial relationship of humidity sensor collection points.
[0010] In terms of fusing time and space features, the current method of fusing time and space features is only a simple addition. There is no separate allocation of dynamic weights for training for time and space features. It is very easy to lose data and cause distortion during the fusion process. It is necessary to design a trainable adaptive weight spatiotemporal feature fusion module. Summary of the invention
[0011] The purpose of the present invention is to solve the deficiencies of the above-mentioned background technology and to provide a method for predicting time series data with associated spatiotemporal relationships.
[0012] The technical solution adopted by the present invention is: a time series data prediction method with associated spatiotemporal relationship, comprising:
[0013] The following steps are involved:
[0014] S1: construct the required meteorological humidity data set, which includes air humidity data, temperature data, wind direction data, and wind speed data, and perform missing smoothing, extremely high value processing, and normalization processing on the data in the meteorological humidity data set;
[0015] S2: Establish an adjacency matrix based on whether there is spatial correlation between the data collection points in the meteorological humidity dataset;
[0016] S3: Use the adjacency matrix to build a spatial dependency feature extraction module based on the graph attention network to extract the spatial dependency features between the data collection points in the meteorological humidity dataset;
[0017] S4: Use the adjacency matrix to build a time-dependent feature extraction module based on the self-attention mechanism to extract the time-dependent features of the data at each time point in the meteorological humidity dataset;
[0018] S5: Construct a spatiotemporal feature fusion module using a gating mechanism to fuse the output features of the spatial-dependent feature extraction module and the temporal-dependent feature extraction module;
[0019] S6: Combine the above multiple modules to generate and train a comprehensive prediction model;
[0020] S7: Input the meteorological humidity dataset into the trained comprehensive prediction model and calculate the meteorological humidity prediction results.
[0021] Step S1 specifically includes:
[0022] 1) Missing smoothing:
[0023] The average value is taken for the short-term missing data in the meteorological humidity data set, and the time series data of three days before and after the data missing point is averaged and smoothed;
[0024] 2) Ultra-high value processing:
[0025] The abnormal high values caused by sensor distortion are processed, and the data of the five days before and after the abnormal high value point are eliminated;
[0026] 3) Normalization processing:
[0027] The data in the dimensional meteorological humidity data set is normalized into dimensionless scalar time series data. The specific method is as follows: ;
[0028] In the formula, is the real meteorological humidity data; , They correspond to the maximum and minimum values of the time series data respectively; is the normalized time series data.
[0029] Step S2 includes: defining a directed graph structure to describe the spatial relationship of spatial acquisition points, N collection points, each of which contains F attributes, directed graph of the meteorological humidity dataset G It can be expressed as:
[0030] ;
[0031] In the formula, the humidity sensor collection point structure is defined as ;in V It is the collection point of humidity sensor; E Whether there is a spatial influence relationship between the collection points; A is an adjacency matrix based on spatial relationship representation;
[0032] Plot of the meteorological humidity dataset G for , , For historical data length, is the number of attribute channels, They are used as inputs of the time-dependent feature extraction module and the space-dependent feature extraction module respectively;
[0033] The initial adjacency matrix of the graph attention network of the graph G is constructed as follows: ;
[0034] In the formula, Indicates the spatial correlation of the collection points and represents the adjacency matrix; Indicates the collection point i and j .
[0035] Step S4 includes: organizing the data in the meteorological humidity data set into a time series data sequence in chronological order and inputting it into the time embedding layer. The time embedding layer maps the attribute data in the time series sequence to a high-dimensional space and transforms the time series data features into fine-grained features for the weight calculation layer to extract time features. The time embedding layer processing calculation method is:
[0036] = ;
[0037] In the formula, is the high-dimensional fine-grained feature obtained by embedding, and is used as ( Q, K, V ) Input items of triple features;
[0038] The processing calculation method of the weight output layer is:
[0039] ;
[0040] ;
[0041] ;
[0042] ;
[0043] ;
[0044] ;
[0045] In the formula, , , They correspond to the Query, Key, and Value triples respectively; Represents the Key matrix The transpose of is the temporal attention map; Represents the output of the weight calculation layer; d k express Model; Respectively represent the weight matrices corresponding to the Query, Key, and Value triplets;
[0046] The information update layer is a fully connected layer that is responsible for fusing the fine-grained features of humidity calculated by the weight output layer and mapping them to the original input data. The same dimension provides temporal feature data for the subsequent spatiotemporal feature fusion module:
[0047] ( ) ;
[0048] In the formula, is with Outputs of the same dimension, ; represents a fully connected layer; It is the final output of the time-dependent feature extraction module, which contains fine-grained long-term dependency features.
[0049] Step S3 includes: the graph attention network in the module is based on the meteorological humidity dataset ={ , }, And the adjacency matrix of humidity sensor collection points Input, calculate the attention coefficient Then, the connectivity relationship is determined based on the adjacency matrix. and its first-order neighbor humidity sensor collection point When there is no spatial influence relationship, the corresponding attention coefficient Set to 0, each element in the attention matrix is calculated as follows: ;
[0050] In the formula, Indicates the humidity sensor collection point Relative to the collection point The attention coefficient; is the adjacency matrix representing the connectivity;
[0051] Get the attention coefficient Then, based on the multi-head attention mechanism, the current central humidity sensor collection point The weighted summation operation of the neighborhood collection points is the collection point Update status:
[0052] = ;
[0053] In the formula, Indicates the humidity sensor collection point Time series data of Indicates the central humidity sensor collection point Update status of is the number of multi-head attention heads; Represents vector concatenation; Indicates The weight matrix corresponding to the head attention;
[0054] Considering the input number The humidity sensor collection point features contain multiple attribute channels. Referring to the multi-head attention mechanism, the improved graph attention network is used to extract spatial features from each channel of the time series data and then spliced. The specific propagation process is as follows:
[0055] = , ;
[0056] In the formula, represents the spatial feature matrix between the humidity sensor collection points extracted in the spatial dependency feature extraction module; express GAT The number of channels to be calculated; Indicates the central collection point In the channel Update status on ; Represents vector concatenation.
[0057] Step S5 includes:
[0058] Improvements based on the standard gating mechanism propagation method:
[0059] ;
[0060] In the formula, g(x) represents the gated output, is the activation function, For input data; is the bias term, W is the weight matrix;
[0061] The training propagation method of the improved spatiotemporal feature fusion module is:
[0062] ;
[0063] ;
[0064] ;
[0065] In the formula, , are the weight matrices of the temporal gating component and the spatial gating component respectively; It is the output of the time-dependent feature extraction module and the space-dependent feature extraction module; and is the corresponding generated gating component; yes , yes , used to map information to [0,1]; It is the output of the spatiotemporal feature fusion module.
[0066] Step S6 includes:
[0067] The comprehensive prediction model is used as a hidden layer, and the input layer and output layer are added;
[0068] Among them, the input layer is mainly responsible for increasing the dimension of the data in the original meteorological humidity dataset. The data input layer is a convolutional layer, which maps the input data of the meteorological humidity dataset to a higher dimensional space and provides finer-grained features;
[0069] In the comprehensive prediction model of the hidden layer, the internal data of the processed meteorological humidity dataset is used to extract the spatiotemporal information of meteorological humidity through the spatial dependent feature extraction module and the time dependent feature extraction module. O T , O S After the spatiotemporal features are aggregated by the spatiotemporal feature fusion module, the gated output is obtained. O G ;
[0070] The output layer is a convolutional layer, which is responsible for integrating the spatiotemporal feature fusion module results. O G Convert to t Weather humidity forecast results at time +1 Y t+1 , that is, input data X The next moment t +1 for the weather and humidity forecast data;
[0071] According to the prediction output Y t+1 And the corresponding time meteorological humidity data x t+1 Calculate the loss function, update all trainable parameter matrices through back propagation, and re-predict until the loss converges or the early stopping condition is met, and then obtain the final prediction sequence through denormalization Y . .
[0072] The present invention not only solves the problem that traditional time series prediction methods ignore the spatial correlation of data and have long-term dependence phenomena that lead to poor generalization and data prediction effects, but also proposes solutions and methods for how to fuse spatiotemporal data and reduce data loss. It has the advantages of comprehensive consideration and high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 is the initial adjacency matrix graph of the graph attention network belonging to graph G;
[0074] Figure 2 This is a framework diagram of the time-dependent feature extraction module based on self-attention;
[0075] Figure 3 Mapping diagram for the temporal attention mechanism;
[0076] Figure 4 is the empty dependency graph between data;
[0077] Figure 5 Schematic diagram of the embedded multi-head graph attention network;
[0078] Figure 6 It is a schematic diagram of the spatiotemporal feature fusion module;
[0079] Figure 7 It is a logical schematic diagram of the present invention;
[0080] Figure 8 It is a schematic diagram of the comprehensive prediction model;
[0081] Fig. 9 For the initial training picture;
[0082] Fig.10 To end the training picture. Implementation
[0083] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments to facilitate a clear understanding of the present invention, but they do not constitute a limitation on the present invention.
[0084] This embodiment includes the following steps:
[0085] 1) Data processing:
[0086] (1) Missing smoothing
[0087] Actual meteorological humidity data may be missing due to sensor anomalies, which may affect the prediction results. For short-term missing data, the average value is taken, and the time series data of three days before and after the data missing point is averaged and smoothed to reduce data errors.
[0088] (2) Ultra-high value processing
[0089] Humidity sensor distortion often occurs in the actual production process, which may result in extremely high values. The unconventional extremely high values caused by sensor distortion are processed, and the data of the five days before and after the extremely high value point are removed to reduce the extremely high value noise caused by distortion.
[0090] (3) Normalization
[0091] Since the improved model is trained based on the gradient descent method, in order to speed up the convergence of the model, the data in the dimensional meteorological humidity data set is normalized into dimensionless scalar time series data. The specific method is as follows:
[0092] ;
[0093] In the formula, It is the real meteorological humidity data; , They correspond to the maximum and minimum values of the time series data respectively; is the normalized time series data.
[0094] 2) Initialize the graph structure:
[0095] Given N humidity sensor collection points, each humidity sensor collection point contains F A directed graph G with attributes (i.e., air humidity data, temperature data, wind direction data, wind speed data):
[0096] ;
[0097] In the formula, the humidity sensor collection point structure is defined as ;in V It is the collection point of humidity sensor; E Whether there is a spatial influence relationship between the collection points; A is an adjacency matrix based on spatial relationship representation;
[0098] The time series data of graph G of the meteorological humidity dataset is represented as , , For historical data length, is the number of attribute channels, They are used as inputs of the time-dependent feature extraction module and the space-dependent feature extraction module respectively;
[0099] The initial adjacency matrix of the graph attention network of the graph G is constructed as follows:
[0100] ;
[0101] In the formula, Indicates the spatial correlation of the collection points and represents the adjacency matrix; Indicates (humidity sensor) collection point i and j ;
[0102] According to the above construction process, for Figure 1 The adjacency matrix of the meteorological humidity data input graph shown below is represented as:
[0103] .
[0104] 3) Time-dependent feature extraction module:
[0105] In order to avoid the long-term dependence phenomenon, the present invention uses the self-attention mechanism to calculate the time features. The time feature extraction speed based on the self-attention mechanism is faster than that of the recurrent neural network model.
[0106] like Figure 2 As shown in the figure, considering that the long-range correlation of time series data is difficult to characterize, the time embedding layer maps the data in the meteorological humidity dataset to a high-dimensional space, transforms the time series data features into fine-grained features for the weight calculation layer to extract time features. The time embedding layer processing calculation method is:
[0107] = ;
[0108] In the formula, is the high-dimensional fine-grained feature obtained by embedding, and is used as ( Q, K, V ) is the input item of triple feature.
[0109] Considering the long-term dependency problem and the non-stationary problem of time series data, the core of the weight output layer adopts the Dot-Product Attention self-attention mechanism, which mainly describes the correlation between different data points in the data in a fine-grained manner. Since the calculation of any attention coefficient is only related to itself and has nothing to do with the distance, it can effectively reduce the long-term dependency problem. The calculation method is as follows:
[0110] ;
[0111] ;
[0112] ;
[0113] ;
[0114] ;
[0115] ;
[0116] In the formula, , , They correspond to the Query, Key, and Value triples respectively; Represents the Key matrix The transpose of is the temporal attention map; Represents the output of the weight calculation layer; d k express Model; Respectively represent the weight matrices corresponding to the Query, Key, and Value triplets.
[0117] The attention mechanism mapping diagram of the time-dependent feature extraction module based on Dot-Product Attention is as follows Figure 3 Show:
[0118] The information update layer is a fully connected layer that is responsible for fusing the fine-grained features calculated by the weight output layer and mapping them to the original input data. The same dimension provides temporal feature data for the subsequent spatiotemporal feature fusion module:
[0119] ( ) ;
[0120] In the formula, is with Outputs of the same dimensions, ; represents a fully connected layer; It is the final output of the time-dependent feature extraction module, which contains fine-grained long-term dependency features.
[0121] 4) Spatial dependency feature extraction module:
[0122] The spectral domain graph convolution network is used to extract the spatial characteristics of the undirected graph structure representation. It cannot process the meteorological humidity directed graph. The graph attention network uses different graph convolution kernels to participate in the calculation for different central humidity sensor collection points, and more fine-grainedly characterizes the spatial dependency relationship between data, such as Figure 4 shown.
[0123] Graph Attention Network ={ , }, and the adjacency matrix Input, for humidity sensor collection point i and neighboring humidity sensor collection points j The method of attention correlation coefficient is:
[0124] ;
[0125] In the formula, Indicates the influence of the humidity sensor collection point on the humidity sensor collection point; Represents vector concatenation; is the graph attention mapping matrix; It is actually a one-way feedforward neural network; it contains the weight vector ∈ ,use When activated, the attention coefficient can be expressed as:
[0126] ;
[0127] Calculate the attention coefficient Then, the connectivity relationship is determined based on the adjacency matrix. and its first-order neighbor humidity sensor collection point When there is no connectivity, the corresponding attention coefficient Set to 0, each element in the attention matrix is calculated as follows:
[0128] ;
[0129] In the formula, Indicates the humidity sensor collection point Relative to the humidity sensor collection point The attention coefficient; is the adjacency matrix representing the connectivity;
[0130] Based on the multi-head attention mechanism, the current central humidity sensor collection point The weighted summation operation of the neighborhood collection points is used to obtain the collection points Update status:
[0131] = ;
[0132] In the formula, Indicates the humidity sensor collection point Time series data of Indicates the central humidity sensor collection point Update status of is the number of multi-head attention heads; Represents vector concatenation; Indicates The weight matrix corresponding to the head attention;
[0133] Considering the input number The humidity sensor collection point features contain multiple channels. Referring to the multi-head attention mechanism, the improved graph attention network is used to extract the spatial features of each channel of the time series data and then spliced. The specific propagation process is as follows:
[0134] = , ;
[0135] In the formula, Represents the spatial features between the humidity sensor collection points extracted in the spatial dependency feature extraction module; express GAT The number of channels to be calculated; Indicates the central collection point In the channel Update status on ; Represents vector concatenation;
[0136] Taking collection point 3 as the central collection point, collection points 1, 2, and 4 as first-order neighbor nodes, the self-attention mechanism calculated by the graph attention network according to the above formula is as follows: Figure 5 As shown, the three-color graph structure represents the number of channels when the GAT module performs calculations, that is, =3, the dotted arrows between nodes indicate the influence between nodes, i.e. =2.
[0137] The graph attention network built based on connectivity relationship sets up independent parameter matrices for the neighborhood humidity sensor collection points of different central humidity sensor collection points, and calculates the attention coefficients pairwise to characterize the correlation between humidity sensor collection points. Each channel feature of the data is calculated independently, and the spatial correlation between nodes is finely granularly characterized, so that the flow law of gas and fluid can be effectively characterized and the prediction accuracy of the model can be improved.
[0138] 5) Spatiotemporal feature fusion module:
[0139] Standard gating mechanism propagation method:
[0140] ;
[0141] In the formula, g(x) represents the gated output, is the activation function, For input data; is the bias term, is the weight matrix.
[0142] The structure of time series data is complex. For the same data, the spatial influence of other data on it and its own time series autocorrelation have different effects on the final prediction results. For example, some meteorological humidity data collection points have closed terrain and are rarely affected by other meteorological humidity data collection points. At this time, time series autocorrelation is the main factor affecting the prediction accuracy, and time-dependent characteristics need to be considered; for some meteorological humidity data collection points, due to open terrain, they are easily affected by moisture dissipation from other nodes. At this time, spatial dependence characteristics are the main factor. Therefore, it is necessary to distinguish between time and space features, and assign different weights to time and space features to carry out time and space feature fusion.
[0143] To address the above problems, a new spatiotemporal feature fusion module is designed based on the gating mechanism. Two gating components are constructed to learn the importance of spatiotemporal features of meteorological humidity data for prediction, and adaptively allocate fusion weights based on the importance. Figure 6 shown.
[0144] The green part in the figure is the spatiotemporal feature fusion module, the new gating component G T , G S Through the weight matrix Dynamically learning temporal features O T and spatial characteristics O S The output of the gating component is between [0,1], which is used to indicate the integration degree of the temporal and spatial dependent feature extraction module of the meteorological humidity data. The training propagation method of the spatiotemporal feature fusion module is improved based on the standard gating mechanism propagation method:
[0145] ;
[0146] ;
[0147] ;
[0148] In the formula, , are the weight matrices of the temporal gating component and the spatial gating component respectively; It is the output of the time-dependent feature extraction module and the space-dependent feature extraction module; and is the corresponding generated gating component; yes , yes , used to map information to [0,1]; It is the output of the spatiotemporal feature fusion module.
[0149] 6) Combine and train comprehensive prediction models
[0150] The comprehensive prediction model designed by the present invention is used as a hidden layer, and an input layer and an output layer are added. Assuming that The humidity sensor collection point is Group data, only consider the air humidity data, that is, the corresponding attribute number is 1, the air humidity data history data length When it is 10, the prediction framework is performed using the present invention. Figure 7 shown.
[0151] Among them, the input layer is mainly responsible for the original air humidity data To increase the dimension, the data input layer is a Convolution maps the input data to a higher-dimensional space, providing more fine-grained temporal and spatial correlation features of air humidity .
[0152] The hidden layer unit is a comprehensive prediction model proposed by the present invention. The internal data of the comprehensive prediction model is extracted through the space and time dependent feature extraction module to extract the spatiotemporal information of air humidity. , After the spatiotemporal features are aggregated by the spatiotemporal feature fusion module, the output , units such as Figure 8 shown.
[0153] The output layer is Convolutional layer, responsible for integrating the meteorological humidity results of the gated fusion block Convert to Prediction results at the moment , that is, input data The next moment Meteorological humidity forecast data.
[0154] The training module is responsible for grasping the optimization direction: output according to the predicted meteorological humidity And the corresponding meteorological humidity data Calculate the loss function, update all trainable parameter matrices through back propagation, and re-predict until the loss converges or the early stopping condition is met, and obtain the final prediction sequence after denormalization .
[0155] Taking three data groups in the meteorological humidity data set as implementation objects, experiments were carried out using the method proposed by the present invention for each node group, and the data codes were TK648, TK744, TK664, T606, and TK649 respectively.
[0156] Implementation environment:
[0157] Taking the meteorological humidity dataset as the implementation object, the computational model proposed in this invention is used to conduct experiments, analyze the attention mapping matrix of GAT in the spatial dependency feature extraction module and the degree of change of the gated component weight matrix of the gated fusion block in different training periods, and compare the performance of the new model with traditional models such as LSTM, GRU, GCN, GAT, STTNS, etc. The above LSTM, GRU, GCN, GAT, STTNS are all commonly used prediction models in this field.
[0158] All examples are based on the Pytorch open source deep learning framework. The specific environment is shown in the table below:
[0159] Environment configuration table:
[0160] The mean absolute error (MAE) and the symmetric mean absolute percentage error (MAPE) are selected as the error indicators for evaluating the model performance, and the root mean square error (RMSE) is used as the loss function for model training. During training, the back propagation operation is performed based on the RMSE value calculated for each batch. The metric definitions are as follows:
[0161] ;
[0162] ;
[0163] ;
[0164] In the formula, is the total number of samples; is the predicted value of the model proposed by the study; is the true value of the node group corresponding to the S80 unit, where RMSE measures the degree of deviation between the predicted value and the true value of the production indicator in the sample. The smaller the RMSE value, the closer the predicted result is to the true value, and the better the model effect.
[0165] The embodiment is mainly divided into 2 parts:
[0166] 1) Matrix analysis: The GAT network in the spatial dependency feature extraction module calculates the attention coefficient through the attention mapping matrix. To prove the effectiveness of the two, the weight changes of the GAT attention weight matrix in the early and late stages of training are analyzed.
[0167] In order to characterize the effect of the spatial dependent feature extraction module GAT network on the fluid motion law, the study takes TK634 as an example to analyze the attention mapping matrix inside GAT And GAT network attention map for analysis. The dimension is high and it is difficult to measure the changing trend of the feature vector. The frequency histogram is used to describe the change of the weight matrix during training, where the horizontal axis is the attention mapping matrix weight matrix , the ordinate is the frequency of the weight matrix values.
[0168] Fig. 9 and Fig.10 The initial and final training Frequency distribution histogram. Compare Fig. 9 , Fig.10 Finding the temporal gating weight matrix In the early stage, some weight values are approximately normally distributed; the maximum parameter value in the middle is close to 2500, including a small number of extremely high parameter items; in the later stage, the weight coefficient parameters are evenly distributed between -0.2 and 0.15, and the distribution number is mostly between 400 and 600, without extremely high parameter items. The weight coefficients were changed during the training process, and the influence of abnormally high values was eliminated by learning the data characteristics.
[0169] From the overall trend of the graph, Fig.10 The weight parameters are distributed in the parameter space of [-0.2, 0.15], relative to Fig. 9 , Fig.10 The distribution in the overall parameter space is more balanced, indicating During the training process, the parameters can be evenly distributed to the entire parameter space, the hidden features of the entire parameter space can be mined, and the feature extraction capability can be improved.
[0170] 2) Comparative experiment: The model of the present invention is compared with the traditional recurrent neural network model (LSTM, GRU) and the traditional graph convolution model (GCN, GAT, STTNS). The same data set is trained and predicted under the same software and hardware conditions, and the performance of different networks under various prediction indicators is compared.
[0171] The results of the embodiment are as follows:
[0172] The comprehensive model (Spatial-Temporal Graph Attention Gate Networks) proposed in this invention is abbreviated as STGAN, and the results are shown in the following table: The STGAN part represents the optimal effect of all models after adding the STGAN model.
[0173]
[0174]
[0175] Taking TK606 as an example, the predicted value of the collection point is compared with the true value. The LSTM and GRU models have a better fit for the mutation point, but because the spatial factor is not considered, there are more misjudgments in the smooth rising or falling segments, and the overall accuracy is weaker than other models; the STGAN model proposed in the present invention has the best effect. Compared with STTNS, the overall trend is closer to the true value and the prediction accuracy is higher.
[0176] The results show that the prediction results of the model proposed by the present invention are relatively better than those of the traditional model.
[0177] The contents not described in detail in this specification belong to the prior art known to professional and technical personnel in this field.
Claims
1. A method for predicting time series data with associated spatiotemporal relationships, characterized in that: The following steps are involved: S1: Construct the required meteorological humidity dataset, and perform missing smoothing, extremely high value processing, and normalization processing on the data in the meteorological humidity dataset; S2: Establish an adjacency matrix based on whether there is spatial correlation between the data collection points in the meteorological humidity dataset; S3: Use the adjacency matrix to build a spatial dependency feature extraction module based on the graph attention network to extract the spatial dependency features between the data collection points in the meteorological humidity dataset; S4: Use the adjacency matrix to build a time-dependent feature extraction module based on the self-attention mechanism to extract the time-dependent features of the data at each time point in the meteorological humidity dataset; S5: Construct a spatiotemporal feature fusion module using a gating mechanism to fuse the output features of the spatial-dependent feature extraction module and the temporal-dependent feature extraction module; S6: Combine the above multiple modules to generate and train a comprehensive prediction model; S7: input the meteorological humidity data set into the trained comprehensive prediction model and calculate the meteorological humidity prediction result; Step S1 specifically includes: 1) Missing smoothing: The average value is taken for the short-term missing data in the meteorological humidity data set, and the time series data of three days before and after the data missing point is averaged and smoothed; 2) Ultra-high value processing: The abnormal high values caused by sensor distortion are processed, and the data of the five days before and after the abnormal high value point are eliminated; 3) Normalization processing: The data in the dimensional meteorological humidity data set is normalized into dimensionless scalar time series data. The specific method is as follows: Where, X is the real meteorological humidity data; X max , X min Corresponding to the maximum and minimum values of the time series data respectively; X norm is the normalized time series data; Step S2 includes: defining a directed graph structure to describe the spatial relationship of spatial collection points, N collection points, each collection point has F attributes, and the directed graph G of the meteorological humidity data set can be expressed as: G = (V, E, A); In the formula, the humidity sensor collection point structure is defined as G = (V, E); V is the humidity sensor collection point; E is whether there is a spatial influence relationship between the collection points; A is the adjacency matrix based on spatial relationship representation; The time series data of the graph G of the meteorological humidity dataset is represented by X T , X S , X T =X S ∈R N×T×F , T is the length of historical data, F is the number of attribute channels, X T , X S They are used as inputs of the time-dependent feature extraction module and the space-dependent feature extraction module respectively; The initial adjacency matrix of the graph attention network of the graph G is constructed as follows: In the formula, Adj represents the spatial correlation of the collection points and represents the adjacency matrix; i, j represent the collection points i and j; Step S3 includes: The graph attention network in the module is based on the meteorological humidity dataset And the humidity sensor collection point adjacency matrix Adj input, calculate the attention coefficient a ij After that, the connectivity relationship is determined based on the adjacency matrix. When the central humidity sensor collection point i and its first-order neighbor humidity sensor collection point have no spatial influence relationship, the corresponding attention coefficient a is ij Set to 0, each element in the attention matrix is calculated as follows: In the formula, a ij represents the attention coefficient of humidity sensor collection point i relative to collection point j; Adj is the adjacency matrix characterized by connectivity; Get the attention coefficient a ij Then, based on the multi-head attention mechanism, the weighted sum operation of the neighborhood collection points of the current central humidity sensor collection point i is performed to obtain the updated state of the collection point i: In the formula, Represents the time series data of the humidity sensor collection point j; represents the update status of the central humidity sensor collection point i; K is the number of multi-head attention heads; ||(·) represents vector splicing; W k Represents the weight matrix corresponding to the k-th attention head; Considering the input number The humidity sensor collection point features contain multiple attribute channels. Referring to the multi-head attention mechanism, the improved graph attention network is used to extract spatial features from each channel of the time series data and then spliced. The specific propagation process is as follows: In the formula, O GAT represents the spatial feature matrix between the humidity sensor collection points extracted in the spatial dependency feature extraction module; C represents the number of channels when GAT is calculated; represents the update status of the central acquisition point i on channel C; ||(·) represents vector splicing; Step S4 includes: organizing the data in the meteorological humidity data set into a time series data sequence in chronological order and inputting it into the time embedding layer. The time embedding layer maps the attribute data in the time series sequence to a high-dimensional space and transforms the time series data features into fine-grained features for the weight calculation layer to extract time features. The time embedding layer processing calculation method is: H T =Embedding(X T ); In the formula, H T It is the high-dimensional fine-grained feature obtained by embedding and serves as the input item of the (Q, K, V) triple feature; The processing calculation method of the weight output layer is: A T =R T V T ; A T ∈R N×T×C ; In the formula, Q T , K T 、V T Corresponding to Query, Key, Value triples respectively; K T T Denotes the Key matrix K T The transpose of R T is the temporal attention map; A T Represents the output of the weight calculation layer; d k K T Model; Respectively represent the weight matrices corresponding to the Query, Key, and Value triplets; The information update layer is a fully connected layer that is responsible for fusing the humidity fine-grained features calculated by the weight output layer and mapping them to the original input data X T The same dimension provides temporal feature data for the subsequent spatiotemporal feature fusion module: O T =F(A T ); In the formula, O T Is with X T Output of the same dimension, O T ∈R N×T×F ; F(·) represents the fully connected layer; O T It is the final output of the time-dependent feature extraction module, which contains fine-grained long-term dependency features; Step S5 includes: Improvements based on the standard gating mechanism propagation method: g(x)=σ(Wx+b); In the formula, represents the gated output, σ is the activation function, x is the input data; b is the bias term, and W is the weight matrix; The training propagation method of the improved spatiotemporal feature fusion module is: O G =G T *O T +G S *O S ; In the formula, are the weight matrices of the temporal gating component and the spatial gating component respectively; O T , O S is the output of the time-dependent feature extraction module and the space-dependent feature extraction module; G T and G S is the corresponding generated gating component; δ(·) is Layernormal, σ(·) is Sigmod, which is used to map information to [0, 1], O G is the output of the spatiotemporal feature fusion module; Step S6 includes: The comprehensive prediction model is used as a hidden layer, and the input layer and output layer are added; Among them, the input layer is mainly responsible for increasing the dimension of the data in the original meteorological humidity dataset. The data input layer is a convolutional layer, which maps the input data of the meteorological humidity dataset to a higher dimensional space and provides finer-grained features; In the comprehensive prediction model of the hidden layer, the internal data of the processed meteorological humidity dataset is used to extract the spatiotemporal information of meteorological humidity through the spatial dependent feature extraction module and the time dependent feature extraction module. T , O S After the spatiotemporal features are aggregated by the spatiotemporal feature fusion module, the gated output O is obtained. G ; The output layer is a convolutional layer, which is responsible for integrating the spatiotemporal feature fusion module results O G Converted to the meteorological humidity forecast result yt at time t+1 +1 , that is, the meteorological humidity forecast data at the next time t+1 of the input data X; According to the prediction output y t+1 And the corresponding time meteorological humidity data x t+1 Calculate the loss function, update all trainable parameter matrices through back propagation, and re-predict until the loss converges or the early stopping condition is met, and then obtain the final prediction sequence Y after denormalization.
