Method and system for filling missing spatio-temporal data in air quality detection system
By using a spatiotemporal data completion model, along with a noise prediction module and iTransformer technology, the problem of missing air quality monitoring data was solved, achieving efficient data completion and improving the accuracy of air quality assessment and early warning.
Patent Information
- Application Number
- CN202511418931.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-30
- Publication Date
- 2025-12-16
AI Technical Summary
Existing air quality monitoring data suffers from missing spatiotemporal data. Traditional methods struggle to effectively capture the spatiotemporal correlation of air quality data, resulting in insufficient accuracy in data filling and impacting the accuracy of air quality assessment and early warning forecasts.
A spatiotemporal data imputation model is adopted, which combines a noise prediction module and an iTransformer module with a diffusion probability model and a self-attention mechanism to capture the spatiotemporal correlation of air quality data and achieve accurate imputation of missing data.
It has improved the completeness and reliability of air quality monitoring data, enhanced the accuracy of historical data statistical analysis, provided more solid data support for pollution trend judgment and source apportionment, and optimized the stability of the real-time monitoring system.
Smart Images

Figure CN121144697A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of air quality detection technology, and more particularly to a method and system for filling in the spatiotemporal data gaps in an air quality detection system. Background Technology
[0002] In the field of air quality monitoring, the concentration data of pollutants such as PM2.5, PM10, ozone, and nitrogen dioxide continuously collected by sensor networks exhibit significant spatiotemporal characteristics. However, due to factors such as sensor malfunctions, communication link interruptions, and environmental interference, monitoring data often suffers from gaps, resulting in incomplete spatiotemporal data. Air quality monitoring data also presents significant complexities: first, the monitored objects involve multiple pollutants, requiring instruments with extremely high sensitivity and accuracy; second, spatiotemporal coverage presents challenges, with significant differences in pollution levels across different regions (such as city centers, industrial areas, suburbs, and remote areas); third, equipment accuracy and stability decrease with increased usage time; and fourth, equipment costs and maintenance require substantial investment of human, material, and financial resources. All these factors exacerbate the risk of data gaps.
[0003] Currently, the mainstream data imputation methods mainly fall into three categories: First, simple statistical imputation methods, such as mean imputation and median imputation. These methods imput data based solely on the statistical characteristics of existing data, completely ignoring the time series characteristics and spatial correlation of the data. Second, time series model methods, such as autoregressive moving average models. These methods have limited ability to handle missing data, and their prediction accuracy decreases significantly when there are consecutive missing values or a high missing rate. Third, machine learning methods. Due to the high dimensionality and complex relationships of air quality data features, involving multiple pollutants, meteorological factors, and spatiotemporal information, model construction is difficult, and the ability to generalize to new data in practical applications is poor, making it difficult to accurately imput missing values.
[0004] Existing data imputation methods have significant shortcomings. Traditional methods (such as linear interpolation and mean imputation) struggle to effectively capture the spatiotemporal correlations in air quality data, such as pollution concentration gradients between spatially adjacent stations and periodic variations over time, leading to insufficient imputation accuracy. This problem further impacts the accuracy of tasks such as air quality assessment, pollution source tracing, and early warning and forecasting. Therefore, there is an urgent need for an intelligent data imputation technology that can efficiently utilize spatiotemporal dependencies to improve the completeness and reliability of air quality monitoring data. Summary of the Invention
[0005] In view of this, the purpose of this invention is to propose a method and system for filling in the missing spatiotemporal data in an air quality monitoring system. This invention introduces a spatiotemporal data filling model to solve the problem of data containing missing values in real-world scenarios. By utilizing a noise prediction module, accurate filling of missing data is achieved.
[0006] The technical means employed in this invention are as follows: A method for filling in the spatiotemporal data gaps in an air quality monitoring system includes the following steps: S1. Real-time acquisition of air quality spatiotemporal data from multiple monitoring stations, construction of a time series dataset containing pollutant concentrations based on the air quality spatiotemporal data, and simultaneous generation of a mask matrix identifying missing data locations and an adjacency matrix reflecting the spatial relationships between stations. S2. Based on time series data, mask matrix and adjacency matrix, initialize the parameters of the diffusion probability model, construct a noise prediction model with noise samples, conditional features and adjacency matrix as input, and train the noise prediction network to learn to predict the added noise with mask matrix, adjacency matrix and time embedding information as conditions. Optimize and obtain the trained noise prediction model by minimizing the loss function between the predicted noise and the real noise. S3. The iTransformer module is introduced to enhance the trained noise prediction model. The time series of each variable is used as a label, multivariate spatiotemporal correlation is extracted through self-attention mechanism, and the global feature representation capability is improved by using a feedforward network to obtain the enhanced noise prediction model. S4. Perform data imputation based on the enhanced noise prediction model, gradually restore missing values through a reverse diffusion process, and generate multiple imputation samples to estimate the probability distribution of missing values.
[0007] Furthermore, S1 specifically includes the following steps: S11. Obtain the current time t in different regions, collect air quality index data of the selected data source area through sensors at regular intervals, and transmit the air quality index data to the server to form the original spatiotemporal dataset. S12. Based on the original spatiotemporal dataset, the missing values in the original dataset are marked by the mask matrix M, and the missing value type is analyzed. The missing value type includes random point missing, continuous block missing, or large-scale missing caused by sensor failure. S13. Calculate the geographical distance between monitoring stations based on their latitude and longitude coordinates, and construct an adjacency matrix A.
[0008] Furthermore, S2 specifically includes the following steps: S21. Randomly generate a diffusion step size t; generate random noise with the same shape as the observed data, and calculate the noisy data noise_data with a diffusion step size of t using a Markov chain; the Markov chain calculation formula is as follows:
[0009] in, It is the raw data. This is the data after adding noise, where T is the step size. It is a minimal positive constant representing the noise level, and I represents an identity matrix; S22. Integrate temporal embedding, feature embedding, and mask information into side information side_info, and input the side information into the noise prediction model; the noise prediction model captures global dependencies across time steps and feature dimensions through self-attention mechanisms or convolutional operations, and outputs predicted noise; S23. Construct the input for the noise prediction model. The conditional noise prediction model uses the product of cond_mask and observed_data as the observation part, and the product of (1-cond_mask) and noisy_data as the noisy target part, and concatenates them as the input. The unconditional noise prediction model directly uses noisy_data as the input. Pass the input and additional information side_info into the noise prediction model to obtain the predicted noise. S24. The input spliced data and side information are processed by the diffusion model. The predicted noise is obtained by combining the current diffusion step size. The region to be filled is determined by the difference between the original observation mask and the conditional mask. The sum of squared residuals in the region is calculated and normalized to obtain the loss value used for model optimization.
[0010] Furthermore, S3 specifically includes the following steps: S31. Interpolate the observed values to construct coarse conditional information, and design a conditional feature extraction module to model the spatiotemporal correlation from the coarse interpolation information; S32. The conditional information is modeled separately, and the conditional information X and noise information Xt are used as inputs to enhance the observed values of conditional feature extraction. Linear interpolation is used for the spatiotemporal data sequence of each node to construct preliminary effective interpolation conditional information for noise reduction. S33. Use 1×1 convolution to extract basic features and convert the interpolation condition information X into a feature matrix. Where N is the number of nodes, L is the time step, and C is the channel size; the feature dimension is compressed through convolution operation while preserving the local correlation of spatiotemporal data; For nonlinear relationships and spatial correlations in spatiotemporal data, a conditional feature extraction module γ(·) is involved. This module takes the interpolated conditional information X and the adjacency matrix A as input, extracts the spatiotemporal dependencies from X, and outputs Hpri as the global context for calculating the spatiotemporal attention weights in noise prediction. This is obtained through Hpri = γ(H, A), where H = Conv(X) and Conv(·) is a 1 × 1 convolution. And d is the channel size; The conditional feature extraction module γ(·) comprehensively combines spatiotemporal global correlation and geographic dependence, as follows:
[0011]
[0012]
[0013]
[0014] Where Attn(·) represents global attention, spa represents spatial attention, tem represents temporal attention, and MPNN(·) represents spatial message passing neural network; S34. Utilize special mechanisms in the evaluation module to reduce the impact of sampling noise and capture spatiotemporal global correlation and spatial information; S35. Use the time clustering module to perform feature extraction and fusion processing on the conditional information.
[0015] Furthermore, S34 specifically includes the following steps: S341. The module input consists of two parts: one part is noise information, which is composed of observable data of X and noise samples Xt; the other part is conditional features H. pri Prior information about the adjacency matrix A; learning temporal features H through the time-dependent learning module γT(·). tem The temporal features are aggregated using the spatial dependency learning module γS(·), as shown in the following formula:
[0016]
[0017] S342. When the diffusion step size t is close to T, change the inputs of the attention components Attntem(·) and Attnspa(·) and calculate the attention weights by using the conditional feature Hpri. S343. Construct the attention key Attntem() using iTransformer; S344. Treat each time series in the dataset as a whole as a token, and learn the features of each feature variable based on each time series. The process is as follows:
[0018]
[0019] in, : N embedding tokens with dimension D, where the superscript indicates the layer index; Defined as follows: Perform a transpose operation, which can be implemented using an MLP. The following definition applies: the acquired variable tokens interact through self-attention and are processed independently by the shared feedforward network in each individual TrmBlock; S345. Based on the self-attention mechanism, the transposed model treats the entire sequence of a variable as an independent process; specifically, it utilizes each time series... The self-attention module uses linear projection to obtain queries, keys, and values. , where d k It is the projected size; S346, based on and Calculate spatial dependencies using projection parameters right and Perform a linear transformation to obtain Its spatial attention weights are as follows:
[0020] Using Graph Neural Networks (MPNN) combined with Adjacency Matrix A to obtain geographic dependency features Furthermore, by integrating spatial attention mechanisms and graph neural network features, spatial features are generated using MLP. .
[0021] Furthermore, S35 specifically includes the following steps: S351: Processing of supplementary information. The main supplementary information includes a time-encoded Utem and a node embedding Uspa representing the spatial attributes of the node. After expanding and concatenating the two, auxiliary information is generated through MLP. ; The formal representation is as follows: The timestamp is converted into a time-encoded tensor of dimension (B, L, emb_time_dim) using the time_embedding function, where emb_time_dim is the time embedding dimension; the target dimension is embedded using the embed_layer function to generate a feature embedding tensor of dimension (K, feature_emb_dim), where feature_emb_dim is the feature embedding dimension; then, the feature embedding tensor is expanded to (B, L, K, feature_emb_dim) to match the batch size and time step. S352: The additional information is merged into (B*side_dim, K, L) to make each channel independent, using the Channel-Independent strategy to model each channel separately; after processing, the clustering module is used to distribute the processed information through the Distribution Router and the Linear-based PatternExtractor to extract temporal features, and finally the linear layer is used to map the features to the target dimension to obtain side_info that matches the input dimension.
[0022] Furthermore, S4 specifically includes the following steps: S41, Data imputation process: Provide noise samples, and use the noise prediction model to predict the noise to be added to the current noise sample by combining auxiliary information side_info and diffusion step size t; S42. By generating multiple imputation samples to approximate the probability distribution of missing values, it is suitable for situations with high missing rates and sensor failure.
[0023] The present invention also provides a spatiotemporal data missing filling system in an air quality detection system, which is used to fill the spatiotemporal data missing in any of the above-mentioned air quality detection system methods, including an original missing data processing layer, a diffusion model construction layer, a feature extraction layer and a data filling layer. The raw missing data processing layer is used to build the data features that the model can process, including raw observable data, missing value mask matrix and missing rate setting; The diffusion model construction layer is used to build a complete diffusion model, including the initialization of diffusion process parameters and the setting of parameters for the inverse diffusion process, and to complete the data introduction. The feature extraction layer is used to capture the temporal dependencies and feature dependencies of the input data, enhancing the model's global context awareness; it fuses spatial and temporal features; and it uses a gating mechanism to flexibly control the feature fusion process, ultimately outputting a noisy prediction result. When used in air quality monitoring scenarios, the data filling layer performs high-precision interpolation of missing data from monitoring stations caused by equipment failures, transmission interruptions, etc., restoring the spatiotemporal continuity of pollutant concentrations such as PM2.5 and ozone.
[0024] Compared with the prior art, the present invention has the following advantages: This invention maps auxiliary information into high-dimensional feature-based positional codes, and uses a joint temporal clustering module to mine multi-channel long-distance temporal dependencies; it constructs a collaborative architecture for noise prediction, embedding, and feature extraction modules, and leverages convolutional neural networks and iTransformer technology to achieve deep capture of spatiotemporal data features; specifically: This invention performs high-dimensional feature processing on auxiliary information through an Embedding Layer to generate position codes suitable for model input, and combines a temporal clustering module to extract multi-channel and long-distance temporal dependencies.
[0025] This invention constructs a noise prediction module, an embedding module, and a feature extraction module. It utilizes convolutional neural networks and iTransformer technology to acquire spatiotemporal data features and performs noise prediction based on the acquired information.
[0026] This invention designs a multi-layer loss function, and by optimizing the noise prediction effect of each layer, the model's predicted data is closer to the real data. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 This is a flowchart of the method of the present invention.
[0029] Figure 2 This is a flowchart illustrating the missing value filling method of the present invention.
[0030] Figure 3 This is a flowchart for data filling in the present invention.
[0031] Figure 4 This is a diagram showing the results of data filling using the method described in this invention. Detailed Implementation
[0032] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] like Figure 1-3 As shown, the present invention provides a method for filling in the spatiotemporal data gaps in an air quality detection system, comprising the following steps: S1. Real-time data acquisition: Real-time image acquisition of the area corresponding to the selected data source using a high-definition camera. The acquired image data is quickly and stably transmitted to the server, thereby constructing a real-time dataset to provide accurate and timely data for subsequent image anomaly detection.
[0035] S11. Obtain the current time t in different regions, collect the air quality index of the selected data source area through sensors at regular intervals, and transmit it stably to the server to form the original dataset; S12. Based on the original dataset of S11, missing values are marked by a mask matrix M (M=0 indicates missing), and the missing types (random point missing, continuous block missing, or large-scale missing due to sensor failure) are analyzed.
[0036] S13. In addition to processing the raw data, it is also necessary to calculate the geographical distance based on the latitude and longitude coordinates of the monitoring station and construct the adjacency matrix A.
[0037] S2. Preprocess the obtained dataset to obtain incomplete observation data X, adjacency matrix A, and missing value Mask. Based on the obtained data samples, perform basic initialization of the parameters of the constructed diffusion probability model, including its diffusion step size and sampling latent variable values. Construct a noise prediction module. During spatiotemporal interpolation, based on conditional information, gradually convert random noise into spatiotemporally consistent missing values. Using noise samples, conditional information, and the adjacency matrix as input, predict the impact of noise samples added during the diffusion process on the original spatiotemporal data to restore the original information of the noise samples.
[0038] S21. First, randomly generate our diffusion step size t, t ~ (0, num_steps). Generate random noise with the same shape as the original observation data, and use the diffusion process formula to calculate the noisy data noise_data when the diffusion step size is t.
[0039] S22. Integrate temporal embedding, feature embedding, and mask information into side information (side_info), and input it into the noise prediction model. The model captures global dependencies across time steps and feature dimensions through self-attention mechanisms or convolutional operations, and outputs predicted noise (shape (B, K, L)), achieving attention-weighted extraction of global features and strengthening the feature representation of key regions.
[0040] S23. Construct the input for the noise prediction model. For a conditional noise prediction model, the product of `cond_mask` and `observed_data` is used as the observation part, and the product of `(1-cond_mask)` and `noisy_data` is used as the noisy target part. These are concatenated and used as input. For an unconditional noise prediction model, `noisy_data` is used directly as input. The input and additional information `side_info` are then passed to the noise prediction model to obtain the predicted noise.
[0041] S3. To obtain more efficient imputation values, we constructed a noise prediction model by introducing the iTransformer module. After comprehensively considering the spatiotemporal data, we used iTransformer to label independent time series and utilized its self-attention mechanism to capture multivariate correlations in the spatiotemporal data. Through a feedforward network module, we learned a better global representation. In experiments, this significantly improved the model's overall perception of the spatiotemporal data.
[0042] S31. Construct a noise prediction module based on a diffusion model. First, interpolate the observed values to obtain enhanced coarse conditional information. Design a conditional feature extraction module to model spatiotemporal correlations from the coarse interpolation information. In the designed noise estimation module, utilize the output of the conditional feature extraction module to calculate attention weights, providing a better global contextual prior for spatiotemporal dependency learning.
[0043] S32. The conditional information is modeled separately, and the conditional information X and noise information Xt are used as inputs. The observed values of conditional feature extraction are enhanced. The enhanced information is used to learn the spatiotemporal dependence. Linear interpolation is used on the spatiotemporal data sequence of each node to construct preliminary effective interpolation conditional information for noise reduction, while preserving a certain degree of spatiotemporal consistency.
[0044] S33. Use 1×1 convolution to extract basic features and convert the interpolation condition information X into a feature matrix. Where N is the number of nodes, L is the time step, and C is the channel size. Convolutional operations compress the feature dimension while preserving the local correlations of spatiotemporal data, preparing for subsequent attention mechanisms and model processing.
[0045] To address the nonlinear relationships and spatial correlations in spatiotemporal data, a learnable module γ(·) is introduced. Module γ(·) takes the interpolated conditional information X and the adjacency matrix A as input, extracts the spatiotemporal dependencies from X, and outputs Hpri as the global context for calculating the spatiotemporal attention weights in noise prediction. Conditional features It is obtained through Hpri=γ(H,A), where H=Conv(X) and Conv(·) is a 1×1 convolution. And d is the channel size. The conditional feature extraction module γ(·) comprehensively combines spatiotemporal global correlation and geographic dependence.
[0046] S34. Utilize special mechanisms in the evaluation module to reduce the impact of sampling noise and capture spatiotemporal global correlations and spatial information; S341. The module input consists of two parts: one part is noise information, which is composed of observable data of X and noise samples Xt; the other part is conditional features H. pri Prior information about the adjacency matrix A; learning temporal features H through the time-dependent learning module γT(·). tem The temporal features are aggregated using the spatial dependency learning module γS(·), as shown in the following formula:
[0047]
[0048] S342. When the diffusion step size t is close to T, change the inputs of the attention components Attntem(·) and Attnspa(·) and calculate the attention weights by using the conditional feature Hpri. S343. Construct the attention key Attntem() using iTransformer; S344. Treat each time series in the dataset as a whole as a token, and learn the features of each feature variable based on each time series. The process is as follows:
[0049]
[0050] in, : N embedding tokens with dimension D, where the superscript indicates the layer index; Defined as follows: Perform a transpose operation, which can be implemented using an MLP. The following definition applies: the acquired variable tokens interact through self-attention and are processed independently by the shared feedforward network in each individual TrmBlock; S345. Based on the self-attention mechanism, the transposed model treats the entire sequence of a variable as an independent process; specifically, it utilizes each time series... The self-attention module uses linear projection to obtain queries, keys, and values. , where d k It is the projected size; S346, based on and Calculate spatial dependencies using projection parameters right and Perform a linear transformation to obtain Its spatial attention weights are as follows:
[0051] Using Graph Neural Networks (MPNN) combined with Adjacency Matrix A to obtain geographic dependency features Furthermore, by integrating spatial attention mechanisms and graph neural network features, spatial features are generated using MLP. .
[0052] S35. Use the time clustering module to perform feature extraction and fusion processing on the conditional information.
[0053] S351: Processing of supplementary information. The main supplementary information includes a time-encoded Utem and a node embedding Uspa representing the spatial attributes of the node. After expanding and concatenating the two, auxiliary information is generated through MLP. ; The formal representation is as follows: The timestamp is converted into a time-encoded tensor of dimension (B, L, emb_time_dim) using the time_embedding function, where emb_time_dim is the time embedding dimension; the target dimension is embedded using the embed_layer function to generate a feature embedding tensor of dimension (K, feature_emb_dim), where feature_emb_dim is the feature embedding dimension; then, the feature embedding tensor is expanded to (B, L, K, feature_emb_dim) to match the batch size and time step. S352: The additional information is merged into (B*side_dim, K, L) to make each channel independent, using the Channel-Independent strategy to model each channel separately; after processing, the clustering module is used to distribute the processed information through the Distribution Router and the Linear-based PatternExtractor to extract temporal features, and finally the linear layer is used to map the features to the target dimension to obtain side_info that matches the input dimension.
[0054] S4. Missing Value Imputation: Based on a pre-trained conditional diffusion model, this task involves imputing missing values in air quality monitoring data, improving the accuracy and reliability of the imputation process.
[0055] S41, Data imputation process: Provide noise samples, and use the noise prediction model to predict the noise to be added to the current noise sample by combining auxiliary information side_info and diffusion step size t.
[0056] S42. By generating multiple imputation samples to approximate the probability distribution of missing values, it is suitable for situations with high missing rates and sensor failure.
[0057] S5, based on S4, obtains the final filling result, outputs and saves it in formatted data form, and can generate a graphical interface.
[0058] This invention also provides a system for filling in the spatiotemporal data gaps in an air quality detection system, for realizing the filling of spatiotemporal data gaps in an air quality detection system, comprising: The system consists of a raw missing data processing layer, a diffusion model construction layer, a feature extraction layer, and a data imputation layer. The raw missing data processing layer is used to build the data features that the model can process, including raw observable data, missing value mask matrix, and missing rate setting.
[0059] The diffusion model building layer is used to build a complete diffusion model, including the initialization of diffusion process parameters and the setting of parameters for the reverse diffusion process, and to complete the data introduction.
[0060] The feature extraction layer captures the temporal dependencies and feature dependencies of the input data, enhancing the model's global context awareness. Spatial and temporal features are fused. A gating mechanism is used to flexibly control the feature fusion process, ultimately outputting a noisy prediction result.
[0061] When the trained data imputation module is applied to air quality monitoring scenarios, it can perform high-precision interpolation of missing data from monitoring stations caused by equipment failures, transmission interruptions, etc., effectively restoring the spatiotemporal continuity of pollutant concentrations such as PM2.5 and ozone. This technology significantly improves the integrity and reliability of air quality data, not only enhancing the accuracy of historical data statistical analysis and providing more solid data support for pollution trend assessment and source apportionment, but also optimizing the stability of real-time monitoring systems, avoiding early warning delays or misjudgments due to missing data. Furthermore, it lays a high-quality data foundation for downstream tasks such as climate model calibration and air pollution health impact assessment.
[0062] Figure 4 The image shows the results of data imputation as described in this invention, for a time series sample containing all 36 features. Red crosses represent observed values, blue circles represent the actual target values to be imputed, and the median of the imputed value is represented by a line. Figure 4 The horizontal axis represents the time step, and the vertical axis represents the air quality index value.
[0063] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for filling in the spatiotemporal data gaps in an air quality detection system, characterized in that, Includes the following steps: S1. Real-time acquisition of air quality spatiotemporal data from multiple monitoring stations, construction of a time series dataset containing pollutant concentrations based on the air quality spatiotemporal data, and simultaneous generation of a mask matrix identifying missing data locations and an adjacency matrix reflecting the spatial relationships between stations. S2. Based on time series data, mask matrix and adjacency matrix, initialize the parameters of the diffusion probability model, construct a noise prediction model with noise samples, conditional features and adjacency matrix as input, and train the noise prediction network to learn to predict the added noise with mask matrix, adjacency matrix and time embedding information as conditions. Optimize and obtain the trained noise prediction model by minimizing the loss function between the predicted noise and the real noise. S3. The iTransformer module is introduced to enhance the trained noise prediction model. The time series of each variable is used as a label, multivariate spatiotemporal correlation is extracted through self-attention mechanism, and the global feature representation capability is improved by using a feedforward network to obtain the enhanced noise prediction model. S4. Perform data imputation based on the enhanced noise prediction model, gradually restore missing values through a reverse diffusion process, and generate multiple imputation samples to estimate the probability distribution of missing values.
2. The method for filling in the spatiotemporal data gaps in the air quality detection system according to claim 1, characterized in that, S1 specifically includes the following steps: S11. Obtain the current time t in different regions, collect air quality index data of the selected data source area through sensors at regular intervals, and transmit the air quality index data to the server to form the original spatiotemporal dataset. S12. Based on the original spatiotemporal dataset, the missing values in the original dataset are marked by the mask matrix M, and the missing value type is analyzed. The missing value type includes random point missing, continuous block missing, or large-scale missing caused by sensor failure. S13. Calculate the geographical distance between each monitoring station based on the latitude and longitude coordinates of the monitoring stations, and construct the adjacency matrix A.
3. The method for filling in the spatiotemporal data gaps in the air quality detection system according to claim 1, characterized in that, S2 specifically includes the following steps: S21. Randomly generate a diffusion step size t; generate random noise with the same shape as the observed data, and calculate the noisy data noise_data with a diffusion step size t using a Markov chain during the forward process; the Markov chain calculation formula is as follows: in, It is the raw data. This is the data after adding noise, where T is the step size. It is a minimal positive constant representing the noise level, and I represents an identity matrix; S22. Integrate temporal embedding, feature embedding, and mask information into side information side_info, and input the side information into the noise prediction model; the noise prediction model captures global dependencies across time steps and feature dimensions through self-attention mechanisms or convolutional operations, and outputs predicted noise; S23. Construct the input for the noise prediction model. The conditional noise prediction model uses the product of cond_mask and observed_data as the observation part, and the product of (1-cond_mask) and noisy_data as the noisy target part, and concatenates them as the input. The unconditional noise prediction model directly uses noisy_data as the input. Pass the input and additional information side_info into the noise prediction model to obtain the predicted noise. S24. The input spliced data and side information are processed by the diffusion model. The predicted noise is obtained by combining the current diffusion step size. The region to be filled is determined by the difference between the original observation mask and the conditional mask. The sum of squared residuals in the region is calculated and normalized to obtain the loss value used for model optimization.
4. The method for filling in the spatiotemporal data gaps in the air quality detection system according to claim 1, characterized in that, S3 specifically includes the following steps: S31. Interpolate the observed values to construct coarse conditional information, and design a conditional feature extraction module to model the spatiotemporal correlation from the coarse interpolation information; S32. The conditional information is modeled separately, and the conditional information X and noise information Xt are used as inputs to enhance the observed values of conditional feature extraction. Linear interpolation is used for the spatiotemporal data sequence of each node to construct preliminary effective interpolation conditional information for noise reduction. S33. Use 1×1 convolution to extract basic features and convert the interpolation condition information X into a feature matrix. Where N is the number of nodes, L is the time step, and C is the channel size; the feature dimension is compressed through convolution operation while preserving the local correlation of spatiotemporal data; For nonlinear relationships and spatial correlations in spatiotemporal data, a conditional feature extraction module γ(·) is involved. The conditional feature extraction module γ(·) takes the interpolated conditional information X and the adjacency matrix A as input, extracts the spatiotemporal dependency from X, and outputs Hpri as the global context for calculating the spatiotemporal attention weights in noise prediction. Conditional features This is obtained through Hpri = γ(H, A), where H = Conv(X) and Conv(·) is a 1 × 1 convolution. And d is the channel size; The conditional feature extraction module γ(·) comprehensively combines spatiotemporal global correlation and geographic dependence, as follows: Where Attn(·) represents global attention, spa represents spatial attention, tem represents temporal attention, and MPNN(·) represents spatial message passing neural network; S34. Utilize special mechanisms in the evaluation module to reduce the impact of sampling noise and capture spatiotemporal global correlation and spatial information; S35. Use the time clustering module to perform feature extraction and fusion processing on the conditional information.
5. The method for filling in the spatiotemporal data gaps in the air quality detection system according to claim 4, characterized in that, S34 specifically includes the following steps: S341. The module input consists of two parts: one part is noise information, which is composed of observable data of X and noise samples Xt; the other part is conditional features H. pri Prior information about the adjacency matrix A; learning temporal features H through the time-dependent learning module γT(·). tem The temporal features are aggregated using the spatial dependency learning module γS(·), as shown in the following formula: S342. When the diffusion step size t is close to T, change the inputs of the attention components Attntem(·) and Attnspa(·) and calculate the attention weights by using the conditional feature Hpri. S343. Construct the attention key Attntem() using iTransformer; S344. Treat each time series in the dataset as a whole as a token, and learn the features of each feature variable based on each time series. The process is as follows: in, : N embedding tokens with dimension D, where the superscript indicates the layer index; Defined as follows: Perform a transpose operation, which can be implemented using an MLP. The following definition applies: the acquired variable tokens interact through self-attention and are processed independently by the shared feedforward network in each individual TrmBlock; S345. Based on the self-attention mechanism, the transposed model treats the entire sequence of a variable as an independent process; specifically, it utilizes each time series... The self-attention module uses linear projection to obtain queries, keys, and values. , where d k It is the projected size; S346, based on and Calculate spatial dependencies using projection parameters right and Perform a linear transformation to obtain Its spatial attention weights are as follows: Using Graph Neural Networks (MPNN) combined with Adjacency Matrix A to obtain geographic dependency features Furthermore, by integrating spatial attention mechanisms and graph neural network features, spatial features are generated using MLP. .
6. The method for filling in the spatiotemporal data gaps in the air quality detection system according to claim 1, characterized in that, S35 specifically includes the following steps: S351: Processing of supplementary information. The main supplementary information includes a time-encoded Utem and a node embedding Uspa representing the spatial attributes of the node. After expanding and concatenating the two, auxiliary information is generated through MLP. ; The formal representation is as follows: The timestamp is converted into a time-encoded tensor of dimension (B, L, emb_time_dim) using the time_embedding function, where emb_time_dim is the time embedding dimension; the target dimension is embedded using the embed_layer function to generate a feature embedding tensor of dimension (K, feature_emb_dim), where feature_emb_dim is the feature embedding dimension; then, the feature embedding tensor is expanded to (B, L, K, feature_emb_dim) to match the batch size and time step. S352: The additional information is merged into (B*side_dim, K, L) in one dimension, so that each channel is processed independently. The Channel-Independent strategy is used to model each channel separately. After processing, the clustering module is used to distribute the processed information through the Distribution Router and the Linear-based Pattern Extractor to extract the temporal features. Finally, the linear layer is used to map the features to the target dimension to obtain the side_info that matches the input dimension.
7. The method for filling in the spatiotemporal data gaps in the air quality detection system according to claim 1, characterized in that, S4 specifically includes the following steps: S41, Data imputation process: Provide noise samples, and use the noise prediction model to predict the noise to be added to the current noise sample by combining auxiliary information side_info and diffusion step size t; S42. By generating multiple imputation samples to approximate the probability distribution of missing values, it is suitable for situations with high missing rates and sensor failure.
8. A system for filling in the spatiotemporal data gaps in an air quality detection system, used to implement the method for filling in the spatiotemporal data gaps in the air quality detection system according to any one of claims 1-7, characterized in that, It includes a raw missing data processing layer, a diffusion model construction layer, a feature extraction layer, and a data imputation layer; The raw missing data processing layer is used to build the data features that the model can process, including raw observable data, missing value mask matrix and missing rate setting; The diffusion model construction layer is used to build a complete diffusion model, including the initialization of diffusion process parameters and the setting of parameters for the inverse diffusion process, and to complete the data introduction. The feature extraction layer is used to capture the temporal dependencies and feature dependencies of the input data, enhancing the model's global context awareness; it fuses spatial and temporal features; and it uses a gating mechanism to flexibly control the feature fusion process, ultimately outputting a noisy prediction result. When used in air quality monitoring scenarios, the data filling layer performs high-precision interpolation of missing data from monitoring stations caused by equipment failures, transmission interruptions, etc., restoring the spatiotemporal continuity of pollutant concentrations such as PM2.5 and ozone.