Air quality forecasting methods and procedures products
By constructing an air quality prediction model and combining environmental and meteorological monitoring data, the air quality impact information is dynamically adjusted, which solves the problem of insufficient accuracy in air quality prediction and achieves simultaneous and efficient prediction for multiple target areas.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 3CLEAR SCI & TECH CO LTD
- Filing Date
- 2026-01-04
- Publication Date
- 2026-04-24
AI Technical Summary
Existing technologies for air quality prediction lack accuracy and cannot effectively reflect the dynamic changes in the direction of air pollutant transport, resulting in inaccurate prediction results.
By acquiring environmental and meteorological monitoring data from multiple target areas, the air quality impact information is dynamically adjusted. An air quality prediction model is constructed using the Transformer and prediction modules, taking into account the mutual influence between different target areas, and synchronous prediction of air quality data is performed.
It improves the accuracy of air quality forecasts, can output air quality data for various target areas simultaneously, and takes into account the dynamic changes in meteorological monitoring data and the influence of pollutant transport direction, thus enhancing the overall forecast performance.
Smart Images

Figure CN121434673B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of air monitoring technology, and more specifically, to an air quality prediction method and program product. Background Technology
[0002] Air quality forecasting predicts the concentration of air pollutants at future times. Air pollutants include various types, such as PM2.5 (particulate matter with a diameter of 2.5 micrometers or less), PM10 (particulate matter with a diameter of 10 micrometers or less), NO2 (nitrogen dioxide), SO2 (sulfur dioxide), CO (carbon monoxide), and O3 (ozone). Accurate air quality forecasting is crucial for environmental management, public health early warning, and joint prevention and control of air pollution. However, the accuracy of air quality forecasts using relevant technologies needs improvement. Summary of the Invention
[0003] The purpose of this disclosure is to provide an air quality forecasting method and program product that improves the accuracy of air quality data forecasting and can simultaneously forecast and output air quality data for various target areas.
[0004] To achieve the above objectives, in a first aspect, this disclosure provides an air quality prediction method, the method comprising:
[0005] Acquire first environmental monitoring data for each of multiple target areas. The first environmental monitoring data for each target area includes air quality data and meteorological monitoring data for the target area at multiple first moments. The multiple first moments include each moment from time T-N+1 to time T.
[0006] For each target area, based on meteorological monitoring data of other target areas outside the target area at the plurality of first moments, first air quality impact information of the target area at each first moment is determined. The first air quality impact information is used to indicate a preset number of first areas that have the greatest impact on the air quality of the target area at the first moment.
[0007] The first air quality impact information and the first environmental monitoring data are input into the target air quality prediction model to obtain the air quality data of each of the multiple target areas at time T+1, which are output by the target air quality prediction model.
[0008] Optionally, the meteorological monitoring data includes wind speed and wind direction; the step of determining the first air quality impact information of the target area at each of the multiple first time moments based on meteorological monitoring data of other target areas outside the target area at the multiple first time moments includes:
[0009] For each first moment, the influence distance of the other target areas on the air quality of the target area at the first moment is determined based on the cosine of the included angle, the wind speed of the other target areas at the first moment, and the preset air pollutant propagation distance. The included angle is determined based on the wind direction of the other target areas at the first moment and the orientation of the target area relative to the other target areas. Based on the influence distance and the spherical distance between the other target areas and the target area, the degree of influence of the other target areas on the air quality of the target area at the first moment is determined. The preset number of other target areas with the highest degree of influence are designated as the first area corresponding to the target area at the first moment.
[0010] Optionally, if the influence distance is greater than or equal to the spherical distance, the degree of influence is a target value;
[0011] When the influence distance is less than the spherical distance, the degree of influence is less than the target value, and the greater the difference between the spherical distance and the influence distance, the smaller the degree of influence.
[0012] Optionally, the target air quality prediction model includes a first Transformer module, a second Transformer module, and a prediction module. The first Transformer module is used to generate first feature information based on the first air quality impact information. The second Transformer module is used to generate second feature information based on the encoded feature information corresponding to the plurality of first times and the first feature information. The prediction module is used to generate air quality data of the plurality of target areas at time T+1 based on the second feature information.
[0013] Optionally, the first Transformer module is used to generate the first feature information based on a multi-head self-attention mechanism in the following manner:
[0014] Based on the characteristic information of the first environmental monitoring data of each of the multiple target areas, the third characteristic information is obtained;
[0015] Based on the first air quality impact information, fourth feature information is generated. The fourth feature information corresponding to the target area at the first time is obtained by splicing the following feature information: feature information of the first environmental monitoring data of the first area corresponding to the target area at the first time, feature information of the spherical distance between the target area and the first area, and feature information of the azimuth angle of the first area relative to the target area.
[0016] For each attention head in the first Transformer module, first query information is obtained based on the third feature information and the query weight matrix of the attention head; first key information is obtained based on the fourth feature information and the key weight matrix of the attention head; first value information is obtained based on the fourth feature information and the value weight matrix of the attention head; and the attention calculation result corresponding to the attention head is determined based on the first query information, the first key information, and the first value information.
[0017] The attention calculation results of each attention head in the first Transformer module are concatenated to obtain the first target attention calculation result, and the first feature information is generated based on the first target attention calculation result.
[0018] Optionally, determining the attention calculation result corresponding to the attention head based on the first query information, the first key information, and the first value information includes:
[0019] Based on the first air quality impact information, fifth feature information is generated, wherein the fifth feature information corresponding to the target area at the first time is generated based on the following information: the influence distance of the first region corresponding to the target area on the air quality of the target area at the first time.
[0020] Based on the first query information, the first key information, the first value information, and the fifth feature information, the attention calculation result corresponding to the attention head is determined.
[0021] Optionally, the second Transformer module is used to generate the second feature information based on a multi-head self-attention mechanism in the following manner:
[0022] Based on the encoded feature information corresponding to the plurality of first time points respectively, and the first feature information, the sixth feature information is obtained, wherein the sixth feature information corresponding to the target region at the first time point is obtained by adding the first feature information corresponding to the target region at the first time point to the encoded feature information at the first time point;
[0023] For each attention head in the second Transformer module, second query information is obtained based on the sixth feature information and the query weight matrix of the attention head; second key information is obtained based on the sixth feature information and the key weight matrix of the attention head; second value information is obtained based on the sixth feature information and the value weight matrix of the attention head; and the attention calculation result corresponding to the attention head is determined based on the second query information, the second key information, and the second value information.
[0024] The attention calculation results of each attention head in the second Transformer module are concatenated to obtain the second target attention calculation result, and the second feature information is generated based on the second target attention calculation result.
[0025] Optionally, the target air quality prediction model is trained in the following manner:
[0026] Acquire training samples, which include second environmental monitoring data for each of the plurality of target areas, and air quality data for each of the target areas at a specified time. The second environmental monitoring data for the target areas includes air quality data and meteorological monitoring data for the target areas at N second times.
[0027] For each target area, based on meteorological monitoring data of other target areas outside the target area at N second times, second air quality impact information of the target area at each second time is determined. The second air quality impact information is used to indicate a preset number of other target areas that have the greatest impact on the air quality of the target area at the second time.
[0028] The second air quality impact information and the second environmental monitoring data of each of the multiple target areas are input into the air quality prediction model to obtain the air quality data of each of the target areas predicted by the air quality prediction model at the specified time.
[0029] Based on the air quality data of each of the marked target areas at the specified time, and the predicted air quality data of each of the target areas at the specified time, target difference information is determined;
[0030] If the target difference information satisfies the training stopping condition, then the target air quality prediction model that has been trained is obtained.
[0031] Optionally, the air quality data includes the concentrations of various air pollutants; determining the target difference information based on the air quality data of each of the labeled target areas at the specified time and the predicted air quality data of each of the target areas at the specified time includes:
[0032] For each of the air pollutants, prediction difference information for the air pollutants is determined based on the concentration of the air pollutants in each of the marked target areas at the specified time and the predicted concentration of the air pollutants in each of the target areas at the specified time.
[0033] The target difference information is determined based on the preset weights corresponding to the various air pollutants and the predicted difference information.
[0034] In a second aspect, this disclosure provides a computer program product, including a computer program, characterized in that, when executed by a processor, the computer program implements the steps of the air quality prediction method provided in the first aspect of this disclosure.
[0035] Through the above technical solution, since meteorological monitoring data for the same target area varies at different times, this solution considers the dynamic changes in meteorological monitoring data. Based on meteorological monitoring data from other target areas outside the target area at multiple first moments, it determines the first air quality impact information for each target area at each first moment. This first air quality impact information is used to indicate a preset number of first areas that have the greatest impact on the air quality of the target area at the first moment. This ensures that the first air quality impact information at each first moment is adaptively adjusted according to the dynamic changes in meteorological monitoring data. Furthermore, when predicting air quality data, the target air quality prediction model can refer to the first air quality impact information obtained from meteorological monitoring data, thereby considering the mutual influence between different target areas and simultaneously predicting and outputting the air quality data for each target area.
[0036] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0037] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0038] Figure 1 This is a flowchart illustrating an exemplary air quality prediction method.
[0039] Figure 2 This is a schematic diagram of an exemplary target air quality prediction model.
[0040] Figure 3 This is a flowchart illustrating an exemplary method by which the first Transformer module generates first feature information.
[0041] Figure 4 This is a flowchart illustrating an exemplary method for the second Transformer module to generate second feature information.
[0042] Figure 5 This is a flowchart illustrating the training process of a target air quality prediction model.
[0043] Figure 6 This is a block diagram illustrating a first electronic device according to an exemplary embodiment.
[0044] Figure 7 This is a block diagram illustrating a second electronic device according to an exemplary embodiment. Detailed Implementation
[0045] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0046] Among related technologies, some employ air quality prediction models based on Graph Convolutional Networks (GCNs). For example, in a GCN, each node represents an air quality monitoring station, and the edge weights are typically Gaussian-weighted based on the geographical distance between stations—the closer the stations, the higher the weight—forming a static adjacency matrix. However, this approach has certain problems. The adjacency matrix is fixed based on geographical distance, but the direction of air pollutant transport changes. A fixed adjacency matrix cannot reflect the impact of these dynamic changes in pollutant transport direction, maintaining a fixed spatial weight based on geographical distance, resulting in low accuracy in air quality prediction.
[0047] This disclosure provides an air quality forecasting method and program product to improve the accuracy of air quality forecasting.
[0048] Figure 1 This is a flowchart illustrating an air quality prediction method, which can be applied to electronic devices, such as terminal devices or servers. Figure 1 As shown, the air quality prediction method may include steps 11 to 13.
[0049] Step 11: Obtain the first environmental monitoring data for each of the multiple target areas.
[0050] The number of target areas is denoted by, for example, C, where C is a positive integer greater than 1. Any two target areas may not overlap spatially. For example, a target area may be a city, which can be a county-level city or a prefecture-level city. In this embodiment of the disclosure, multiple target areas may be all cities nationwide, meaning that this disclosure can achieve synchronous prediction of air quality in all cities across the country.
[0051] It should be noted that in the following examples, the target area is explained as a city, but the division of the target area is not limited to this. For example, multiple target areas can be multiple areas that need to be predicted for air quality according to certain rules, such as grid areas. There is no limit to the size of the target area.
[0052] The primary environmental monitoring data for the target area includes air quality data and meteorological monitoring data for the target area at multiple time points.
[0053] Air quality data can include the concentrations of various air pollutants, such as PM2.5, PM10, NO2, SO2, CO, and O3. Air quality data can be obtained from data released by environmental monitoring stations.
[0054] Meteorological monitoring data may include wind speed, wind direction, temperature, humidity, air pressure, precipitation, etc. This data can come from meteorological monitoring stations or reanalysis datasets. The reanalysis dataset can be the ERA5 reanalysis dataset, which refers to the European Centre for Medium-Range Weather Forecasts' fifth-generation atmospheric reanalysis dataset.
[0055] The multiple first moments include each moment from time T-N+1 to time T, for a total of N moments, where N is a positive integer greater than 1. In one embodiment, time T can be the current moment, and times T-N+1 to T-1 can be historical moments. The air quality data and meteorological monitoring data of the target area at the multiple first moments can all be actual monitored data. Time T+1 is a future moment, i.e., the air quality prediction in this disclosure aims to predict the air quality data of each of the multiple target areas at time T+1 based on the actual air quality data and meteorological monitoring data of the multiple target areas from time T-N+1 to time T.
[0056] There is no restriction on the time interval between two adjacent moments; for example, the interval between two adjacent moments can be 1 hour.
[0057] Step 12: For each target area, based on the meteorological monitoring data of other target areas outside the target area at multiple first moments, determine the first air quality impact information of the target area at each first moment.
[0058] The first air quality impact information is used to indicate a preset number of first areas that have the greatest impact on the air quality of the target area at a first moment. These preset number of first areas are the same as the preset number of other target areas. Hereinafter, M represents the preset number, where M is a positive integer greater than 1 and less than C.
[0059] Meteorological monitoring data can include wind speed and direction. Wind speed and direction have a direct impact on the direction and trajectory of air pollutant transport. For example, if target area A is north of target area B and target area C is south of target area B, when the wind direction in target area B is southerly (wind blowing from south to north), then the air pollutants in target area B will move with the wind. Therefore, target area B has a greater impact on the air quality of target area A, but a smaller impact on the air quality of target area C.
[0060] In this way, meteorological monitoring data from other target areas can reflect the direction of air pollutant transport and the trajectory of movement in other target areas, thereby identifying areas that have a greater impact on the air quality of the target area based on meteorological monitoring data from other target areas.
[0061] Because meteorological monitoring data changes at different times for the same target area, taking target area A as an example, at time T-1, target area B has a relatively large influence on target area A, while at time T, due to changes in wind direction, target area B has a smaller influence on target area A, while target area D has a relatively larger influence on target area A.
[0062] Therefore, in this disclosure, considering the dynamic changes of meteorological monitoring data, the first air quality impact information of the target area at each first moment is determined respectively, so that the first air quality impact information at each first moment is adaptively adjusted with the dynamic changes of meteorological monitoring data.
[0063] Step 13: Input the first air quality impact information and the first environmental monitoring data into the target air quality prediction model to obtain the air quality data of each of the multiple target areas at time T+1 output by the target air quality prediction model.
[0064] The target air quality prediction model can be a pre-trained model. In this disclosure, the target air quality prediction model can simultaneously predict the air quality data of multiple target areas at time T+1. When the multiple target areas are all cities nationwide, the target air quality prediction model can output the synchronously predicted air quality data of all cities nationwide.
[0065] On the one hand, it can simultaneously predict and output air quality data for each target area, improving overall prediction performance. On the other hand, compared to related technologies where one prediction model corresponds to one region, meaning the prediction model can only predict air quality data for that one region, the target air quality prediction model in this disclosure can refer to the first air quality impact information obtained based on meteorological monitoring data, thereby considering the impact of meteorological monitoring data on the direction of pollutant transport, as well as the mutual influence between different target areas, improving the accuracy of air quality data prediction.
[0066] Through the above technical solution, since meteorological monitoring data for the same target area varies at different times, this solution considers the dynamic changes in meteorological monitoring data. Based on meteorological monitoring data from other target areas outside the target area at multiple first moments, it determines the first air quality impact information for each target area at each first moment. This first air quality impact information is used to indicate a preset number of first areas that have the greatest impact on the air quality of the target area at the first moment. This ensures that the first air quality impact information at each first moment is adaptively adjusted according to the dynamic changes in meteorological monitoring data. Furthermore, when predicting air quality data, the target air quality prediction model can refer to the first air quality impact information obtained from meteorological monitoring data, thereby considering the mutual influence between different target areas and simultaneously predicting and outputting the air quality data for each target area.
[0067] This disclosure describes the methods used to determine the extent of the impact of other target areas on the air quality of the target area.
[0068] For example, if the meteorological monitoring data includes wind speed and wind direction, step 12 may include:
[0069] For each first moment, the influence distance of other target areas on the air quality of the target area at the first moment is determined based on the cosine value of the included angle, the wind speed of other target areas at the first moment, and the preset air pollutant propagation distance. Based on the influence distance and the spherical distance between other target areas and the target area, the degree of influence of other target areas on the air quality of the target area at the first moment is determined. The preset number of other target areas with the largest degree of influence are taken as the first area corresponding to the target area at the first moment.
[0070] The included angle is determined based on the wind direction of other target areas at the first moment and the orientation of the target area relative to the other target areas. For example, the direction of the first vector can be the direction the wind is blowing towards the other target areas at the first moment, i.e., where the wind is blowing towards the other target areas at the first moment. The second vector can be a vector pointing from the center point of the other target areas to the center point of the target area, representing the orientation of the target area relative to the other target areas. Both the first and second vectors can be vectors in the same plane coordinate system; therefore, the angle between the first and second vectors is the included angle mentioned above. Furthermore, wind direction refers to the direction from which the wind comes, i.e., the direction from which the wind blows. The direction from which the wind comes is opposite to the direction from which the wind blows.
[0071] Since the cosine of the included angle reflects the consistency between the direction of the wind blowing from other target areas and the orientation of the target area relative to other target areas at the first moment, the influence distance can be calculated using the cosine of the included angle. For example, if the included angle is 0, it means that at the first moment, the direction of the wind blowing from other target areas and the orientation of the target area relative to other target areas are completely consistent. In this case, the cosine of the included angle is 1, which represents this consistency.
[0072] In one embodiment, when the influence distance is greater than or equal to the spherical distance, the degree of influence is the target value; when the influence distance is less than the spherical distance, the degree of influence is less than the target value, and the greater the difference between the spherical distance and the influence distance, the smaller the degree of influence.
[0073] The influence distance of other target areas on the air quality of the target area can be understood as the distance that pollutants from other target areas can travel with the wind to the target area at the first moment, with the center point of the other target areas as the endpoint. If the influence distance is greater than or equal to the spherical distance between the two target areas, it means that the other target areas will have an impact on the air quality of the target area. If the influence distance is less than the spherical distance between the two target areas, it means that the other target areas have a certain impact on the air quality of the target area. Moreover, the greater the difference between the spherical distance and the influence distance, the smaller the degree of impact.
[0074] After determining the degree of influence of other target areas on the air quality of the target area at the first moment, the other target areas can be sorted from largest to smallest according to the degree of influence, and the other target areas in the top M positions can be determined.
[0075] The above technical solution, considering the direct impact of wind speed and direction on the transport direction and trajectory of air pollutants, determines the influence distance of other target areas on the air quality of the target area based on their wind speed and direction. By determining the influence distance and spherical distance, the degree of influence can be quantified, thus identifying the M primary regions with the greatest influence on the air quality of the target area. Considering the mutual influence between different target regions improves the accuracy of air quality data prediction.
[0076] The spherical distance between other target areas can be calculated using the Haversine formula (also known as the semi-versine formula) based on the longitude and latitude coordinates of the center points of the other target areas and the longitude and latitude coordinates of the center point of the target area.
[0077] The spherical distance between the i-th target region and the j-th target region It can be calculated using the following formula (1):
[0078] (1)
[0079] R is the Earth's radius. Let be the latitude coordinates of the center point of the i-th target region. Let J be the latitude coordinates of the center point of the j-th target region. for and The difference, for and The difference, Let be the longitude coordinates of the center point of the i-th target region. Let be the longitude coordinates of the center point of the j-th target region. In the formula, It represents the product.
[0080] For example, the distance of the influence of the air quality of the i-th target area on the j-th target area at time t. It can be calculated using the following formula (2):
[0081] (2)
[0082] This represents the preset air pollutant propagation distance, and the wind speed empirical coefficient, which can be a preset value, such as 10km, meaning that a wind speed of 3.6km / h corresponds to a pollutant propagation distance of approximately 10km. The value of 'b' is also a preset value, such as 0.1, which can be used to avoid the calculated distance result being 0 or negative. This represents the wind speed in the i-th target area at time t. The included angle is determined based on the wind direction of the i-th target area at time t and the orientation of the j-th target area relative to the i-th target area.
[0083] The degree of influence of the i-th target area on the air quality of the j-th target area at time t. It can be calculated using the following formula (3):
[0084] (3)
[0085] exp represents the natural exponential function. According to formula (3), in the influence distance... Greater than or equal to spherical distance In this case, the degree of impact The value is 1, which is the target value; the influence distance is... Less than spherical distance In this case, the degree of impact Less than 1, and the difference between the spherical distance and the influence distance The larger the size, the greater the impact. The smaller the value, the greater the impact, and the more the impact decreases exponentially with the increase of the distance difference.
[0086] Taking target region A as an example, the spherical distances between target region A and target regions B, C, D, E, F, G, H, I, and J can be calculated respectively. The same method applies to other target regions to calculate the spherical distance between each pair of target regions.
[0087] The calculation methods for the impact distance and impact degree can be found in the above description. Table 1 shows the impact distance (in km), and Table 2 shows the impact degree.
[0088] Table 1
[0089]
[0090] Table 2
[0091]
[0092] In Tables 1 and 2, the first row represents the target area, and the first column represents other target areas. For example, the data 169.3 in the second row and third column of Table 1 indicates that the influence distance of target area A on the air quality of target area B is 169.3 km. Similarly, the data 7.3 in the third row and second column of Table 1 indicates that the influence distance of target area B on the air quality of target area A is 7.3 km. In Table 1, the influence distance of a target area on itself is 0.
[0093] Taking the data 0.55 in the second row and third column of Table 2 as an example, it indicates that the influence of target area A on the air quality of target area B is 0.55. Taking the data 0 in the third row and second column of Table 2 as an example, it indicates that the influence of target area B on the air quality of target area A is 0. In Table 2, the influence of a target area on itself is 1. Some influence values of 0 in Table 2 are close to 0 and are represented by 0.
[0094] It should be noted that Tables 1 and 2 are examples of these target regions. In this embodiment, the influence of other target regions on target region I is 0. In this case, M other target regions can be randomly selected as the first region corresponding to target region I.
[0095] The target air quality prediction model in this disclosure is described below.
[0096] Figure 2 This is a schematic diagram of an exemplary target air quality prediction model, such as... Figure 2 As shown, the target air quality prediction model includes a first Transformer module, a second Transformer module, and a prediction module.
[0097] The first Transformer module generates first feature information based on first air quality impact information and transmits the first feature information to the second Transformer module. The second Transformer module generates second feature information based on the encoded feature information corresponding to multiple first time points and the first feature information, and transmits the second feature information to the second Transformer module. The prediction module generates air quality data for multiple target areas at time T+1 based on the second feature information.
[0098] Using the above technical solution, the first Transformer module can extract features from a spatial perspective and prioritize the downwind areas (i.e., the M primary areas that have the greatest impact on the air quality of the target area). The second Transformer module can extract features from a temporal perspective, focusing on the temporal sequence of time points from time T-N+1 to time T. The prediction module can simultaneously generate air quality data for multiple target areas.
[0099] It should be noted that the Transformer module is a neural network architecture based on the self-attention mechanism. The Transformer structure can contain multiple layers, each layer including a multi-head self-attention module (MHA), a feed-forward network (FFN), residual connections, and a layer normalization module. For the feed-forward network, residual connections, and layer normalization module, as well as the information transfer between multiple layers, refer to the Transformer computation methods in related technologies. The following sections provide a detailed introduction to the multi-head self-attention mechanism in the first and second Transformer modules.
[0100] In one embodiment, such as Figure 3 As shown, the first Transformer module is used to generate first feature information through steps 41 to 44 based on a multi-head self-attention mechanism.
[0101] Step 41: Obtain the third feature information based on the feature information of the first environmental monitoring data of each of the multiple target areas.
[0102] Taking the first environmental monitoring data of target area A at time T as an example, features can be extracted from the air quality data and meteorological monitoring data of target area A at time T, and the first environmental monitoring data of target area A at time T can be represented as D-dimensional feature information. The feature information of the first environmental monitoring data of other target areas and other times can be represented in the same way. D-dimensionality can represent the number of hidden features.
[0103] The size of the third feature information can be represented as N×C×D. In this disclosure, the size of the feature information can be understood as the features that the feature information includes. N represents the N times from time T-N+1 to time T, C represents the C target areas, and D represents the feature dimension. That is, the third feature information includes the feature information of the first environmental monitoring data of the C target areas at T times. For the first environmental monitoring data of a target area at a certain time, the size of the feature information is 1×D.
[0104] Step 42: Generate fourth feature information based on the first air quality impact information.
[0105] The fourth feature information corresponding to the target area at the first moment is obtained by splicing the following feature information: feature information of the first environmental monitoring data of the first area corresponding to the target area at the first moment, feature information of the spherical distance between the target area and the first area, and feature information of the azimuth angle of the first area relative to the target area.
[0106] For a specific first region, the concatenation of feature information can be represented as follows: . This represents the first region corresponding to the i-th target region at time t. This represents the feature information of the first environmental monitoring data of the first region corresponding to the i-th target region at time t. The size of this feature information is 1×D. Feature information representing the spherical distance between the target region and the first region. This represents the azimuth information of the first region relative to the target region. The size of the stitched feature information is 1×(D+2).
[0107] At the first time step, the number of first regions corresponding to the target region is M, and the size of the fourth feature information can be N×C×M×(D+2). At a certain first time step, the size of the fourth feature information corresponding to the next target region is M×(D+2).
[0108] Step 43: For each attention head in the first Transformer module, obtain the first query information based on the third feature information and the query weight matrix of the attention head; obtain the first key information based on the fourth feature information and the key weight matrix of the attention head; obtain the first value information based on the fourth feature information and the value weight matrix of the attention head; and determine the attention calculation result corresponding to the attention head based on the first query information, the first key information, and the first value information.
[0109] In the first Transformer module, the number of attention heads in the self-attention module is, for example, h, where d represents the dimension of the features of each attention head, and the product of h and d is D. For each attention head in the first Transformer module, the dot product of the third feature information and the query weight matrix of the attention head is taken as the first query information Q1, the dot product of the fourth feature information and the key weight matrix of the attention head is taken as the first key information K1, and the dot product of the fourth feature information and the value weight matrix of the attention head is taken as the first value information V1.
[0110] In the first Transformer module, the size of the query weight matrix Wq for each attention head can be D×d, the size of the key weight matrix Wk for each attention head can be (D+2)×d, and the size of the value weight matrix Wv for each attention head can be (D+2)×d. When performing the dot product operation, the feature information of a target region at a certain time step can be used as the granularity for the dot product operation with the weight matrix.
[0111] During the model usage phase, the query weight matrix, key weight matrix, and value weight matrix for each attention head in the first and second Transformer modules are determined when the model training is completed.
[0112] In one embodiment, the method for determining the attention calculation result corresponding to the attention head based on the first query information, the first key information, and the first value information can be as follows:
[0113] Based on the first air quality impact information, the fifth feature information is generated; based on the first query information, the first key information, the first value information, and the fifth feature information, the attention calculation result corresponding to the attention head is determined.
[0114] The fifth feature information corresponding to the target area at the first moment is generated based on the following information: the influence distance of the first region corresponding to the target area on the air quality of the target area at the first moment.
[0115] For example, at time t, the first region corresponding to the i-th target region includes the j-th target region, according to The following formula (4) can be used to calculate , It can be regarded as the spatial prior bias information of the first region corresponding to the i-th target region at time t.
[0116] (4)
[0117] This is a preset minimum value used to prevent the logarithm from becoming meaningless. The size of the fifth feature information can be N×C×M. The size of the fifth feature information corresponding to the next target region at a certain time is 1×M.
[0118] The attention calculation result of the attention head in the first Transformer module can be determined by the following formula (5). :
[0119] (5)
[0120] in, This represents the fifth feature information. d represents the number of dimensions.
[0121] Step 44: Concatenate the attention calculation results of each attention head in the first Transformer module to obtain the first target attention calculation result, and generate the first feature information based on the first target attention calculation result.
[0122] In the first Transformer module, the size of the attention calculation result of each attention head is N×C×d, and the size of the first target attention calculation result obtained by splicing is N×C×D.
[0123] The first target attention calculation result is processed by residual connection, layer normalization module and feedforward neural network to obtain the first feature information, the size of the first feature information is N×C×D.
[0124] In this way, the influence distance can reflect the influence of the first region on the target region from a spatial perspective. When calculating attention, the influence distance of the first region on the air quality of the target region is considered. Furthermore, the characteristic information of the spherical distance between the target region and the first region, as well as the characteristic information of the azimuth angle of the first region relative to the target region, can also reflect the spatial characteristics between the first region and the target region. Therefore, the first Transformer module can achieve priority attention to the downwind region from a spatial perspective.
[0125] In one embodiment, such as Figure 4As shown, the second Transformer module is used to generate second feature information through steps 51 to 53 based on a multi-head self-attention mechanism.
[0126] Step 51: Based on the encoded feature information corresponding to the multiple first time points and the first feature information, obtain the sixth feature information.
[0127] The sixth feature information corresponding to the target region at the first time step is obtained by adding the first feature information corresponding to the target region at the first time step to the encoded feature information at the first time step.
[0128] During the model usage phase, the encoded feature information corresponding to multiple first time points can be obtained during the model training phase when the model training is completed. That is, during model training, data from N consecutive second time points are used for training. Each of the N second time points corresponds to a encoded feature information. The encoded feature information corresponding to each second time point is updated as the model is trained. When the model training is completed, the encoded feature information corresponding to each second time point is obtained. According to the time order of the N consecutive second time points, they are mapped to the N first time points. The encoded feature information of the second time point obtained when the training is completed is used as the encoded feature information of the corresponding first time point.
[0129] For a target region, the size of the first feature information at a certain time is 1×D, and the size of the encoded feature information at each time can be 1×D. For example, for target region A, the first feature information at time T is added to the encoded feature information at time T to obtain the sixth feature information of target region A at time T.
[0130] Step 52: For each attention head in the second Transformer module, obtain the second query information based on the sixth feature information and the query weight matrix of the attention head; obtain the second key information based on the sixth feature information and the key weight matrix of the attention head; obtain the second value information based on the sixth feature information and the value weight matrix of the attention head; and determine the attention calculation result corresponding to the attention head based on the second query information, the second key information, and the second value information.
[0131] In the second Transformer module, the size of the query weight matrix Wq for each attention head can be D×d, the size of the key weight matrix Wk for each attention head can be D×d, and the size of the value weight matrix Wv for each attention head can be D×d.
[0132] For each attention head in the second Transformer module, the dot product of the sixth feature information and the query weight matrix of the attention head is used as the second query information Q2, the dot product of the sixth feature information and the key weight matrix of the attention head is used as the second key information K2, and the dot product of the sixth feature information and the value weight matrix of the attention head is used as the second value information V2.
[0133] The attention calculation result of the attention head in the second Transformer module can be determined by the following formula (6). :
[0134] (6)
[0135] In formulas (5) and (6), T represents the transpose of the matrix.
[0136] Step 53: Concatenate the attention calculation results of each attention head in the second Transformer module to obtain the second target attention calculation result, and generate the second feature information based on the second target attention calculation result.
[0137] In the second Transformer module, the size of the attention calculation result of each attention head is N×C×d, and the size of the second target attention calculation result obtained by splicing is N×C×D.
[0138] The result of the second target attention calculation is processed by residual connection, layer normalization module and feedforward neural network to obtain the second feature information, the size of the second feature information is N×C×D.
[0139] In this way, the encoded feature information corresponding to each first moment can reflect the temporal order of each first moment. That is, the second Transformer module can extract features from the perspective of time to focus on the temporal order of each moment from time T-N+1 to time T. Thus, when making air quality prediction at time T+1, the influence of air quality at each past moment on air quality at time T+1 is considered.
[0140] The prediction module may include a layer normalization layer and a multilayer perceptron (MLP). The prediction module can generate air quality data for multiple target areas at time T+1 based on the second feature information.
[0141] It should be noted that the size of the feature information mentioned above can be understood as which aspects of the feature information are included. When performing calculations, such as feature addition, dot product, feature concatenation, etc., the calculation can be performed with the feature information of a target region at a certain time as the granularity, and the features of multiple target regions at multiple times can be calculated in parallel.
[0142] Figure 5 This is a flowchart illustrating the training process of a target air quality prediction model, as exemplarily shown. Figure 5 As shown, steps 61 to 67 are included.
[0143] Step 61: Obtain training samples.
[0144] The training samples include secondary environmental monitoring data for multiple target areas, as well as labeled air quality data for each target area at a specified time. The secondary environmental monitoring data for each target area includes air quality data and meteorological monitoring data for N secondary time points. It should be noted that the secondary time point is used to distinguish it from the primary time point, not to limit it to a specific time; that is, different training samples contain data from different secondary time points. The specified time point is the time following the latest of the N secondary time points.
[0145] The number of training samples can be multiple. For example, one of the training samples may contain the second environmental monitoring data of the target area, which may include the air quality data and meteorological monitoring data of the target area at each second time from time T'-N+1 to time T', with time T'+1 specified as the time. Time T'-N+1 to time T'+1 are all historical times.
[0146] Step 62: For each target area, based on meteorological monitoring data from other target areas at N second time points, determine the second air quality impact information for each target area at each second time point. The second air quality impact information is used to indicate the preset number of other target areas that have the greatest impact on the air quality of the target area at the second time point.
[0147] The method for determining the preset number of other target areas that have the greatest impact on the air quality of the target area can be referred to the implementation method in step 12.
[0148] Step 63: Input the second air quality impact information and the second environmental monitoring data of each of the multiple target areas into the air quality prediction model to obtain the air quality data of each target area at a specified time predicted by the air quality prediction model.
[0149] During model training, the structure of the air quality prediction model is the same as that of the target air quality prediction model described above.
[0150] In the first and second Transformer modules mentioned above, the query weight matrix, key weight matrix, and value weight matrix of each attention head, as well as the encoded feature information corresponding to multiple second time steps, are all learnable features, that is, they can be set initially and updated during training.
[0151] Step 64: Determine the target difference information based on the air quality data of each marked target area at the specified time and the predicted air quality data of each target area at the specified time.
[0152] In one embodiment, the air quality data includes the concentrations of various air pollutants; step 64 can be implemented as follows:
[0153] For each air pollutant, the predicted difference information for air pollutants is determined based on the concentration of air pollutants in each target area at a specified time and the predicted concentration of air pollutants in each target area at a specified time.
[0154] Target difference information is determined based on the preset weights and predicted difference information corresponding to various air pollutants.
[0155] For example, for the i-th target area, the concentration of the k-th air pollutant in the i-th target area at a specified time is represented as y. ik The predicted concentration of the k-th air pollutant in the i-th target area at a specified time is represented by y. ik ', will y ik With y ik The absolute value of the difference between ' and ' is used as the prediction difference information for the k-th air pollutant in the i-th target area. The average value of the prediction difference information for the k-th air pollutant in each of the C target areas is used as the prediction difference information for the k-th air pollutant.
[0156] The target difference information loss can be calculated using the following formula (7):
[0157] (7)
[0158] K represents the number of types of air pollutants. This represents the preset weight corresponding to the k-th air pollutant. This represents the predicted difference information for the k-th air pollutant.
[0159] Step 65: Determine whether the target difference information meets the training stopping condition. If it does, proceed to step 66; otherwise, proceed to step 67.
[0160] If the target difference information meets the training stopping condition, it can be that the target difference information is less than a preset threshold, indicating that the prediction accuracy of the air quality prediction model meets the requirements.
[0161] Step 66: Obtain the trained target air quality prediction model.
[0162] Step 67: Train the air quality prediction model based on the target difference information. After the training is completed, obtain the next training sample and return to step 62.
[0163] Training the air quality prediction model can include updating the weight matrix and the encoded feature information corresponding to each time step.
[0164] It should be noted that model training can be performed in batches or by training samples. Batch training means using multiple training samples simultaneously for one round of training. Therefore, obtaining training samples can be either obtaining a new training sample or obtaining multiple training samples from the next batch.
[0165] The above technical solution enables joint prediction of multiple air pollutants, meaning that the target air quality prediction model can simultaneously predict and output the concentration prediction results of multiple air pollutants in each target area.
[0166] Related technologies employ machine learning models such as LSTM (Long Short-Term Memory) and RNN (Recurrent Neural Network) for air quality prediction. However, when dealing with high-dimensional data from multiple cities and long-term series, these models suffer from low training efficiency and difficulty in convergence. Furthermore, the approach of predicting air quality separately for each city fails to fully utilize the information on the impact of air quality between cities.
[0167] This disclosure employs the Transformer architecture, which enables the focus on downwind areas, i.e., other areas that have a significant impact on the air quality of the target area, as well as the focus on the temporal order of the input data. It also supports simultaneous prediction of multiple cities and multiple pollutants, and can perform parallel computation for higher efficiency.
[0168] Figure 6 This is a block diagram illustrating a first electronic device 700 according to an exemplary embodiment. (See diagram below.) Figure 6 As shown, the first electronic device 700 may include: a first processor 701 and a first memory 702. The first electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a first communication component 705.
[0169] The first processor 701 controls the overall operation of the first electronic device 700 to complete all or part of the steps in the aforementioned air quality prediction method. The first memory 702 stores various types of data to support the operation of the first electronic device 700. This data may include, for example, instructions for any application or method operating on the first electronic device 700, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The first memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in the first memory 702 or transmitted via the first communication component 705. The audio component also includes at least one speaker for outputting audio signals. I / O interface 704 provides an interface between the first processor 701 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. The first communication component 705 is used for wired or wireless communication between the first electronic device 700 and other devices. Wireless communication may include Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of these. Therefore, the corresponding first communication component 705 may include a Wi-Fi module, a Bluetooth module, or an NFC module.
[0170] In an exemplary embodiment, the first electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the air quality prediction method described above.
[0171] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the air quality prediction method described above. For example, the computer-readable storage medium may be the first memory 702 including the program instructions described above, which may be executed by the first processor 701 of the first electronic device 700 to complete the air quality prediction method described above.
[0172] Figure 7 This is a block diagram illustrating a second electronic device 1900 according to an exemplary embodiment. For example, the second electronic device 1900 may be provided as a server. (Refer to...) Figure 7 The electronic device 1900 includes a second processor 1922, which may be one or more, and a second memory 1932 for storing computer programs executable by the second processor 1922. The computer programs stored in the second memory 1932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the second processor 1922 may be configured to execute the computer program to perform the aforementioned air quality prediction method.
[0173] Additionally, the second electronic device 1900 may also include a power supply component 1926 and a second communication component 1950. The power supply component 1926 may be configured to perform power management of the second electronic device 1900, and the second communication component 1950 may be configured to enable communication of the second electronic device 1900, such as wired or wireless communication. Furthermore, the second electronic device 1900 may also include an input / output (I / O) interface 1958. The second electronic device 1900 can operate on an operating system, such as Windows Server, stored in a second memory 1932. TM Mac OS X TM UnixTM Linux TM etc.
[0174] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the air quality prediction method described above. For example, the computer-readable storage medium may be the second memory 1932 including the program instructions, which may be executed by the second processor 1922 of the second electronic device 1900 to complete the air quality prediction method described above.
[0175] In another exemplary embodiment, a computer program product is also provided, which includes a computer program executable by a processor, which, when executed by the processor, implements the steps of the air quality prediction method described above.
[0176] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0177] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0178] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. An air quality prediction method, characterized in that, The method includes: Acquire first environmental monitoring data for each of multiple target areas. The first environmental monitoring data for each target area includes air quality data and meteorological monitoring data for the target area at multiple first moments. The multiple first moments include each moment from time T-N+1 to time T. For each target area, based on meteorological monitoring data of other target areas outside the target area at multiple first moments, first air quality impact information of the target area at each first moment is determined. The first air quality impact information is used to indicate a preset number of first areas that have the greatest impact on the air quality of the target area at the first moment. The meteorological monitoring data includes wind speed and wind direction. The degree of impact of the other target areas on the air quality of the target area at the first moment is determined based on the cosine of the included angle and the wind speed of the other target areas at the first moment. The included angle is determined based on the wind direction of the other target areas at the first moment and the orientation of the target area relative to the other target areas. The first air quality impact information and the first environmental monitoring data are input into the target air quality prediction model to obtain the air quality data of each of the multiple target areas at time T+1, which are output by the target air quality prediction model. The target air quality prediction model includes a first Transformer module, which is used to generate fourth feature information based on the first air quality impact information and generate first feature information based on the fourth feature information. The first feature information is used to determine the air quality data of each of the multiple target areas at time T+1. The fourth feature information corresponding to the target area at the first time is obtained by concatenating the following feature information: feature information of the first environmental monitoring data of the first area corresponding to the target area at the first time, feature information of the spherical distance between the target area and the first area, and feature information of the azimuth angle of the first area relative to the target area.
2. The method according to claim 1, characterized in that, The step of determining the first air quality impact information of the target area at each of the multiple first time moments based on meteorological monitoring data of other target areas outside the target area includes: For each first moment, based on the cosine of the included angle, the wind speed of the other target areas at the first moment, and the preset air pollutant propagation distance, the influence distance of the other target areas on the air quality of the target area at the first moment is determined; based on the influence distance and the spherical distance between the other target areas and the target area, the degree of influence of the other target areas on the air quality of the target area at the first moment is determined; the preset number of other target areas with the largest degree of influence are taken as the first area corresponding to the target area at the first moment.
3. The method according to claim 2, characterized in that, When the influence distance is greater than or equal to the spherical distance, the degree of influence is the target value; When the influence distance is less than the spherical distance, the degree of influence is less than the target value, and the greater the difference between the spherical distance and the influence distance, the smaller the degree of influence.
4. The method according to claim 1, characterized in that, The target air quality prediction model further includes a second Transformer module and a prediction module. The second Transformer module is used to generate second feature information based on the encoded feature information corresponding to the plurality of first time points and the first feature information. The prediction module is used to generate air quality data of the plurality of target areas at time T+1 based on the second feature information.
5. The method according to claim 4, characterized in that, The first Transformer module is used to generate the first feature information based on a multi-head self-attention mechanism in the following manner: Based on the characteristic information of the first environmental monitoring data of each of the multiple target areas, the third characteristic information is obtained; The fourth feature information is generated based on the first air quality impact information; For each attention head in the first Transformer module, first query information is obtained based on the third feature information and the query weight matrix of the attention head; first key information is obtained based on the fourth feature information and the key weight matrix of the attention head. Based on the fourth feature information and the value weight matrix of the attention head, the first value information is obtained; based on the first query information, the first key information and the first value information, the attention calculation result corresponding to the attention head is determined; The attention calculation results of each attention head in the first Transformer module are concatenated to obtain the first target attention calculation result, and the first feature information is generated based on the first target attention calculation result.
6. The method according to claim 5, characterized in that, The step of determining the attention calculation result corresponding to the attention head based on the first query information, the first key information, and the first value information includes: Based on the first air quality impact information, fifth feature information is generated, wherein the fifth feature information corresponding to the target area at the first time is generated based on the following information: the influence distance of the first region corresponding to the target area on the air quality of the target area at the first time. Based on the first query information, the first key information, the first value information, and the fifth feature information, the attention calculation result corresponding to the attention head is determined.
7. The method according to claim 4, characterized in that, The second Transformer module is used to generate the second feature information based on a multi-head self-attention mechanism in the following manner: Based on the encoded feature information corresponding to the plurality of first time points respectively, and the first feature information, the sixth feature information is obtained, wherein the sixth feature information corresponding to the target region at the first time point is obtained by adding the first feature information corresponding to the target region at the first time point to the encoded feature information at the first time point; For each attention head in the second Transformer module, second query information is obtained based on the sixth feature information and the query weight matrix of the attention head; second key information is obtained based on the sixth feature information and the key weight matrix of the attention head; second value information is obtained based on the sixth feature information and the value weight matrix of the attention head; and the attention calculation result corresponding to the attention head is determined based on the second query information, the second key information, and the second value information. The attention calculation results of each attention head in the second Transformer module are concatenated to obtain the second target attention calculation result, and the second feature information is generated based on the second target attention calculation result.
8. The method according to claim 1, characterized in that, The target air quality prediction model was trained in the following manner: Acquire training samples, which include second environmental monitoring data for each of the plurality of target areas, and air quality data for each of the target areas at a specified time. The second environmental monitoring data for the target areas includes air quality data and meteorological monitoring data for the target areas at N second times. For each target area, based on meteorological monitoring data of other target areas outside the target area at N second times, second air quality impact information of the target area at each second time is determined. The second air quality impact information is used to indicate a preset number of other target areas that have the greatest impact on the air quality of the target area at the second time. The second air quality impact information and the second environmental monitoring data of each of the multiple target areas are input into the air quality prediction model to obtain the air quality data of each of the target areas predicted by the air quality prediction model at the specified time. Based on the air quality data of each of the marked target areas at the specified time, and the predicted air quality data of each of the target areas at the specified time, target difference information is determined; If the target difference information satisfies the training stopping condition, then the target air quality prediction model that has been trained is obtained.
9. The method according to claim 8, characterized in that, The air quality data includes the concentrations of various air pollutants; determining the target difference information based on the air quality data of each of the labeled target areas at the specified time, and the predicted air quality data of each of the target areas at the specified time, includes: For each of the air pollutants, prediction difference information for the air pollutants is determined based on the concentration of the air pollutants in each of the marked target areas at the specified time and the predicted concentration of the air pollutants in each of the target areas at the specified time. The target difference information is determined based on the preset weights corresponding to the various air pollutants and the predicted difference information.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the method according to any one of claims 1-9.
Citation Information
Patent Citations
Prediction method and device, training method and device, electronic equipment and storage medium
CN114819289A
Air quality prediction method and system
CN116611561A