Air quality prediction method and system based on multi-granularity contrast learning
Through the multi-granularity contrastive learning method, combined with geographical and semantic hypergraphs, air quality monitoring data is processed, which solves the problems of noise interference and uneven data distribution, improves the accuracy and robustness of air quality prediction, and achieves a more comprehensive spatiotemporal feature representation.
Patent Information
- Application Number
- CN202410662597.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-27
AI Technical Summary
Existing air quality prediction methods have problems with noise interference and uneven data distribution when processing multi-granularity spatio-temporal data, resulting in inaccurate prediction results and the inability to fully understand complex spatio-temporal dependencies.
Using a method based on multi-granularity comparative learning, a multi-granularity comparative learning model is constructed by acquiring air quality monitoring data and time feature data, using geographical hypergraphs and semantic hypergraphs to capture spatial features, combined with external attention time feature extraction modules and adaptive The fusion module performs contrastive learning within and between granularities, and builds an air quality prediction model based on multi-granularity comparative learning.
Reduce the impact of noise, improve the accuracy and robustness of air quality prediction, be able to better handle the uneven distribution of spatiotemporal data, enhance the adaptability and generalization capabilities of the model, and provide a more comprehensive spatiotemporal feature representation.
Smart Images

Figure CN118535920A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of air quality prediction, and in particular to an air quality prediction method based on multi-granularity contrast learning. Background Art
[0002] In various practical application fields such as traffic management and environmental monitoring, spatiotemporal data plays a key role in revealing the evolution trend of data. Accurate prediction has become the cornerstone for making wise decisions and implementing effective strategies in various fields. The core task of air quality prediction is to effectively learn the dependencies between time and space. With the development of deep learning technology, existing research has captured temporal dependencies through recurrent neural networks (RNNs), temporal convolutional networks (TCNs), and self-attention mechanisms, while using convolutional neural networks (CNNs) and graph neural networks (GNNs) to parse spatial relationships.
[0003] Although these methods have achieved certain results, they still have limitations. First, learning reliable spatiotemporal representations is a complex and challenging task, especially when dealing with multi-granular spatiotemporal data. The quality of spatiotemporal data is often affected by the accuracy and stability of sensors, resulting in noise in the data, which may come from sensor errors, environmental interference, or inaccurate data processing. In addition, traditional air quality prediction methods usually focus on a single temporal granularity, ignoring the complementarity and intrinsic connections between data of different granularities, limiting the comprehensive understanding of complex spatiotemporal dependencies. However, by adopting multi-granularity air quality prediction methods, data at different spatiotemporal scales can be integrated, providing a more comprehensive perspective to understand and predict spatiotemporal dynamics. Second, the distribution of spatiotemporal data often shows significant unevenness in the real world. For example, data points may be densely clustered in some areas, while relatively sparse in other areas. This uneven distribution pattern poses challenges for data analysis. Traditional data models are often based on the simplified assumption that data is uniformly distributed in space and time, which ignores the complexity of the data, especially the dense data in a specific area and the sparse data in other areas. This imbalance leads to simplified model assumptions, which in turn creates biases in the modeling process and prevents predictions and analyses from accurately reflecting the complexity and diversity of the real world. Summary of the invention
[0004] In view of the fact that existing studies do not consider the diversity of multi-granularity representation patterns and the limitations of existing methods in processing uneven distribution of spatiotemporal data, the present invention proposes an air quality prediction method based on multi-granularity contrastive learning, the method comprising:
[0005] S1: Obtain the air quality monitoring dataset and time characteristic dataset of the air quality monitoring site, preprocess the air quality monitoring dataset and time characteristic dataset and divide them into training set, validation set and test set, and take PM2.5 as the target pollutant;
[0006] S2: Divide the air quality data into different granularities and build an air quality prediction model based on multi-granularity contrast learning;
[0007] S3: Training an air quality prediction model based on multi-granularity contrastive learning;
[0008] S4: Input the test set into the trained air quality prediction model based on multi-granularity contrastive learning to obtain the air quality prediction value.
[0009] Furthermore, a preferred method is proposed, wherein step S1 comprises:
[0010] S11: preprocessing the historical air quality monitoring data of each air quality monitoring station according to the linear interpolation and maximum and minimum normalization methods;
[0011] S12: Divide the preprocessed air quality monitoring data and time characteristic data according to the mean pooling technology, obtain air quality monitoring data with a time interval of 3 hours and a time interval of 6 hours, and use the time interval of 1 hour as the target granularity, and use the time interval of 3 hours and the time interval of 6 hours as auxiliary granularities;
[0012] S13: Divide the acquired data of different granularities into a training set, a validation set, and a test set.
[0013] Furthermore, a preferred method is proposed, wherein step S2 comprises:
[0014] S21: constructing a geographic hypergraph and a semantic hypergraph according to the location information and attribute information of the nodes respectively; wherein the nodes are air quality monitoring sites;
[0015] S22: Fusion constructs geographic hypergraph and semantic hypergraph, and inputs the training set data into the dual hypergraph convolutional spatial feature extraction module to obtain the spatial feature representation of the nodes;
[0016] S23: Input the training set data into the external attention time feature extraction module to obtain the time feature representation of the node;
[0017] S24: inputting the spatial feature representation and the temporal feature representation of the node into the adaptive fusion module to obtain the spatiotemporal feature representation of all nodes at each granularity;
[0018] S25: Use the intra-granular contrast learning module to process the spatiotemporal feature representation at the target granularity and capture the correlation between nodes at the target granularity;
[0019] S26: Use the inter-granularity contrast learning module to process the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity to capture the correlation between different granularities of the same node;
[0020] S27: concatenate node representations of different granularities, and use gating technology to filter the concatenated fusion representation;
[0021] S28: Air quality prediction model based on multi-granularity contrastive learning based on two-layer fully connected neural network and filtered fusion representation combination.
[0022] Furthermore, a preferred method is proposed, wherein step S23 comprises:
[0023] The temporal dependency learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes.
[0024]
[0025] Among them, M b,v is a learnable parameter, A b It is the input data and the external memory matrix unit M b,k Attention between:
[0026]
[0027] Among them, M b,k It is a memory associated with the dataset. Norm indicates that double normalization is used to normalize rows and columns separately.
[0028] Furthermore, a preferred method is proposed, wherein step S24 comprises:
[0029]
[0030] Among them, W1 and W2 are learnable parameters, ⊙ represents the element-wise product, and H b It is an adaptive fusion module.
[0031] Furthermore, a preferred method is proposed, wherein step S27 comprises:
[0032] Splicing the spatiotemporal representations at different granularities Concat :
[0033] H Concat =|| b∈B H b
[0034] The concatenated representation is then filtered by the gating unit H fusion :
[0035] H fusion =σ1(H Concat )⊙σ2(H Concat )
[0036] Among them, σ1 is the hyperbolic tangent activation function, σ2 is the sigmoid activation function, and ⊙ represents the element-wise product.
[0037] Furthermore, a preferred method is proposed, wherein step S3 comprises:
[0038] S31: inputting the data in the training set into the air quality prediction model based on multi-granularity contrast learning to obtain the prediction value at the target granularity;
[0039] S32: Calculate the prediction loss using the mean absolute error according to the actual value and the predicted value of the target granularity;
[0040] S33: The prediction loss, intra-granular contrast loss, and inter-granular contrast loss are weighted to construct an overall loss function and minimize it to train the model.
[0041] Based on the same inventive concept, the present invention also proposes an air quality prediction system based on multi-granularity contrast learning, the system comprising:
[0042] A data acquisition unit, used to acquire an air quality monitoring data set and a time characteristic data set of an air quality monitoring site, preprocess the air quality monitoring data set and the time characteristic data set and divide them into a training set, a validation set and a test set, and use PM2.5 as a target pollutant;
[0043] An air quality prediction model building unit, used to divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative learning;
[0044] A training unit, used to train an air quality prediction model based on multi-granularity contrast learning;
[0045] The prediction unit is used to input the test set into the trained air quality prediction model based on multi-granularity contrastive learning to obtain the air quality prediction value.
[0046] Based on the same inventive concept, the present invention also proposes a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the air quality prediction method based on multi-granularity contrast learning as described in any one of the above items.
[0047] Based on the same inventive concept, the present invention also proposes a computer-readable storage medium, which is used to store a computer program, and the computer program executes any of the above-mentioned air quality prediction methods based on multi-granularity contrast learning.
[0048] The present invention is beneficial in that:
[0049] Traditional air quality prediction methods are affected by noise, resulting in inaccurate prediction results. The air quality prediction method based on multi-granularity contrast learning proposed in the present invention can reduce the influence of noise to a certain extent by using the multi-granularity contrast learning method, because it extracts useful patterns by comparing information of different granularities, thereby better predicting air quality.
[0050] Air quality data in reality usually has an uneven distribution in time and space, and traditional methods cannot handle this data feature well. The method proposed in the present invention adopts a multi-granularity contrast learning method to better utilize information of different granularities, thereby more effectively handling the uneven distribution of spatiotemporal data and improving the accuracy of air quality prediction. By utilizing the multi-granularity contrast learning method, the relationship between air quality monitoring data and time feature data can be more fully utilized, thereby improving the accuracy and reliability of air quality prediction. The multi-granularity contrast learning method can reduce the impact of noise to a certain extent and better adapt to the uneven distribution of spatiotemporal data, thereby enhancing the robustness of the model and enabling it to perform well in different situations. By dividing air quality data of different granularities and constructing a prediction model based on multi-granularity contrast learning, the information in the data can be better utilized, and richer features can be extracted, thereby improving the prediction effect.
[0051] The present invention overcomes the problem that it is difficult to obtain reliable spatiotemporal representation under multiple granularities, and uses contrastive learning to achieve contrast within and between granularities, thereby obtaining richer spatiotemporal representation.
[0052] The present invention also overcomes the problem of uneven distribution of air quality data, and uses semantic hypergraphs and geographic hypergraphs to capture high-order spatial dependencies between nodes, thereby alleviating the problem of uneven data distribution.
[0053] The invention is applied to the field of environmental monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a flow chart of the air quality prediction method based on multi-granularity contrast learning described in Implementation Method 1;
[0055] Figure 2 Schematic diagram of the air quality prediction model based on multi-granularity contrast learning described in Implementation Method 3;
[0056] Figure 3 Schematic diagram of a dual hypergraph convolutional spatial feature extraction module according to Implementation Example 11;
[0057] Figure 4 This is a schematic diagram of the external attention time feature extraction module described in Implementation Example 11. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0059] Implementation method 1, see Figure 1 The air quality prediction method based on multi-granularity contrast learning described in this embodiment includes:
[0060] S1: Obtain the air quality monitoring dataset and time characteristic dataset of the air quality monitoring site, preprocess the air quality monitoring dataset and time characteristic dataset and divide them into training set, validation set and test set, and take PM2.5 as the target pollutant;
[0061] S2: Divide the air quality data into different granularities and build an air quality prediction model based on multi-granularity contrast learning;
[0062] S3: Training an air quality prediction model based on multi-granularity contrastive learning;
[0063] S4: Input the test set into the trained air quality prediction model based on multi-granularity contrastive learning to obtain the air quality prediction value.
[0064] Traditional air quality prediction methods are affected by noise, resulting in inaccurate prediction results. The method proposed in this embodiment uses a multi-granularity contrast learning method to reduce the impact of noise to a certain extent, because it extracts useful patterns by comparing information of different granularities, thereby better predicting air quality.
[0065] Air quality data in reality usually has uneven distribution in time and space, and traditional methods cannot handle this data feature well. The method of multi-granularity contrast learning adopted in this embodiment can make better use of information of different granularities, thereby more effectively handling the uneven distribution of spatiotemporal data and improving the accuracy of air quality prediction. By utilizing the multi-granularity contrast learning method, the relationship between air quality monitoring data and time feature data can be more fully utilized, thereby improving the accuracy and reliability of air quality prediction. The multi-granularity contrast learning method can reduce the impact of noise to a certain extent and better adapt to the uneven distribution of spatiotemporal data, thereby enhancing the robustness of the model and enabling it to perform well in different situations. By dividing air quality data of different granularities and constructing a prediction model based on multi-granularity contrast learning, the information in the data can be better utilized, and richer features can be extracted, thereby improving the prediction effect.
[0066] Embodiment 2: This embodiment further limits the air quality prediction method based on multi-granularity contrast learning described in Embodiment 1. Step S1 includes:
[0067] S11: preprocessing the historical air quality monitoring data of each air quality monitoring station according to the linear interpolation and maximum and minimum normalization methods;
[0068] S12: Divide the preprocessed air quality monitoring data and time characteristic data according to the mean pooling technology, obtain air quality monitoring data with a time interval of 3 hours and a time interval of 6 hours, and use the time interval of 1 hour as the target granularity, and use the time interval of 3 hours and the time interval of 6 hours as auxiliary granularities;
[0069] S13: Divide the acquired data of different granularities into a training set, a validation set, and a test set.
[0070] This implementation method uses linear interpolation and maximum and minimum normalization methods to pre-process the historical data of each air quality monitoring site, which can more effectively handle missing values and outliers in the data and improve the quality and availability of the data. By using mean pooling technology to divide the data into different granularities, including time intervals of 1 hour, 3 hours and 6 hours, it is possible to more comprehensively consider the impact of different time granularities on air quality, and improve the applicability and generalization ability of the model. Using 1 hour as the target granularity and 3 hours and 6 hours as auxiliary granularities, it is possible to use the information of auxiliary granularities to improve the stability and robustness of the model while retaining high precision, making the model more suitable for different scenarios and data distributions. Dividing data sets of different granularities into training sets, validation sets and test sets can better evaluate the performance of the model, and provide a more comprehensive data foundation, which is conducive to the training and optimization of the model.
[0071] Implementation method three, see Figure 2 This embodiment further defines the air quality prediction method based on multi-granularity contrast learning described in the second embodiment, and the step S2 includes:
[0072] S21: constructing a geographic hypergraph and a semantic hypergraph according to the location information and attribute information of the nodes respectively; wherein the nodes are air quality monitoring sites;
[0073] S22: Fusion constructs geographic hypergraph and semantic hypergraph, and inputs the training set data into the dual hypergraph convolutional spatial feature extraction module to obtain the spatial feature representation of the nodes;
[0074] S23: Input the training set data into the external attention time feature extraction module to obtain the time feature representation of the node;
[0075] S24: inputting the spatial feature representation and the temporal feature representation of the node into the adaptive fusion module to obtain the spatiotemporal feature representation of all nodes at each granularity;
[0076] S25: Use the intra-granular contrast learning module to process the spatiotemporal feature representation at the target granularity and capture the correlation between nodes at the target granularity;
[0077] S26: Use the inter-granularity contrast learning module to process the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity to capture the correlation between different granularities of the same node;
[0078] S27: concatenate node representations of different granularities, and use gating technology to filter the concatenated fusion representation;
[0079] S28: Air quality prediction model based on multi-granularity contrastive learning based on two-layer fully connected neural network and filtered fusion representation combination.
[0080] Traditional methods cannot capture the complex spatial characteristics of air quality monitoring sites well, which leads to inaccurate prediction results. In this implementation, by constructing a geographic hypergraph and a semantic hypergraph and using a dual hypergraph convolutional spatial feature extraction module, the spatial feature representation of the node can be obtained more comprehensively, thereby improving the model's ability to understand and utilize spatial information.
[0081] The comprehensive feature extraction of spatiotemporal data is one of the key issues in air quality prediction. This implementation introduces an external attention temporal feature extraction module and an adaptive fusion module to more effectively extract the temporal feature representation of nodes, and adaptively fuse spatial features and temporal features to obtain a richer and more accurate spatiotemporal feature representation.
[0082] When processing multi-granularity information, the intra-granularity contrast learning module and the inter-granularity contrast learning module are used to capture the correlation between nodes at the target granularity and the correlation between the target granularity and the auxiliary granularity, respectively, thereby better utilizing information at different granularities and improving the model's data utilization efficiency and prediction accuracy.
[0083] By introducing gating technology and a two-layer fully connected neural network, the extracted spatiotemporal features can be flexibly combined and adjusted, further improving the model's adaptability to complex data and prediction accuracy.
[0084] Embodiment 4: This embodiment further limits the air quality prediction method based on multi-granularity contrast learning described in Embodiment 3. Step S23 includes:
[0085] The temporal dependency learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes.
[0086]
[0087] Among them, M b,v is a learnable parameter, A b It is the input data and the external memory matrix unit M b,k Attention between:
[0088]
[0089] Among them, M b,k As a dataset-related memory, it is a learnable parameter that is independent of the input. Norm means that double normalization is used to normalize rows and columns separately.
[0090] In this implementation, the Transformer's attention mechanism is applied to the time-dependent learning module, which can better capture the time dependencies in the air quality data, thereby improving the quality of the time representation and the accuracy of the prediction. The parameters in the external attention mechanism are learnable, which means that the model can adaptively learn the correlation between the data instead of relying on a fixed attention distribution. This makes the model more versatile and adaptable in different data sets and prediction tasks. Using the Transformer-based attention mechanism, the time dependencies can be modeled as sparse attention weights, which can reduce the computational cost of the memory matrix, while reducing storage requirements and improving the efficiency and scalability of the model. As a memory matrix related to the data set, the external memory dynamically adjusts the relationship between the input data and the external memory through the attention mechanism, so that the model can better utilize external information to enhance the time representation of the node, thereby improving the representation ability and prediction performance of the model.
[0091] Embodiment 5: This embodiment further limits the air quality prediction method based on multi-granularity contrast learning described in Embodiment 4. Step S24 includes:
[0092]
[0093] Among them, W1 and W2 are learnable parameters, ⊙ represents the element-wise product, and H b It is an adaptive fusion module.
[0094] Using the adaptive fusion module allows the model to automatically learn the relationship between the spatial and temporal features of nodes and perform effective fusion. This fusion method can make full use of the interaction between different features to better capture the complex patterns and laws in air quality monitoring data.
[0095] Parameters W1 and W2 are learnable, which means that the model can automatically adjust these parameters based on the data to optimally fuse spatial and temporal features. This flexibility enables the model to better adapt to the characteristics of different data sets and tasks, improving the generalization ability of the model. Using element-wise product operations allows the model to consider the importance of both spatial and temporal features and weigh them in the fusion process. This helps the model understand the spatiotemporal characteristics of the data more comprehensively, thereby improving the accuracy of predictions.
[0096] The final spatiotemporal feature representation of all nodes at each granularity contains the fusion of spatial and temporal information, which enables the model to better capture the spatiotemporal relationship between monitoring sites, thereby improving the accuracy of air quality prediction.
[0097] Embodiment 6: This embodiment further limits the air quality prediction method based on multi-granularity contrast learning described in Embodiment 4. Step S27 includes:
[0098] Splicing the spatiotemporal representations at different granularities Concat :
[0099] H Concat =|| b∈B H b
[0100] The concatenated representation is then filtered by the gating unit H fusion :
[0101] H fusion =σ1(H Concat )⊙σ2(H Concat )
[0102] Among them, σ1 is the hyperbolic tangent activation function, σ2 is the sigmoid activation function, and ⊙ represents the element-wise product.
[0103] By splicing the spatiotemporal representations at different granularities, the model can make comprehensive use of the information at each granularity to more comprehensively understand the characteristics of the air quality monitoring site. This synthesis can help the model better capture the intrinsic relationship between the data and improve the accuracy of the prediction. The spliced representation is then filtered through the gating unit, which can selectively emphasize or suppress the importance of the feature. This helps the model to better focus on the features that affect the prediction target during the learning process, improving the performance and generalization ability of the model. Using the hyperbolic tangent and sigmoid activation functions, the features can be normalized and compressed within an appropriate range, so that the value range of the feature is within a suitable interval, which is conducive to optimizing the stability and convergence speed of the algorithm. The element product operation can help the model better combine the information at different granularities, introduce the interactive relationship between the features, and help improve the expression and fitting capabilities of the model.
[0104] Embodiment 7: This embodiment further limits the air quality prediction method based on multi-granularity contrast learning described in Embodiment 1, and step S3 includes:
[0105] S31: inputting the data in the training set into the air quality prediction model based on multi-granularity contrast learning to obtain the prediction value at the target granularity;
[0106] S32: Calculate the prediction loss using the mean absolute error according to the actual value and the predicted value of the target granularity;
[0107] S33: The prediction loss, intra-granular contrast loss, and inter-granular contrast loss are weighted to construct an overall loss function and minimize it to train the model.
[0108] In this embodiment, the overall loss function is constructed by weighting the prediction loss, intra-granularity contrast loss, and inter-granularity contrast loss. This method comprehensively considers losses in multiple aspects, so that the model can better learn the associations and rules between data during training, thereby improving the generalization ability and prediction accuracy of the model.
[0109] The multi-granularity contrastive learning method not only considers the loss between the predicted value and the true value, but also considers the contrast loss within and between granularities. This contrastive learning method can help the model better understand the intrinsic relationship between data and improve the robustness and interpretability of the model.
[0110] Taking the contrast loss of different granularities into account makes the model pay more attention to the data features at different scales, thereby improving the model's adaptability and robustness to data at various scales. This helps the model achieve good prediction results when facing data of different granularities.
[0111] By weighting different loss terms, the weight of the loss function can be flexibly adjusted according to the characteristics of the task and the nature of the data, so as to better balance the importance of each loss term and optimize the training effect of the model.
[0112] Embodiment 8: The air quality prediction system based on multi-granularity contrast learning described in this embodiment includes:
[0113] A data acquisition unit, used to acquire an air quality monitoring data set and a time characteristic data set of an air quality monitoring site, preprocess the air quality monitoring data set and the time characteristic data set and divide them into a training set, a validation set and a test set, and use PM2.5 as a target pollutant;
[0114] An air quality prediction model building unit, used to divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative learning;
[0115] A training unit, used to train an air quality prediction model based on multi-granularity contrast learning;
[0116] The prediction unit is used to input the test set into the trained air quality prediction model based on multi-granularity contrastive learning to obtain the air quality prediction value.
[0117] Embodiment 9. A computer device described in this embodiment includes a memory and a processor, wherein a computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes the air quality prediction method based on multi-granularity contrast learning as described in any one of embodiments 1 to 7.
[0118] Implementation method ten, a computer-readable storage medium described in this implementation method, wherein the computer-readable storage medium is used to store a computer program, and the computer program executes the air quality prediction method based on multi-granularity contrast learning described in any one of implementation methods one to seven.
[0119] Implementation method 11: See Figure 3 and Figure 4 This embodiment provides a specific example of the air quality prediction method based on multi-granularity contrast learning described in the first embodiment, and is also used to explain the second to seventh embodiments. Specifically:
[0120] Step 1: Obtain the air quality monitoring data set and time characteristic data set of the air quality monitoring site, preprocess the data set and divide it into training set, validation set and test set, and use PM2.5 as the target pollutant;
[0121] The step 1 specifically comprises the following steps:
[0122] Step 1.1: Preprocess the historical monitoring data of each air quality monitoring station using linear interpolation and maximum and minimum normalization methods;
[0123] Step 1.2: Apply the mean pooling technique to divide the original data (1-hour time interval) into air quality monitoring data with 3-hour time interval and 6-hour time interval. The 1-hour time interval is used as the target granularity, and the other two are used as auxiliary granularities (3-hour time interval and 6-hour time interval);
[0124] In step 1.2, the original data is divided into multi-granularity spatiotemporal data using mean pooling technology, represented by a set of granularities {g1, g2, g3} from fine to coarse, where each granularity g b The following time series Indicates, where N represents the number of nodes, T represents the time window length, F represents the feature dimension, and X i,b Indicates particle size in g b The time series of the i-th node;
[0125] Step 1.3: The data of different granularities obtained in step 1.2 are further divided into training set, validation set and test set.
[0126] Step 2: Construct an air quality prediction model based on multi-granularity contrast learning;
[0127] The step 2 specifically comprises the following steps:
[0128] Step 2.1: Use the location information and attribute information of the nodes to construct the geographic hypergraph G D and the semantic hypergraph G S ;
[0129] In step 2.1, in order to construct the semantic hypergraph G S First, we use cosine similarity to calculate the semantic similarity between nodes and arrange them in descending order. For each node, we select the first K nodes with the greatest similarity to form a hyperedge. For all nodes, we construct a hyperedge set ε S , where |ε S | represents the number of hyperedges, and the connection matrix between nodes and hyperedges is defined as
[0130] In order to construct the geographic hypergraph G D , first calculate the geographical distance between nodes, and select nodes within the threshold range to form a hyperedge with them. For all nodes, construct a hyperedge set ε D , where |ε D | represents the number of hyperedges, and the connection matrix between nodes and hyperedges is defined as
[0131] Step 2.2: The geographic hypergraph and semantic hypergraph constructed in step 2.1 are merged, and the training data obtained in step 1.3 are input into the dual hypergraph convolutional spatial feature extraction module to obtain the spatial feature representation of the node; wherein the dual hypergraph convolutional spatial feature extraction module is as follows: Figure 3 shown.
[0132] In step 2.2, the particle size g b The spatial features are expressed as:
[0133]
[0134] Among them, L is the number of hypergraph convolution iterations, and the hypergraph convolution process of each layer is:
[0135]
[0136] Among them, D v and D e are the normalized diagonal matrices based on vertex degree and edge degree, respectively.
[0137] Step 2.3: Input the data obtained in step 1.3 into the external attention time feature extraction module to obtain the time feature representation of the node; wherein the external attention time feature extraction module is as follows: Figure 4 shown.
[0138] By particle size g b For example, the temporal dependency learning module in step 2.3 uses a Transformer-based external attention mechanism to learn the temporal representation of nodes:
[0139]
[0140] Among them, M b,v is a learnable parameter, A b It is the input data and the external memory matrix unit M b,k Attention between:
[0141]
[0142] Among them, M b,k As a dataset-related memory, it is a learnable parameter that is independent of the input. Norm means that double normalization is used to normalize rows and columns separately.
[0143] Step 2.4: Input the spatial and temporal feature representations obtained in steps 2.2 and 2.3 into the adaptive fusion module to obtain the spatiotemporal feature representations of all nodes at each granularity;
[0144] In step 2.4, the adaptive fusion module uses a bilinear function to fuse spatial features and temporal features:
[0145]
[0146] Among them, W1 and W2 are learnable parameters, and ⊙ represents the element-wise product.
[0147] Step 2.5: Input the spatiotemporal representation of the target granularity obtained in step 2.4 into the intra-granular contrastive learning module to capture the correlation between nodes at the target granularity;
[0148] In step 2.5, the similarity between nodes at the target granularity is first calculated and arranged by size. The top K nodes with the highest similarity are taken as positive samples of the node, and the remaining nodes are taken as negative samples. The InfoNCE loss in contrastive learning is used to calculate the contrastive loss within the granularity:
[0149]
[0150] Where τ is the temperature coefficient, is the positive sample set, is the negative sample set.
[0151] Step 2.6: Input the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity obtained in step 2.4 into the inter-granularity contrast learning module to capture the correlation between different granularities of the same node;
[0152] In step 2.6, the feature representations of the same node at different granularities are regarded as positive samples, and the remaining nodes are regarded as negative samples. The contrast loss between granularities is calculated using the InfoNCE loss in contrastive learning:
[0153]
[0154] Where τ is the temperature coefficient, is the negative sample set.
[0155] Step 2.7: Splice the node representations of different granularities, and apply gating technology to filter the spliced fusion representation; in the step 2.7, firstly splice the spatiotemporal representations of different granularities obtained in step 2.4:
[0156] H Concat =|| b∈B H b
[0157] The concatenated representation is then filtered through the gating unit:
[0158] H fusion =σ1(HConcat )⊙σ2(H Concat )
[0159] Among them, σ1 is the hyperbolic tangent activation function, σ2 is the sigmoid activation function, and ⊙ represents the element-wise product.
[0160] Step 2.8: Use a two-layer fully connected neural network to predict the air quality (PM2.5 value) at the target granularity of each air quality monitoring station at the next γ time moments.
[0161] Step 3: training the air quality prediction model based on multi-granularity contrast learning described in step 2;
[0162] The step 3 specifically comprises the following steps:
[0163] Step 3.1: Input the data in the training set into the air quality prediction model based on multi-granularity contrast learning described in step 2. Obtain the predicted value at the target granularity;
[0164] Step 3.2: Calculate the prediction loss using the mean absolute error based on the true value of the target granularity in step 1.3 and the predicted value in step 3.1;
[0165] The prediction loss in step 3.2 is:
[0166]
[0167] Step 3.3: The prediction loss in step 3.2, the intra-granular contrast loss in step 2.5, and the inter-granular contrast loss in step 2.6 are weighted to construct an overall loss function and minimized to train the model.
[0168] The overall model loss in step 3.3 is the weighted sum of the prediction loss in step 3.2 and the contrast loss in steps 2.5 and 2.6:
[0169]
[0170] Among them, η1, η2 and λ θ is a hyperparameter, represents the L2 regularization term, which prevents the model from overfitting by penalizing large parameter values in the model.
[0171] Step 4: Input the spatiotemporal series data of the air quality monitoring stations in the test set into the air quality prediction model based on multi-granularity contrastive learning trained in step 3, and output the predicted air quality value (PM2.5) for the next γ steps.
[0172] In this implementation, an air quality prediction model based on multi-granularity contrastive learning is proposed to address some limitations of existing air quality prediction models. The model mainly consists of three modules: first, a dual hypergraph convolution module that integrates geographic hypergraph and semantic hypergraph is designed to capture high-order spatial dependencies between nodes, and a temporal dependency learning module is designed to learn the temporal representation of nodes, and the spatiotemporal representation of nodes is obtained by adaptively fusing spatial representation and temporal representation. Then, an intra-granularity and inter-granularity contrastive learning module is designed, which enhances the spatiotemporal representation by combining the commonalities and differences of different granularities. Finally, a supervision task is introduced to distinguish the importance of different granularities and make predictions for all nodes.
[0173] Although preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure. Obviously, those skilled in the art may make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is also intended to include these modifications and variations.
[0174] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0175] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure rather than to limit its protection scope. Although the present disclosure has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that after reading the present disclosure, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation methods of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the disclosed claims to be approved.
Claims
1. The air quality prediction method based on multi-granularity contrast learning is characterized by: The method comprises: S1: Obtain the air quality monitoring dataset and time characteristic dataset of the air quality monitoring site, preprocess the air quality monitoring dataset and time characteristic dataset and divide them into training set, validation set and test set, and take PM2.5 as the target pollutant; S2: Divide the air quality data into different granularities and build an air quality prediction model based on multi-granularity contrast learning; S3: Training an air quality prediction model based on multi-granularity contrastive learning; S4: Input the test set into the trained air quality prediction model based on multi-granularity contrastive learning to obtain the air quality prediction value.
2. The air quality prediction method based on multi-granularity contrast learning according to claim 1 is characterized in that: The step S1 comprises: S11: preprocessing the historical air quality monitoring data of each air quality monitoring station according to the linear interpolation and maximum and minimum normalization methods; S12: Divide the preprocessed air quality monitoring data and time characteristic data according to the mean pooling technology, obtain air quality monitoring data with a time interval of 3 hours and a time interval of 6 hours, and use the time interval of 1 hour as the target granularity, and use the time interval of 3 hours and the time interval of 6 hours as auxiliary granularities; S13: Divide the acquired data of different granularities into a training set, a validation set, and a test set.
3. The air quality prediction method based on multi-granularity contrast learning according to claim 2 is characterized in that: The step S2 comprises: S21: constructing a geographic hypergraph and a semantic hypergraph according to the location information and attribute information of the nodes respectively; wherein the nodes are air quality monitoring sites; S22: Fusion constructs geographic hypergraph and semantic hypergraph, and inputs the training set data into the dual hypergraph convolutional spatial feature extraction module to obtain the spatial feature representation of the nodes; S23: Input the training set data into the external attention time feature extraction module to obtain the time feature representation of the node; S24: inputting the spatial feature representation and the temporal feature representation of the node into the adaptive fusion module to obtain the spatiotemporal feature representation of all nodes at each granularity; S25: Use the intra-granular contrast learning module to process the spatiotemporal feature representation at the target granularity and capture the correlation between nodes at the target granularity; S26: Use the inter-granularity contrast learning module to process the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity to capture the correlation between different granularities of the same node; S27: concatenate node representations of different granularities, and use gating technology to filter the concatenated fusion representation; S28: Air quality prediction model based on multi-granularity contrastive learning based on two-layer fully connected neural network and filtered fusion representation combination.
4. The air quality prediction method based on multi-granularity contrast learning according to claim 3 is characterized in that: The step S23 comprises: The temporal dependency learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes. Among them, M b,v is a learnable parameter, A b It is the input data and the external memory matrix unit M b,k Attention between: Among them, M b,k It is a memory associated with the dataset. Norm indicates that double normalization is used to normalize rows and columns separately.
5. The air quality prediction method based on multi-granularity contrast learning according to claim 4 is characterized in that: The step S24 comprises: Among them, W1 and W2 are learnable parameters, ⊙ represents the element-wise product, and H b It is an adaptive fusion module.
6. The air quality prediction method based on multi-granularity contrast learning according to claim 4 is characterized in that: The step S27 comprises: Splicing the spatiotemporal representations at different granularities Concat : H Concat =|| b∈B H b The concatenated representation is then filtered by the gating unit H fusion : H fusion =σ1(H Concat )⊙σ2(H Concat ) Among them, σ1 is the hyperbolic tangent activation function, σ2 is the sigmoid activation function, and ⊙ represents the element-wise product.
7. The air quality prediction method based on multi-granularity contrast learning according to claim 1 is characterized in that: The step S3 comprises: S31: inputting the data in the training set into the air quality prediction model based on multi-granularity contrast learning to obtain the prediction value at the target granularity; S32: Calculate the prediction loss using the mean absolute error according to the actual value and the predicted value of the target granularity; S33: The prediction loss, intra-granular contrast loss, and inter-granular contrast loss are weighted to construct an overall loss function and minimize it to train the model.
8. The air quality prediction system based on multi-granularity contrast learning is characterized by: The system comprises: A data acquisition unit, used to acquire an air quality monitoring data set and a time characteristic data set of an air quality monitoring site, preprocess the air quality monitoring data set and the time characteristic data set and divide them into a training set, a validation set and a test set, and use PM2.5 as a target pollutant; An air quality prediction model building unit, used to divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative learning; A training unit, used to train an air quality prediction model based on multi-granularity contrast learning; The prediction unit is used to input the test set into the trained air quality prediction model based on multi-granularity contrastive learning to obtain the air quality prediction value.
9. A computer device, characterized in that: It includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor runs the computer program stored in the memory, the processor executes the air quality prediction method based on multi-granularity contrast learning as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program executes the air quality prediction method based on multi-granularity contrast learning according to any one of claims 1 to 7.
Citation Information
Patent Citations
Air quality prediction method based on multi-task space-time diagram convolution
CN114841400A
Air quality prediction method based on contrast multi-view clustering
CN115758205A
Air quality prediction method
CN116341763A
