Air quality index prediction method and device based on CNN-AGU
By introducing convolutional neural networks and gated cyclic units in air quality index prediction, combined with the attention mechanism, the problem of insufficient air quality index prediction accuracy in the existing technology is solved, and more efficient data utilization and more accurate predictions are achieved. result.
Patent Information
- Application Number
- CN202210721055.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-16
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-06-16
AI Technical Summary
Existing air quality index prediction methods have shortcomings in accuracy and are difficult to make full use of historical data, resulting in inaccurate prediction results.
An air quality index prediction method based on convolutional neural network (CNN), gated recurrent unit (AGU) and attention mechanism is used to enhance the learning ability of the gated recurrent unit and improve the data through data preprocessing, feature extraction and model training. Utilization efficiency.
It improves the accuracy and stability of air quality index prediction, avoids prediction errors due to function saturation, and achieves more accurate air quality index prediction.
Smart Images

Figure CN115099488B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of air quality index, and in particular to an air quality index prediction method and device based on CNN-AGU. Background Art
[0002] Air pollution has a great impact on the development of the national economy and people's physical and mental health, and has attracted great attention from all walks of life. AQI (Air Quality Index) simplifies the concentrations of several routinely monitored air pollutants into a single conceptual index value based on ambient air quality standards and the impact of various pollutants on human health, ecology, and environment. The AQI is used to evaluate the air quality, and the evaluation results can fully reflect the actual air quality. For a long time, the prediction of AQI has been one of the research hotspots in the field of air pollution monitoring and control at home and abroad. Summary of the invention
[0003] The embodiments of the present application provide a method and device for predicting an air quality index based on CNN-AGU to improve the prediction accuracy of the air quality index.
[0004] This application is implemented through the following technical solutions:
[0005] In a first aspect, an embodiment of the present application provides an air quality index prediction method based on CNN-AGU, comprising:
[0006] Obtain the air quality index and influencing factors of the air quality index within a preset time, perform data preprocessing on the air quality index and influencing factors, and obtain constructed time series input data;
[0007] An air quality index prediction model is established based on convolutional neural networks, gated recurrent units, and attention mechanisms;
[0008] The constructed time series input data is input into the air quality index prediction model to obtain the predicted value of the air quality index.
[0009] In conjunction with the first aspect, in some possible implementations, data preprocessing includes missing value processing, standardization processing, and three-dimensional data construction; missing value processing fills in missing data according to the attributes and duration of the missing data. When the attribute of the missing data is the air quality index, the missing data is filled in by the air quality index definition method; when the attribute of the missing data is pollutant concentration or weather data, the forward recursive method is used to fill in the missing pollutant concentration or weather data with a duration less than or equal to the unit time, and the moving average method is used to fill in the missing pollutant concentration or weather data with a duration greater than the unit time. The three-dimensional data construction is based on the data that has completed the missing value processing and standardization processing, the preset step size and the preset sequence length, and multiple samples are obtained. The set of multiple samples is the constructed time series input data.
[0010] In combination with the first aspect, in some possible implementations, the standardization processing includes removing abnormal data and standardizing the data format.
[0011] In combination with the first aspect, in some possible implementations, the prediction model includes a CNN layer, an AGU layer and an output layer; the CNN layer is used to extract and output data features of the input data; the AGU layer predicts the data based on the data features to obtain a prediction result; and the output layer is used to output the prediction result.
[0012] In combination with the first aspect, in some possible implementations, the input data of the CNN layer is constructed time series input data, and the CNN layer uses a gradient descent method to train the constructed time series input data to obtain extracted data features.
[0013] In combination with the first aspect, in some possible implementations, the data processing function of the AGU layer is: t =z t ·h t-1 +(1-z t )h′ t , where z t =σ(W z *[h t-1 , x t ]+b z ), z t is the output of the update gate, σ is the sigmoid activation function, W z is the weight of the update gate, b z is the bias of the update gate, x t is the input vector of the current node, h t-1 is the hidden state passed down from the previous node, h′ t =tanh(U t *[DAM·h t-1 , x t ]+bt ), DAM = tanh(r t ), b t is the preset bias, r t is the output result of the reset gate, r t =σ(W r *[h t-1 , x t ]+b r ), W r To reset the gate weight, b r To reset the gate bias, U t =softmax(α t ), α t =σ(W α *[h t-1 , x t ]+b α ), where U t is the attention probability distribution, α t For x t and h t-1 The matching degree between them, W α is α t The weight of b α is α t The bias.
[0014] In combination with the first aspect, in some possible implementations, the air quality index prediction method based on CNN-AGU also includes the step of training the air quality index prediction model, including: obtaining training samples, dividing the training samples into training sets, validation sets and test sets, and the ratio of the number of data in the training sets, validation sets and test sets is 6:2:2; training and evaluating the air quality index prediction model based on the training sets, validation sets and test sets. Among them, the training set is used for model training to update model parameters; the validation set is used to test the accuracy of the model, adjust the number of training times and learning rate, and monitor whether the model is overfitting; the test set is used to evaluate the generalization ability of the model after the final training of the model is completed to obtain the prediction accuracy.
[0015] In the second aspect, an embodiment of the present application provides an air quality index prediction device based on CNN-AGU, including: a preprocessing module, used to obtain the air quality index and influencing factors of the air quality index within a preset time, perform data preprocessing on the air quality index and influencing factors, and obtain constructed time series input data; a modeling module, used to establish an air quality index prediction model based on a convolutional neural network, a gated recurrent unit and an attention mechanism; a prediction module, used to input the constructed time series input data into the air quality index prediction model to obtain a predicted value of the air quality index.
[0016] In a third aspect, an embodiment of the present application provides a terminal device, comprising: a processor and a memory, the memory being used to store a computer program, and when the processor executes the computer program, it implements the air quality index prediction method based on CNN-AGU as described in any one of the first aspects.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the air quality index prediction method based on CNN-AGU as described in any one of the first aspects is implemented.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the air quality index prediction method based on CNN-AGU as described in any one of the above-mentioned first aspects.
[0019] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
[0020] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0021] This application introduces an attention mechanism based on a convolutional neural network and a gated recurrent unit, thereby enhancing the learning ability of the gated recurrent unit, so that the gated recurrent unit can learn historical data more fully during operation, thereby improving the efficiency of data utilization. Therefore, the data results obtained by this method in predicting the air quality index are more accurate.
[0022] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0024] Figure 1 This is a schematic diagram of an application scenario of an air quality index prediction method based on CNN-AGU provided in an embodiment of the present application;
[0025] Figure 2 It is a flowchart of an air quality index prediction method based on CNN-AGU provided in one embodiment of the present application;
[0026] Figure 3 It is a schematic diagram of the construction process of constructed time series input data provided by an embodiment of the present application;
[0027] Figure 4 is a schematic diagram of an air quality index prediction model provided by an embodiment of the present application;
[0028] Figure 5 It is a structural schematic diagram of an AGU provided in one embodiment of the present application;
[0029] Figure 6 It is a structural schematic diagram of an air quality index prediction device based on CNN-AGU provided in one embodiment of the present application;
[0030] Figure 7 It is a structural diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0031] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0032] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0033] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0034] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0035] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0036] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0037] For example, the embodiments of the present application can be applied to Figure 1 In the exemplary scenario shown. In this scenario, the air quality index and air quality index influencing factor acquisition device 10 is used to obtain the air quality index and air quality index influencing factors for a period of time and send them to the CNN-AGU-based air quality index prediction device 20, and the CNN-AGU-based air quality index prediction device 20 calculates the air quality index prediction result.
[0038] The following combination Figure 1 The air quality index prediction method based on CNN-AGU of the present application is described in detail.
[0039] Figure 2 is a schematic flow chart of an air quality index prediction method based on CNN-AGU provided in an embodiment of the present application, with reference to Figure 2 , the air quality index prediction method based on CNN-AGU is described as follows:
[0040] In step 101, the air quality index and the influencing factors of the air quality index within a preset time are obtained, and data preprocessing is performed on the air quality index and the influencing factors to obtain constructed time series input data.
[0041] Exemplarily, data preprocessing includes missing value processing, standardization processing and three-dimensional data construction.
[0042] Specifically, while obtaining the air quality index within a preset time, the influencing factors of the air quality index are also obtained, and the influencing factors include: the concentration of CO, NO2, O3, PM10, PM2.5 and SO2, and also include: temperature, humidity, wind level and weather.
[0043] Missing value processing can fill in missing data according to the attributes and duration of missing data. When the attribute of missing data is air quality index, the missing data is filled by air quality index definition method; when the attribute of missing data is pollutant concentration or weather data, the forward filling method is used for missing pollutant concentration or weather data with a duration less than or equal to the unit time, and the moving average method is used for missing pollutant concentration or weather data with a duration greater than the unit time.
[0044] Specifically, regarding the missing AQI (Air Quality Index), it can be seen from the AQI calculation formula that its value is determined by the maximum value of the pollutant's IAQI (Individual Air Quality Index), which is related to the corresponding pollutant concentration and has nothing to do with the duration of the missing. Therefore, no matter how long the missing time is, it is necessary to first analyze the pollutant concentration value to determine whether there is a missing situation. If there is a missing pollutant concentration value, it is processed accordingly according to the missing duration. When the pollutant concentration values exist, the missing AQI is assigned a value according to the maximum value method.
[0045] Specifically, if one or more data with a missing duration of unit time are missing, if the AQI exists and is the maximum value among the existing pollutant IAQI data, or if the AQI does not exist, it is necessary to perform forward recurrent complementation on each pollutant or weather data separately, as shown in formula (1):
[0046]
[0047] In formula (1), Represents the valid observation value of the d-dimensional component data at the previous moment.
[0048] For data with missing duration greater than the unit time, if the forward filling method is used, the filling value of a certain data in the continuous missing period will be a constant value, the data is too smooth, and the network cannot find the connection between the data well. In this case, the moving average method is used to fill the missing data, as shown in formula (2):
[0049]
[0050] First, set a time window, denoted as k. The moving average method is to slide this time window along the time axis to get the average value. When calculating the average value, the data of the t-1, t-2, ..., tk time steps are used, where Represents the d-dimensional component data k time steps ahead from the current missing moment.
[0051] Exemplarily, the standardization process includes removing abnormal data and standardizing data formats.
[0052] Specifically, as shown in Table 1, it can be seen that some data have abnormalities such as inconsistent formats and repeated data. To ensure the uniform format of the input data, the duplicate data is deleted. For example, in Table 1, only one data of 2020 / 2 / 28 3:00 is retained, and the data with unit symbols are deleted, such as temperature data with ℃ and humidity data with % symbol.
[0053] Table 1 Air quality index within preset time
[0054]
[0055]
[0056] Sometimes feature data is not always a continuous value, but may be some categorical values, such as weather conditions can be divided into "cloudy" and "sunny", etc. For such feature data, it is usually necessary to digitize the feature data, as shown in Table 2.
[0057] Table 2 Digital transformation of characteristic data
[0058]
[0059] In the process of predicting AQI, the factors that affect AQI include pollutants such as CO and NO2 and some meteorological factors. The dimensions and numerical magnitudes of these feature data are different. If the original data values are used directly, then their impact on AQI will be different. Through standardization, different feature data can have the same scale, thereby reducing the impact of different numerical values on model training, accelerating the model convergence speed, and conducting comprehensive evaluation and analysis. This application uses Min-Max standardization to perform corresponding linear transformation processing on sample data, so that the transformed data is mapped to the interval [0,1]. The entire process will not destroy the existing data structure, as shown in formula (3).
[0060]
[0061] Among them, y i For x i The impact on AQI, n is the number of factors affecting AQI, x is i Factors affecting AQI.
[0062] Exemplarily, the constructed time series input data refers to the data column information recorded in chronological order according to the same standard, and the data obtained by indexing by the time dimension. The air quality data and weather data studied in this application are both time series data. The obtained data set can be represented by a set, that is, S = {X1, X2, ..., X n}, where n represents the number of time steps, each time step X t are all d-dimensional vectors, representing the set of pollutant concentration observations and weather data at a certain point in time, that is, X t ={C1, C2, ..., C 11}, where C1-C7 are the concentrations of AQI, CO, NO2, O3, PM10, PM2.5 and SO2, respectively, and C8-C 11 They are temperature, humidity, wind level and weather respectively. Therefore, the data set is (n, d), and the time series samples generated by the data set are three-dimensional data. The calculation result is (N, T, D), where N is the number of time slices, that is, the number of samples, T is the number of time steps contained in a sample, and D is the number of features of the input data, that is, X t The number of elements in .
[0063] Exemplarily, the three-dimensional data construction is based on data that has completed missing value processing and standardization processing, a preset step size and a preset sequence length, to obtain multiple samples, and the set of multiple samples is the constructed time series input data.
[0064] like Figure 3 As shown, the preset step size is 1 and the preset sequence length is 24, that is, each sample contains 24 data, and the first data of each adjacent sample differs by the preset step size of 1, that is, the first data in the second sample is the second data in the first sample. Assuming that there are Y input data of the time series, the data is constructed in three dimensions according to the preset step size of step=1 and the preset sequence length of sequence=24, then the number of samples is Y-23, the number of time steps contained in a sample is 24, and the number of features of the input data is 11, that is, the operation result is (Y-23,24,11).
[0065] In step 102, an air quality index prediction model is established based on a convolutional neural network, a gated recurrent unit, and an attention mechanism.
[0066] Exemplarily, the prediction model includes a CNN (Convolutional Neural Networks) layer, an AGU (Attention Gate Unit) layer and an output layer; the CNN layer is used to extract and output data features of the input data; the AGU layer predicts the data based on the data features to obtain a prediction result; and the output layer is used to output the prediction result.
[0067] Exemplarily, the input data of the CNN layer is constructed time series input data, and the CNN layer uses the gradient descent method to train the constructed time series input data to obtain extracted data features.
[0068] Exemplarily, the data processing function of the AGU layer is:
[0069] h t =z t ·h t-1 +(1-z t )h′ t
[0070] Among them, z t =σ(W z *[h t-1 , x t ]+b z ), z t is the output of the update gate, σ is the sigmoid activation function, W z is the weight of the update gate, bz is the bias of the update gate, x t is the input vector of the current node, h t-1 is the hidden state passed down from the previous node, h′ t =tanh(U t *[DAM·h t-1 , x t ]+b t ), DAM = tanh(r t ), b t is the preset bias, r t is the output result of the reset gate, r t =σ(W r *[h t-1 , x t ]+b r ), W r To reset the gate weight, b r To reset the gate bias, U t =softmax(α t ), α t =σ(W α *[h t-1 , x t]+b α ), where U t is the attention probability distribution, α t For x t and h t-1 The matching degree between them, W α is α t The weight of b α is α t The bias.
[0071] Specifically, the AGU structure in the AGU layer is provided with a DAM (Data Adjustment Module), and the DAM is used to avoid errors in prediction results due to the saturation of the function.
[0072] Exemplarily, the air quality index prediction method based on CNN-AGU also includes the step of training the air quality index prediction model, including: obtaining training samples, dividing the training samples into a training set, a validation set, and a test set, wherein the ratio of the number of data in the training set, the validation set, and the test set is 6:2:2; training and evaluating the air quality index prediction model based on the training set, the validation set, and the test set. Among them, the training set is used for model training to update model parameters; the validation set is used to test the accuracy of the model, adjust the number of training times and the learning rate, and monitor whether the model is overfitting; the test set is used to evaluate the generalization ability of the model after the final training of the model is completed to obtain the prediction accuracy.
[0073] Specifically, Figure 4 Schematic diagram of the air quality index prediction model provided for this application. From the figure, we can see that after the data is preprocessed, it will enter the CNN layer to extract and output data features, and then enter the AGU layer. The AGU layer predicts the data based on the data features and finally outputs the AQI prediction value.
[0074] like Figure 5 As shown, Figure 5 This is a schematic diagram of the AGU structure. Compared with the previous ordinary gating units, the AGU structure also includes DAM and Attention (attention mechanism unit), which makes the prediction results obtained by the air quality index prediction model of this application more accurate and more stable.
[0075] Specifically, the sample data of this application is limited, and 7877 samples are intercepted from 39385 samples as the test set. The remaining samples are used as learning samples of the air quality index prediction model. During the training process, 23631 learning samples are intercepted as the training set and 7877 are used as the validation set.
[0076] Specifically, usually, the generalization ability of neural networks is stronger than that of linear models, but there are still many parameters in neural networks that need to be adjusted and selected, such as batch_size, epochs, etc. in the hyperparameters of running neural networks. We need to adjust these hyperparameters to make the generalization ability of the model reach its strongest level. During the training process, the model parameters need to be adjusted to obtain the best parameters, which are shown in Table 3.
[0077] Table 3 Model parameters
[0078] type parameter CNN Layer filters=16;kernel_size=1;padding='valid' MaxPooling1D pool_size=1;padding='valid' AGU layer units=128;kernel_initializer='he_normal' Other parameters loss='mae'; batch_size=120; learning_rate=0.001; epochs=100
[0079] After setting the parameters, the validation set prediction results of the validation set of the present invention and the other seven models (SVR, RFR, LSTM, GRU, AGU, CNN-LSTM, CNN-GRU) are shown in Table 4. In terms of model training time, compared with LSTM and GRU, AGU has an attention mechanism added to AGU, which requires matching each item of the input sequence with the corresponding hidden state at the previous moment during training. The matching process is used to calculate the matching weight, which is limited to the current sequence pair and is not an overall weight like the traditional neural network model weight. The training time is slightly increased, but in terms of error degree and fit, AGU performs better.
[0080] Table 4 Prediction results of validation set
[0081] Model MAE MSE <![CDATA[R 2 ]]> Training time(s) SVR 19.264 483.626 0.8750 540.23 RFR 15.364 402.629 0.8905 486.32 LSTM 9.523 220.396 0.9300 1115.36 GRU 9.003 210.271 0.9331 1110.62 AGU 8.242 194.231 0.9490 1271.35 CNN-LSTM 8.931 195.826 0.9466 1217.91 CNN-GRU 8.013 185.400 0.9453 1113.66 CNN-AGU 7.087 180.361 0.9570 1334.85
[0082] In step 103, the constructed time series input data is input into the air quality index prediction model to obtain the predicted value of the air quality index.
[0083] Specifically, in order to verify the effectiveness and accuracy of the model of the present invention, the prediction results of CNN-AGU of the present invention and other 7 models (SVR, RFR, LSTM, GRU, AGU, CNN-LSTM, CNN-GRU) were compared with MAE, MSE, R 2 The comprehensive comparison of the evaluation indicators is shown in Table 5. In the overall evaluation criteria, the evaluation indicators of the AQI prediction model of CNN-AGU are better than those of other models.
[0084] Table 5 Test set prediction results
[0085] Model MAE MSE <![CDATA[R 2 ]]> SVR 21.100 523.136 0.8550 RFR 15.296 400.4241 0.8727 LSTM 10.001 232.777 0.9200 GRU 9.199 230.001 0.9102 AGU 8.7420 196.4631 0.9380 CNN-LSTM 9.9114 199.3654 0.9211 CNN-GRU 8.429 189.542 0.9253 CNN-AGU 8.107 183.322 0.9490
[0086] From the test set prediction results of each model in Table 5, we can find that:
[0087] R of SVR and RFR prediction results 2The MAE and MSE performances of SVR and RFR models are relatively poor, as they are sensitive to outliers. For example, compared with the LSTM prediction model, SVR has a lower RSE performance. 2 The low is 0.065, the MAE is high is 11.099, and the MSE is high is 290.359.
[0088] LSTM, GRU and AGU are essentially variants of recurrent neural networks. Due to the relatively simple internal structure of GRU, the training time of this model is the shortest in the experiment, and the fitting effect is comparable to that of LSTM. 2 It is 0.018 higher, and MAE and MSE are reduced by 1.259 and 36.3139 respectively; compared with GRU, R 2 It is 0.0278 higher, and MAE and MSE are 0.457 and 33.5379 lower respectively.
[0089] After the introduction of CNN, the MAE of LSTM, GRU and AGU is reduced compared with the single model. 2 Compared with the single LSTM method, the MAE index of CNN-LSTM is reduced by 0.9%, the MSE index is reduced by 14.35%, and the R 2 The index is improved by 0.12%; the MAE index of CNN-GRU is reduced by 8.37% and the MSE index is reduced by 17.59% compared with the single GRU method. 2 The indicator is improved by 1.66%; the MAE indicator of CNN-AGU is reduced by 7.26% and the MSE indicator is reduced by 6.69% compared with the single AGU method. 2 The indicator increased by 1.17%.
[0090] Compared with CNN-LSTM, CNN-AGU has a lower MAE of 1.8044, a lower MSE of 16.0434, and R 2 Compared with CNN-GRU, CNN-AGU’s MAE index decreased by 0.322, MSE decreased by 6.22, and R 2 Improved by 0.0237.
[0091] The above-mentioned CNN-AGU-based air quality index prediction method, by introducing the attention mechanism on the basis of the convolutional neural network and the gated recurrent unit, enhances the learning ability of the gated recurrent unit, so that the gated recurrent unit can learn the historical data more fully during operation, and improves the efficiency of data utilization. In addition, the existence of the data adjustment module can also avoid errors in the prediction results due to the saturation of the function. Therefore, the data results obtained by this method in the prediction of air quality index are more accurate.
[0092] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0093] Corresponding to the air quality index prediction method based on CNN-AGU described in the above embodiment, Figure 6 A structural block diagram of an air quality index prediction device based on CNN-AGU provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0094] See also Figure 6 The air quality index prediction device based on CNN-AGU in the embodiment of the present application may include a preprocessing module 401, a modeling module 402 and a prediction module 403.
[0095] The preprocessing module 401 is used to obtain the air quality index and the influencing factors of the air quality index within a preset time, perform data preprocessing on the air quality index and the influencing factors, and obtain constructed time series input data.
[0096] Exemplarily, data preprocessing includes missing value processing, standardization processing and three-dimensional data construction; missing value processing fills in missing data according to the attributes and duration of missing data; when the attribute of missing data is air quality index, missing data is filled in by air quality index definition method. When the attribute of missing data is pollutant concentration or weather data, the forward recursive method is used to fill in the missing pollutant concentration or weather data with a missing duration less than or equal to the unit time, and the moving average method is used to fill in the missing pollutant concentration or weather data with a missing duration greater than the unit time.
[0097] The three-dimensional data construction is based on the data that has completed missing value processing and standardization processing, a preset step size and a preset sequence length, to obtain multiple samples, and the collection of multiple samples is the constructed time series input data.
[0098] Exemplarily, the standardization process includes removing abnormal data and standardizing data formats.
[0099] The modeling module 402 is used to establish an air quality index prediction model based on a convolutional neural network, a gated recurrent unit, and an attention mechanism.
[0100] Exemplarily, the prediction model includes a CNN layer, an AGU layer and an output layer; the CNN layer is used to extract and output data features of the input data; the AGU layer predicts the data based on the data features to obtain a prediction result; and the output layer is used to output the prediction result.
[0101] Exemplarily, the input data of the CNN layer is constructed time series input data, and the CNN layer uses the gradient descent method to train the constructed time series input data to obtain extracted data features.
[0102] Exemplarily, the data processing function of the AGU layer is:
[0103] h t =z t ·h t-1 +(1-z t )h′ t
[0104] Among them, z t =σ(W z *[h t-1 , x t ]+b z ), z t is the output of the update gate, σ is the sigmoid activation function, W z is the weight of the update gate, b z is the bias of the update gate, x t is the input vector of the current node, h t-1 is the hidden state passed down from the previous node, h′ t =tanh(U t *[DAM·h t-1 , x t ]+b t ), DAM = tanh(r t ), b t is the preset bias, r t is the output result of the reset gate, r t =σ(W r *[h t-1 , x t ]+b r ), W r To reset the gate weight, b r To reset the gate bias, U t =softmax(α t ), α t =σ(W α *[h t-1 , x t ]+b α ), where U t is the attention probability distribution, α t For x t and h t-1 The matching degree between them, W α is α t The weight of b α is α tThe bias.
[0105] Exemplarily, the air quality index prediction method based on CNN-AGU also includes the step of training the air quality index prediction model, including: obtaining training samples, dividing the training samples into training sets, validation sets and test sets, the data quantity ratio of the training sets, validation sets and test sets is 6:2:2; training and evaluating the air quality index prediction model based on the training sets, validation sets and test sets. Among them, the training set is used for model training to update model parameters; the validation set is used to test the accuracy of the model, adjust the number of training times and learning rate, and monitor whether the model is overfitting; the test set is used to evaluate the generalization ability of the model after the final training of the model is completed to obtain the prediction accuracy.
[0106] The prediction module 403 is used to input the constructed time series input data into the air quality index prediction model to obtain the predicted value of the air quality index.
[0107] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0108] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0109] The present application also provides a terminal device, see Figure 7 The terminal device 500 may include: at least one processor 510 and a memory 520, wherein the memory 520 is used to store a computer program 521, and the processor 510 is used to call and run the computer program 521 stored in the memory 520 to implement the steps in any of the above-mentioned method embodiments, for example Figure 2Steps 101 to 103 in the illustrated embodiment. Alternatively, when the processor 510 executes the computer program, the functions of each module / unit in the above-mentioned device embodiments are implemented, for example Figure 6 Functions of modules 401 to 403 are shown.
[0110] Exemplarily, the computer program 521 may be divided into one or more modules / units, one or more modules / units are stored in the memory 520, and are executed by the processor 510 to complete the present application. The one or more modules / units may be a series of computer program segments that can complete specific functions, and the program segments are used to describe the execution process of the computer program in the terminal device 500.
[0111] Those skilled in the art will understand that Figure 7 It is only an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components, such as input and output devices, network access devices, buses, etc.
[0112] The processor 510 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0113] The memory 520 may be an internal storage unit of the terminal device, or an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. The memory 520 is used to store the computer program and other programs and data required by the terminal device. The memory 520 may also be used to temporarily store data that has been output or is to be output.
[0114] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0115] The air quality index prediction method based on CNN-AGU provided in the embodiment of the present application can be applied to terminal devices such as computers, wearable devices, vehicle-mounted devices, tablet computers, laptops, netbooks, mobile phones, etc. The embodiment of the present application does not impose any restrictions on the specific type of terminal devices.
[0116] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can implement the steps in each embodiment of the above-mentioned CNN-AGU-based air quality index prediction method.
[0117] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in each embodiment of the above-mentioned CNN-AGU-based air quality index prediction method when executing the computer program product.
[0118] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
[0119] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0120] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0121] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0122] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0123] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for predicting air quality index based on CNN-AGU, characterized in that: include: Acquire an air quality index and influencing factors of the air quality index within a preset time, perform data preprocessing on the air quality index and the influencing factors, and obtain constructed time series input data; An air quality index prediction model is established based on convolutional neural networks, gated recurrent units, and attention mechanisms; Inputting the constructed time series input data into the air quality index prediction model to obtain a predicted value of the air quality index; The prediction model includes a CNN layer, an AGU layer and an output layer; The CNN layer is used to extract and output data features of the input data; The AGU layer predicts the data based on the data features to obtain a prediction result; The output layer is used to output the prediction result; The data processing function of the AGU layer is: h t =z t ·h t-1 +(1-z t )h′ t Among them, z t =σ(W z *[h t-1 ,x t ]+b z ), z t is the output of the update gate, σ is the sigmoid activation function, W z is the weight of the update gate, b z is the bias of the update gate, x t is the input vector of the current node, h t-1 is the hidden state passed down from the previous node, h t ′=tanh(U t *[DAM·h t-1 ,x t ]+b t ), DAM = tanh(r t ), b t is the preset bias, r t is the output result of the reset gate, r t =σ(W r *[h t-1 ,x t ]+b r ), W r To reset the gate weight, b r To reset the gate bias, U t =softmax(α t ), α t =σ(W α *[h t-1 ,x t ]+b α ), where U t is the attention probability distribution, α t For x t and h t-1 The matching degree between them, W α is α t The weight of b α is α t The bias.
2. The air quality index prediction method based on CNN-AGU according to claim 1, characterized in that: The data preprocessing includes missing value processing, standardization processing and data three-dimensional construction; the missing value processing fills the missing data according to the attributes and duration of the missing data; When the attribute of the missing data is the air quality index, the missing data is filled by the air quality index definition method; When the attribute of missing data is pollutant concentration or weather data, the forward filling method is used to fill in the missing pollutant concentration or weather data with a missing duration less than or equal to the unit time, and the moving average method is used to fill in the missing pollutant concentration or weather data with a missing duration greater than the unit time; The three-dimensional data construction is based on the data that has completed the missing value processing and the standardization processing, the preset step size and the preset sequence length, to obtain multiple samples, and the set of the multiple samples is the constructed time series input data.
3. The air quality index prediction method based on CNN-AGU as claimed in claim 2, characterized in that: The standardization process includes removing abnormal data and standardizing data formats.
4. The air quality index prediction method based on CNN-AGU according to claim 1, characterized in that: The input data of the CNN layer is the constructed time series input data, and the CNN layer uses the gradient descent method to train the constructed time series input data to obtain extracted data features.
5. The air quality index prediction method based on CNN-AGU according to claim 1, characterized in that: The method further comprises the step of training the air quality index prediction model, including: Obtain training samples, and divide the training samples into a training set, a validation set, and a test set, wherein the ratio of the number of data in the training set, the validation set, and the test set is 6:2:2; The air quality index prediction model is trained and evaluated based on the training set, validation set and test set; wherein the training set is used for model training to update model parameters; the validation set is used to test the accuracy of the model, adjust the number of training times and the learning rate, and monitor whether the model is overfitting; the test set is used to evaluate the generalization ability of the model after the final training of the model is completed to obtain the prediction accuracy.
6. An air quality index prediction device based on CNN-AGU, characterized in that: include: A preprocessing module is used to obtain the air quality index and the influencing factors of the air quality index within a preset time, perform data preprocessing on the air quality index and the influencing factors, and obtain constructed time series input data; A modeling module for building an air quality index prediction model based on convolutional neural networks, gated recurrent units, and attention mechanisms; A prediction module, used for inputting the constructed time series input data into the air quality index prediction model to obtain a predicted value of the air quality index; The prediction model includes a CNN layer, an AGU layer and an output layer; The CNN layer is used to extract and output data features of the input data; The AGU layer predicts the data based on the data features to obtain a prediction result; The output layer is used to output the prediction result; The data processing function of the AGU layer is: h t =z t ·h t-1 +(1-z t )h′ t Among them, z t =σ(W z *[h t-1 ,x t ]+b z ), z t is the output of the update gate, σ is the sigmoid activation function, W z is the weight of the update gate, b z is the bias of the update gate, x t is the input vector of the current node, h t-1 is the hidden state passed down from the previous node, h t ′=tanh(U t *[DAM·h t-1 ,x t ]+b t ), DAM = tanh(r t ), b t is the preset bias, r t is the output result of the reset gate, r t =σ(W r *[h t-1 ,x t ]+b r ), W r To reset the gate weight, b r To reset the gate bias, U t =softmax(α t ), α t =σ(W α *[h t-1 ,x t ]+b α ), where U t is the attention probability distribution, α t For x t and h t-1 The matching degree between them, W α is α t The weight of b α is α t The bias.
7. A terminal device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the air quality index prediction method based on CNN-AGU as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the air quality index prediction method based on CNN-AGU as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Air quality prediction method based on attention enhancement graph convolutional neural network AGC and gated cycle unit GRU
CN112085163A
