Air quality prediction method and system based on multi-granularity contrast learning

CN118535920BActive Publication Date: 2026-11-03HARBIN ENG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410662597.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2026-11-03
Estimated Expiration
2044-05-27

AI Technical Summary

Technical Problem

Existing air quality prediction methods fail to effectively handle noise interference and uneven distribution of multi-granularity spatiotemporal data, resulting in inaccurate prediction results.

Method used

A multi-granularity contrastive learning approach is adopted. By constructing an air quality prediction model based on multi-granularity contrastive learning, the spatial and temporal features of air quality monitoring stations are extracted using geographic and semantic hypergraphs. Combined with contrastive learning modules inside and outside the granularity, the correlation between nodes and the relationship between different granularities are captured.

Benefits of technology

It improves the accuracy and robustness of air quality forecasts, better adapts to the uneven distribution of spatiotemporal data, and enhances the model's adaptability and predictive performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535920B_ABST
    Figure CN118535920B_ABST
Patent Text Reader

Abstract

The application relates to an air quality prediction method and system based on multi-granularity contrast learning, and relates to the field of air quality prediction. The method solves the problems that existing research does not consider the mode diversity of multi-granularity representation and the limitations of existing methods in processing the uneven distribution of spatiotemporal data. The method comprises the following steps: acquiring an air quality monitoring dataset and a time feature dataset of an air quality monitoring site, preprocessing the air quality monitoring dataset and the time feature dataset, dividing the air quality monitoring dataset and the time feature dataset into a training set, a verification set and a test set, and taking PM2.5 as a target pollutant; dividing the air quality data into different granularities, constructing an air quality prediction model based on multi-granularity contrast learning, training the air quality prediction model based on multi-granularity contrast learning, inputting the test set into the trained air quality prediction model based on multi-granularity contrast learning, and acquiring an air quality prediction value. The application is applied to the field of environmental monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of air quality forecasting, and more particularly to an air quality forecasting method based on multi-granularity contrastive learning. Background Technology

[0002] In various practical applications such as traffic management and environmental monitoring, spatiotemporal data plays a crucial role in revealing data evolution trends. Accurate forecasting has become the cornerstone of making informed decisions and implementing effective strategies in various fields. The core task of air quality forecasting is to effectively learn the temporal and spatial dependencies. With the development of deep learning technology, existing research uses recurrent neural networks (RNNs), temporal convolutional networks (TCNs), and self-attention mechanisms to capture temporal dependencies, while employing convolutional neural networks (CNNs) and graph neural networks (GNNs) to analyze spatial relationships.

[0003] Despite their achievements, these methods still have limitations. First, learning reliable spatiotemporal representations is a complex and challenging task, especially when dealing with multi-granularity spatiotemporal data. The quality of spatiotemporal data is often affected by sensor accuracy and stability, leading to noise in the data, which may originate from sensor errors, environmental interference, or inaccuracies in data processing. Furthermore, traditional air quality forecasting methods typically focus on a single temporal granularity, neglecting the complementarity and intrinsic connections between data at different granularities, thus limiting a comprehensive understanding of complex spatiotemporal dependencies. However, by employing multi-granularity air quality forecasting methods, it is possible to integrate data from different spatiotemporal scales, providing a more comprehensive perspective for understanding and predicting spatiotemporal dynamics. Second, the distribution of spatiotemporal data often exhibits significant unevenness in the real world; for example, data points may be densely clustered in some areas while relatively sparse in others. This uneven distribution pattern presents challenges for data analysis. Traditional data models are often based on the simplistic assumption of uniform spatiotemporal distribution of data, which ignores the complexity of the data, particularly the data density in specific regions versus the sparsity in other regions. This imbalance leads to simplistic model assumptions, which in turn introduces biases in the modeling process, making predictions and analyses unable to accurately reflect the complexity and diversity of the real world. Summary of the Invention

[0004] This invention addresses the shortcomings of existing research, which fails to consider the pattern diversity of multi-granularity representations and the limitations of existing methods in handling uneven distributions of spatiotemporal data. It proposes an air quality prediction method based on multi-granularity contrastive learning, comprising:

[0005] S1: Obtain the air quality monitoring dataset and time feature dataset from the air quality monitoring stations, preprocess the air quality monitoring dataset and time feature dataset and divide them into training set, validation set and test set, and take PM2.5 as the target pollutant;

[0006] S2: Divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative 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 embodiment is proposed, wherein step S1 includes:

[0010] S11: Preprocess the historical air quality monitoring data of each air quality monitoring station according to the linear interpolation and min-max normalization methods;

[0011] S12: Based on the mean pooling technique, the preprocessed air quality monitoring data and time feature data are divided to obtain air quality monitoring data with time intervals of 3 hours and 6 hours. The time interval of 1 hour is used as the target granularity, and the time intervals of 3 hours and 6 hours are used as auxiliary granularities.

[0012] S13: Divide the acquired data of different granularities into training set, validation set and test set.

[0013] Furthermore, a preferred embodiment is proposed, wherein step S2 includes:

[0014] S21: Construct a geographic hypergraph and a semantic hypergraph based on the location and attribute information of the nodes, respectively; where the nodes are air quality monitoring stations;

[0015] S22: Integrate and construct a geographic hypergraph and a semantic hypergraph, and input the data in the training set 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 temporal feature extraction module to obtain the temporal feature representation of the nodes;

[0017] S24: Input the spatial and temporal feature representations of the nodes into the adaptive fusion module to obtain the spatiotemporal feature representations of all nodes at each granularity;

[0018] S25: Employ an intra-granularity contrastive learning module to process the spatiotemporal feature representation at the target granularity and capture the correlation between nodes at the target granularity;

[0019] S26: The inter-granularity contrast learning module is used to process the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity, and to capture the correlation between different granularities of the same node.

[0020] S27: The node representations of different granularities are spliced ​​together, and the spliced ​​fused representation is filtered using gating technology;

[0021] S28: An air quality prediction model based on multi-granularity contrastive learning, which combines a two-layer fully connected neural network and a filtered fusion representation.

[0022] Furthermore, a preferred embodiment is proposed, wherein step S23 includes:

[0023] The time-dependent learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes.

[0024]

[0025] Among them, M b,v It 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 For the memory associated with the dataset, Norm indicates that double normalization was used to normalize the rows and columns separately.

[0028] Furthermore, a preferred embodiment is proposed, wherein step S24 includes:

[0029]

[0030] Where W1 and W2 are learnable parameters, ⊙ represents the element-wise product, and H... b This is an adaptive fusion module.

[0031] Furthermore, a preferred embodiment is proposed, wherein step S27 includes:

[0032] splicing spatiotemporal representations at different granularities H Concat :

[0033] H Concat =|| b∈B H b

[0034] The concatenated representation is then filtered by a gating unit. fusion :

[0035] H fusion =σ1(H Concat )⊙σ2(H Concat )

[0036] Where σ1 is the hyperbolic tangent activation function, σ2 is the sigmoid activation function, and ⊙ represents the element-wise product.

[0037] Furthermore, a preferred embodiment is proposed, wherein step S3 includes:

[0038] S31: Input the data in the training set into the air quality prediction model based on multi-granularity contrastive learning to obtain the predicted value at the target granularity;

[0039] S32: Calculate the prediction loss using the mean absolute error based on the true and predicted values ​​of the target granularity;

[0040] S33: Weight the prediction loss, intra-granularity contrast loss, and inter-granularity contrast loss to construct an overall loss function and minimize it to train the model.

[0041] Based on the same inventive concept, this invention also proposes an air quality prediction system based on multi-granularity contrastive learning, the system comprising:

[0042] The data acquisition unit is used to acquire air quality monitoring datasets and time feature datasets from air quality monitoring stations, preprocess the air quality monitoring datasets and time feature datasets and divide them into training set, validation set and test set, and use PM2.5 as the target pollutant;

[0043] The air quality prediction model building unit is used to divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative learning.

[0044] Training unit, used to train air quality prediction model based on multi-granularity contrastive 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 predicted air quality 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 contrastive learning as described in any of the above.

[0047] Based on the same inventive concept, the present invention also proposes a computer-readable storage medium for storing a computer program that executes the air quality prediction method based on multi-granularity contrastive learning described in any of the preceding claims.

[0048] The advantages of this invention are:

[0049] Traditional air quality forecasting methods are susceptible to noise interference, leading to inaccurate predictions. This invention proposes an air quality forecasting method based on multi-granularity contrastive learning. This method reduces the impact of noise to some extent because it extracts useful patterns by comparing information at different granularities, thus providing better air quality predictions.

[0050] Real-world air quality data often exhibits a non-uniform spatiotemporal distribution, which traditional methods struggle to handle effectively. The method proposed in this invention employs multi-granularity contrastive learning, which better utilizes information at different granularities, thus more effectively addressing the non-uniform distribution of spatiotemporal data and improving the accuracy of air quality prediction. By utilizing multi-granularity contrastive learning, the relationship between air quality monitoring data and temporal feature data can be more fully leveraged, thereby enhancing the accuracy and reliability of air quality prediction. This method can also reduce the impact of noise to some extent and better adapt to the non-uniform distribution of spatiotemporal data, enhancing the model's robustness and enabling it to perform well under various conditions. By dividing air quality data into different granularities and constructing a prediction model based on multi-granularity contrastive learning, the information within the data can be better utilized, extracting richer features and thus improving prediction performance.

[0051] This invention overcomes the problem of obtaining reliable spatiotemporal representations under multiple granularities by using contrastive learning to achieve comparisons within and between granularities, thereby obtaining richer spatiotemporal representations.

[0052] This invention also overcomes the problem of uneven distribution of air quality data by using semantic hypergraphs and geographic hypergraphs to capture high-order spatial dependencies between nodes, thereby alleviating the problem of uneven data distribution.

[0053] This invention is applied to the field of environmental monitoring. Attached Figure Description

[0054] Figure 1 This is a flowchart of the air quality prediction method based on multi-granularity contrastive learning described in Implementation Method 1.

[0055] Figure 2 This is a schematic diagram of the air quality prediction model based on multi-granularity contrastive learning as described in Implementation Method 3;

[0056] Figure 3 This is a schematic diagram of the dual hypergraph convolutional spatial feature extraction module described in Implementation Method Eleven;

[0057] Figure 4 This is a schematic diagram of the external attention time feature extraction module described in Implementation Method Eleven. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0059] Implementation Method 1, see [link] Figure 1 This embodiment describes an air quality prediction method based on multi-granularity contrastive learning. The method includes:

[0060] S1: Obtain the air quality monitoring dataset and time feature dataset from the air quality monitoring stations, preprocess the air quality monitoring dataset and time feature dataset and divide them into training set, validation set and test set, and take PM2.5 as the target pollutant;

[0061] S2: Divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative 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 forecasting methods are susceptible to noise interference, leading to inaccurate predictions. The method proposed in this embodiment employs a multi-granularity contrastive learning approach, which can reduce the impact of noise to some extent. This is because it extracts useful patterns by comparing information at different granularities, thereby providing better air quality predictions.

[0065] Real-world air quality data often exhibits a non-uniform distribution across time and space, a characteristic that traditional methods struggle to handle effectively. This implementation employs a multi-granularity contrastive learning approach, which better utilizes information at different granularities to more effectively address the non-uniform distribution of spatiotemporal data, thereby improving the accuracy of air quality predictions. By leveraging multi-granularity contrastive learning, the relationship between air quality monitoring data and temporal feature data can be more fully utilized, thus enhancing the accuracy and reliability of air quality predictions. This approach can also reduce the impact of noise to some extent and better adapt to the non-uniform distribution of spatiotemporal data, thereby enhancing the model's robustness and enabling it to perform well under various conditions. By dividing air quality data into different granularities and constructing a prediction model based on multi-granularity contrastive learning, the information within the data can be better utilized, extracting richer features and ultimately improving prediction performance.

[0066] Implementation Method Two: This implementation method further defines the air quality prediction method based on multi-granularity contrastive learning described in Implementation Method One. Step S1 includes:

[0067] S11: Preprocess the historical air quality monitoring data of each air quality monitoring station according to the linear interpolation and min-max normalization methods;

[0068] S12: Based on the mean pooling technique, the preprocessed air quality monitoring data and time feature data are divided to obtain air quality monitoring data with time intervals of 3 hours and 6 hours. The time interval of 1 hour is used as the target granularity, and the time intervals of 3 hours and 6 hours are used as auxiliary granularities.

[0069] S13: Divide the acquired data of different granularities into training set, validation set and test set.

[0070] This implementation uses linear interpolation and min-max normalization to preprocess historical data from each air quality monitoring station, effectively handling missing and outlier values ​​and improving data quality and usability. By employing mean pooling to divide the data into different granularities—1-hour, 3-hour, and 6-hour time intervals—it comprehensively considers the impact of different time granularities on air quality, improving the model's applicability and generalization ability. Using 1-hour as the target granularity and 3-hour and 6-hour as auxiliary granularities preserves high accuracy while leveraging information from the auxiliary granularities to enhance model stability and robustness, making the model more suitable for different scenarios and data distributions. Dividing the datasets into training, validation, and test sets allows for better evaluation of model performance and provides a more comprehensive data foundation, aiding in model training and optimization.

[0071] Implementation Method 3, see below Figure 2 This embodiment further defines the air quality prediction method based on multi-granularity contrastive learning described in Embodiment 2. Step S2 includes:

[0072] S21: Construct a geographic hypergraph and a semantic hypergraph based on the location and attribute information of the nodes, respectively; where the nodes are air quality monitoring stations;

[0073] S22: Integrate and construct a geographic hypergraph and a semantic hypergraph, and input the data in the training set 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 temporal feature extraction module to obtain the temporal feature representation of the nodes;

[0075] S24: Input the spatial and temporal feature representations of the nodes into the adaptive fusion module to obtain the spatiotemporal feature representations of all nodes at each granularity;

[0076] S25: Employ an intra-granularity contrastive learning module to process the spatiotemporal feature representation at the target granularity and capture the correlation between nodes at the target granularity;

[0077] S26: The inter-granularity contrast learning module is used to process the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity, and to capture the correlation between different granularities of the same node.

[0078] S27: The node representations of different granularities are spliced ​​together, and the spliced ​​fused representation is filtered using gating technology;

[0079] S28: An air quality prediction model based on multi-granularity contrastive learning, which combines a two-layer fully connected neural network and a filtered fusion representation.

[0080] Traditional methods fail to capture the complex spatial features of air quality monitoring stations effectively, leading to inaccurate predictions. This implementation constructs a geographic hypergraph and a semantic hypergraph, and utilizes a dual-hypergraph convolutional spatial feature extraction module to more comprehensively obtain the spatial feature representations of nodes, thereby improving the model's ability to understand and utilize spatial information.

[0081] Comprehensive feature extraction from spatiotemporal data is one of the key issues in air quality forecasting. This implementation introduces an external attention temporal feature extraction module and an adaptive fusion module, which can more effectively extract the temporal feature representation of nodes and adaptively fuse spatial and temporal features to obtain richer and more accurate spatiotemporal feature representations.

[0082] When processing multi-granularity information, an intra-granularity contrastive learning module and an inter-granularity contrastive learning module were used to capture the correlation between nodes at the target granularity and the correlation between the target granularity and the auxiliary granularity, respectively. This allowed for better utilization of information at different granularities and improved the model's efficiency in utilizing data and its 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 its prediction accuracy.

[0084] Implementation Method Four: This implementation method further defines the air quality prediction method based on multi-granularity contrastive learning described in Implementation Method Three. Step S23 includes:

[0085] The time-dependent learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes.

[0086]

[0087] Among them, M b,v It 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-dependent memory, it is a learnable parameter independent of the input. Norm indicates that double normalization was used to normalize the rows and columns separately.

[0090] This implementation applies the Transformer attention mechanism to the time dependency learning module, which can better capture the time dependencies in air quality data, thereby improving the quality of time representation and the accuracy of prediction. The parameters in the external attention mechanism are learnable, meaning the model can adaptively learn the correlations between data points rather than relying on a fixed attention distribution. This makes the model more general and adaptable across different datasets and prediction tasks. Using a Transformer-based attention mechanism, time dependencies can be modeled as sparse attention weights, reducing the computational cost of the memory matrix and storage requirements, thus improving model efficiency and scalability. The external memory, acting as a dataset-related memory matrix, dynamically adjusts the relationship between input data and external memory through the attention mechanism, enabling the model to better utilize external information to enhance the temporal representation of nodes, thereby improving the model's representational ability and prediction performance.

[0091] Implementation Method Five: This implementation method further defines the air quality prediction method based on multi-granularity contrastive learning described in Implementation Method Four. Step S24 includes:

[0092]

[0093] Where W1 and W2 are learnable parameters, ⊙ represents the element-wise product, and H... b This is an adaptive fusion module.

[0094] Using an adaptive fusion module allows the model to automatically learn the relationships between the spatial and temporal features of nodes and perform effective fusion. This fusion method can fully utilize the interactions between different features, thereby better capturing the complex patterns and regularities in air quality monitoring data.

[0095] Parameters W1 and W2 are learnable, meaning the model can automatically adjust these parameters based on the data to optimally fuse spatial and temporal features. This flexibility allows the model to better adapt to the characteristics of different datasets and tasks, improving its generalization ability. Using element-wise product operations allows the model to consider the importance of both spatial and temporal features simultaneously and weigh them during the fusion process. This helps the model to more comprehensively understand the spatiotemporal characteristics of the data, thereby improving prediction accuracy.

[0096] The resulting spatiotemporal feature representations of all nodes at each granularity incorporate the fusion of spatial and temporal information, enabling the model to better capture the spatiotemporal relationships between monitoring stations and thus improve the accuracy of air quality prediction.

[0097] Implementation Method Six: This implementation method further defines the air quality prediction method based on multi-granularity contrastive learning described in Implementation Method Four. Step S27 includes:

[0098] splicing spatiotemporal representations at different granularities H Concat :

[0099] H Concat =|| b∈B H b

[0100] The concatenated representation is then filtered by a gating unit. fusion :

[0101] H fusion =σ1(H Concat )⊙σ2(H Concat )

[0102] Where σ1 is the hyperbolic tangent activation function, σ2 is the sigmoid activation function, and ⊙ represents the element-wise product.

[0103] This implementation method, by splicing spatiotemporal representations at different granularities, allows the model to comprehensively utilize information from each granularity, thereby gaining a more complete understanding of the characteristics of air quality monitoring stations. This synthesis helps the model better capture the intrinsic relationships between data, improving prediction accuracy. The spliced ​​representations are then filtered through a gating unit, selectively emphasizing or suppressing the importance of features. This helps the model better focus on features that influence the prediction target during the learning process, improving model performance and generalization ability. Using hyperbolic tangent and sigmoid activation functions can normalize and compress features within an appropriate range, ensuring that feature values ​​are within suitable intervals, which is beneficial for optimizing algorithm stability and convergence speed. Element-wise product operations help the model better combine information from different granularities, introducing interaction relationships between features, which helps improve the model's expressive and fitting abilities.

[0104] Implementation Method Seven: This implementation method further defines the air quality prediction method based on multi-granularity contrastive learning described in Implementation Method One. Step S3 includes:

[0105] S31: Input the data in the training set into the air quality prediction model based on multi-granularity contrastive learning to obtain the predicted value at the target granularity;

[0106] S32: Calculate the prediction loss using the mean absolute error based on the true and predicted values ​​of the target granularity;

[0107] S33: Weight the prediction loss, intra-granularity contrast loss, and inter-granularity contrast loss 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 comparison loss, and inter-granularity comparison loss. This method comprehensively considers multiple aspects of loss, enabling the model to better learn the correlation and patterns between data during training, thereby improving the model's generalization ability and prediction accuracy.

[0109] The multi-granularity contrastive learning approach considers not only the loss between predicted and true values, but also the contrastive losses within and between granularities. This contrastive learning method helps the model better understand the intrinsic relationships between data, improving the model's robustness and interpretability.

[0110] By incorporating contrastive losses at different granularities, the model pays closer attention to data features at various scales, thereby improving its adaptability and robustness to data at diverse scales. This helps the model achieve good predictive results when faced with data of different granularities.

[0111] By weighting different loss terms, the weights of the loss function can be flexibly adjusted according to the characteristics of the task and the nature of the data, thereby better balancing the importance of each loss term and optimizing the training effect of the model.

[0112] Implementation Method Eight: The air quality prediction system based on multi-granularity contrastive learning described in this implementation method includes:

[0113] The data acquisition unit is used to acquire air quality monitoring datasets and time feature datasets from air quality monitoring stations, preprocess the air quality monitoring datasets and time feature datasets and divide them into training set, validation set and test set, and use PM2.5 as the target pollutant;

[0114] The air quality prediction model building unit is used to divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative learning.

[0115] Training unit, used to train air quality prediction model based on multi-granularity contrastive 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 predicted air quality value.

[0117] Implementation Method Nine: A computer device according to this implementation method includes a memory and a processor. The memory stores a computer program. When the processor runs the computer program stored in the memory, the processor executes the air quality prediction method based on multi-granularity contrastive learning as described in any one of Implementation Methods One to Seven.

[0118] Implementation Method 10: A computer-readable storage medium according to this implementation method, the computer-readable storage medium being used to store a computer program, the computer program executing the air quality prediction method based on multi-granularity contrastive learning as described in any one of Implementation Methods 1 to 7.

[0119] Implementation Method 11, see below Figure 3 and Figure 4 This embodiment describes a specific example of the air quality prediction method based on multi-granularity contrastive learning described in Embodiment 1, and also serves to explain Embodiments 2 to 7. Specifically:

[0120] Step 1: Obtain the air quality monitoring dataset and time feature dataset from the air quality monitoring stations. Preprocess the dataset and divide it into training set, validation set and test set, and use PM2.5 as the target pollutant.

[0121] Step 1 specifically includes the following steps:

[0122] Step 1.1: Preprocess the historical monitoring data of each air quality monitoring station using linear interpolation and min-max normalization methods;

[0123] Step 1.2: Apply mean pooling to divide the original data (1-hour time interval) into air quality monitoring data with 3-hour and 6-hour time intervals. The 1-hour time interval is used as the target granularity, and the other two are used as auxiliary granularities (3-hour and 6-hour time intervals).

[0124] In step 1.2, the original data is divided into multi-granularity spatiotemporal data using mean pooling, represented by a set of granularities {g1, g2, g3} from fine to coarse. Each granularity g b The following time series The expression is represented as follows: where N represents the number of nodes, T represents the time window length, F represents the feature dimension, and X represents the feature dimension. i,b Indicates particle size in g b The time series of the i-th node;

[0125] Step 1.3: Further divide the data of different granularities obtained in Step 1.2 into training set, validation set and test set.

[0126] Step 2: Construct an air quality prediction model based on multi-granularity contrastive learning;

[0127] Step 2 specifically includes the following steps:

[0128] Step 2.1: Construct a geographic hypergraph G using the location and attribute information of the nodes. D and semantic hypergraph G S ;

[0129] In step 2.1, in order to construct the semantic hypergraph G S First, the semantic similarity between nodes is calculated using cosine similarity and then arranged in descending order. For each node, the top K nodes with the highest similarity are selected to form a hyperedge. For all nodes, a hyperedge set ε is constructed. S , where |ε S | represents the number of hyperedges, and the connection matrix between nodes and hyperedges is defined as follows:

[0130] To construct the geographic hypergraph G D First, calculate the geographical distance between nodes, and then select nodes within a threshold range to form a hyperedge with each node. 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 follows:

[0131] Step 2.2: Merge the geographic hypergraph and semantic hypergraph constructed in Step 2.1, and input the training data obtained in Step 1.3 into the dual hypergraph convolutional spatial feature extraction module to obtain the spatial feature representation of the nodes; wherein, the dual hypergraph convolutional spatial feature extraction module is as follows: Figure 3 As shown.

[0132] In step 2.2, the particle size g b The spatial characteristics are represented as follows:

[0133]

[0134] Where L is the number of hypergraph convolution iterations, and the hypergraph convolution process for each layer is as follows:

[0135]

[0136] Among them, D v and D e These are 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 temporal feature extraction module to obtain the temporal feature representation of the nodes; wherein, the external attention temporal feature extraction module is as follows: Figure 4 As shown.

[0138] In terms of particle size g b For example, in step 2.3, the time-dependent learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes:

[0139]

[0140] Among them, M b,v It 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-dependent memory, it is a learnable parameter independent of the input. Norm indicates that double normalization was used to normalize the rows and columns separately.

[0143] Step 2.4: Input the spatial and temporal feature representations obtained in Step 2.2 and Step 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 and temporal features:

[0145]

[0146] Here, W1 and W2 are learnable parameters, and ⊙ represents the element-wise product.

[0147] Step 2.5: Input the spatiotemporal representation at the target granularity obtained in Step 2.4 into the intragranular 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 sorted by size. The top K nodes with the highest similarity are taken as positive samples for that node, and the remaining nodes are taken as negative samples. The in-granularity contrastive loss is calculated using the InfoNCE loss in contrastive learning.

[0149]

[0150] Where τ is the temperature coefficient. For the positive sample set, This is the set of negative samples.

[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 comparison learning module to capture the correlation between different granularities of the same node;

[0152] In step 2.6, feature representations at different granularities of the same node are considered as positive samples, and the remaining nodes are considered as negative samples. The InfoNCE loss in contrastive learning is used to calculate the contrastive loss between granularities.

[0153]

[0154] Where τ is the temperature coefficient. This is the set of negative samples.

[0155] Step 2.7: Concatenate node representations of different granularities and apply gating technology to filter the fused representation after concatenation; Step 2.7 first involves concatenating 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 by a gating unit:

[0158] H fusion =σ1(HConcat )⊙σ2(H Concat )

[0159] Where σ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 for each air quality monitoring station at the next γ time points.

[0161] Step 3: Train the air quality prediction model based on multi-granularity contrastive learning described in Step 2;

[0162] Step 3 specifically includes the following steps:

[0163] Step 3.1: Input the data from the training set into the air quality prediction model based on multi-granularity contrastive learning described in Step 2. Obtain the predicted value at the target granularity.

[0164] Step 3.2: Based on the true value of the target granularity in Step 1.3 and the predicted value in Step 3.1, calculate the prediction loss using the mean absolute error;

[0165] The prediction loss in step 3.2 is:

[0166]

[0167] Step 3.3: Weight the prediction loss from Step 3.2, the intra-granularity contrast loss from Step 2.5, and the inter-granularity contrast loss from Step 2.6 to construct an overall loss function and minimize it to train the model.

[0168] The overall model loss in step 3.3 is a weighted sum of the prediction loss in step 3.2 and the contrast loss in steps 2.5 and 2.6.

[0169]

[0170] Wherein, η1, η2 and λ θ For hyperparameters, This represents the L2 regularization term, which prevents overfitting by penalizing large parameter values ​​in the model.

[0171] Step 4: Input the spatiotemporal sequence 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] This implementation addresses some limitations of existing air quality prediction models by proposing an air quality prediction model based on multi-granularity contrastive learning. The model mainly consists of three modules: First, a dual hypergraph convolution module integrating geographic and semantic hypergraphs is designed to capture high-order spatial dependencies between nodes. 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 and temporal representations. Then, an intra-granularity and inter-granularity contrastive learning module is designed, which enhances the spatiotemporal representation by combining the commonalities and differences between different granularities. Finally, a supervised task is introduced to distinguish the importance of different granularities and make predictions for all nodes.

[0173] Although preferred embodiments of this disclosure have been described, those skilled in the art, upon learning the basic inventive concept, can make further changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of this disclosure. Clearly, those skilled in the art can make various alterations and variations to this disclosure without departing from its spirit and scope. Thus, if such modifications and variations fall within the scope of the claims of this disclosure and their equivalents, this disclosure is also intended to include such modifications and variations.

[0174] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied 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] This disclosure is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure and not to limit its protection scope. Although this disclosure has been described in detail with reference to the above embodiments, those skilled in the art should understand that after reading this disclosure, they can still make various changes, modifications or equivalent substitutions to the specific implementation of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the published pending claims.

Claims

1. An air quality prediction method based on multi-granularity contrastive learning, characterized in that, The method includes: S1: Obtain the air quality monitoring dataset and time feature dataset from the air quality monitoring stations, preprocess the air quality monitoring dataset and time feature dataset and divide them into training set, validation set and test set, and take PM2.5 as the target pollutant; S2: Divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative 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; Step S1 includes: S11: Preprocess the historical air quality monitoring data of each air quality monitoring station according to the linear interpolation and min-max normalization methods; S12: Based on the mean pooling technique, the preprocessed air quality monitoring data and time feature data are divided to obtain air quality monitoring data with time intervals of 3 hours and 6 hours. The time interval of 1 hour is used as the target granularity, and the time intervals of 3 hours and 6 hours are used as auxiliary granularities. S13: Divide the acquired data of different granularities into training set, validation set and test set; Step S2 includes: S21: Construct a geographic hypergraph and a semantic hypergraph based on the location and attribute information of the nodes, respectively; where the nodes are air quality monitoring stations; S22: Integrate and construct a geographic hypergraph and a semantic hypergraph, and input the data in the training set 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 temporal feature extraction module to obtain the temporal feature representation of the nodes; S24: Input the spatial and temporal feature representations of the nodes into the adaptive fusion module to obtain the spatiotemporal feature representations of all nodes at each granularity; S25: Employ an intra-granularity contrastive learning module to process the spatiotemporal feature representation at the target granularity and capture the correlation between nodes at the target granularity; S26: The inter-granularity contrast learning module is used to process the spatiotemporal representation at the target granularity and the spatiotemporal representation at the auxiliary granularity, and 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 fused representation after concatenation; S28: An air quality prediction model based on multi-granularity contrastive learning, which combines a two-layer fully connected neural network and a filtered fusion representation. Step S3 includes: S31: Input the data in the training set into the air quality prediction model based on multi-granularity contrastive learning to obtain the predicted value at the target granularity; S32: Calculate the prediction loss using the mean absolute error based on the true and predicted values ​​of the target granularity; S33: Weight the prediction loss, intra-granularity contrast loss, and inter-granularity contrast loss to construct an overall loss function and minimize it to train the model.

2. The air quality prediction method based on multi-granularity contrastive learning according to claim 1, characterized in that, Step S23 includes: The time-dependent learning module uses a Transformer-based external attention mechanism to learn the temporal representation of nodes. : in, To learn the temporal representation of nodes using an external attention mechanism based on Transformer, These are learnable parameters. It is the input data and the external memory matrix unit. Attention between: Norm indicates that double normalization was used to normalize both rows and columns separately. Represents each granularity The following time series.

3. The air quality prediction method based on multi-granularity contrastive learning according to claim 2, characterized in that, Step S24 includes: in, and These are learnable parameters. Represents the element-wise product. For adaptive fusion module, For particle size Spatial characteristics.

4. The air quality prediction method based on multi-granularity contrastive learning according to claim 3, characterized in that, Step S27 includes: splicing spatiotemporal representations at different granularities : The concatenated representation is then filtered by a gating unit. : in, The hyperbolic tangent activation function is used. It is the sigmoid activation function. Represents the element product.

5. The air quality prediction method based on multi-granularity contrastive learning according to claim 1, characterized in that, Step S3 includes: S31: Input the data in the training set into the air quality prediction model based on multi-granularity contrastive learning to obtain the predicted value at the target granularity; S32: Calculate the prediction loss using the mean absolute error based on the true and predicted values ​​of the target granularity; S33: Weight the prediction loss, intra-granularity contrast loss, and inter-granularity contrast loss to construct an overall loss function and minimize it to train the model.

6. An air quality prediction system based on multi-granularity contrastive learning, characterized in that, The system is implemented based on the method of claim 1, and the system includes: The data acquisition unit is used to acquire air quality monitoring datasets and time feature datasets from air quality monitoring stations, preprocess the air quality monitoring datasets and time feature datasets and divide them into training set, validation set and test set, and use PM2.5 as the target pollutant; The air quality prediction model building unit is used to divide air quality data into different granularities and build an air quality prediction model based on multi-granularity comparative learning. Training unit, used to train air quality prediction model based on multi-granularity contrastive 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 predicted air quality value.

7. A computer device, characterized in that, The system includes 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 contrastive learning as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program that executes the air quality prediction method based on multi-granularity contrastive learning as described in any one of claims 1-5.

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