Air quality index prediction method, device, terminal and storage medium
By using a recurrent neural network model based on a novel gating unit, the problem of traditional machine learning algorithms being unable to uncover time-series dependencies in air quality index prediction is solved, achieving higher prediction accuracy and shorter training time.
Patent Information
- Application Number
- CN202111215395.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-19
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2041-10-19
AI Technical Summary
Traditional machine learning algorithms are unable to effectively uncover the dependencies between time-series data, resulting in inaccurate air quality index predictions.
A recurrent neural network prediction model based on a new gating unit is adopted, including a forget gate, an input gate, and an anti-oversaturation conversion module. By acquiring air quality and meteorological datasets, performing data filling, transformation, and normalization, the data is then input into the pre-trained recurrent neural network model with the new gating unit for prediction.
It improves the accuracy of air quality index prediction, alleviates the gradient vanishing and gradient explosion problems in recurrent neural networks, and reduces model training time.
Smart Images

Figure CN113887815B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of air quality prediction, and in particular to an air quality index prediction method, device, terminal and storage medium. Background Art
[0002] As an important indicator for evaluating air pollution, the air quality index describes the cleanliness of the air or the degree of pollution and its impact on human health. Therefore, the accurate prediction of the air quality index has important guiding significance for people's production, life and health.
[0003] At present, air quality index prediction is usually based on traditional machine learning algorithms. However, traditional machine learning algorithms cannot well explore the dependencies between time series data, resulting in inaccurate air quality index prediction results. Summary of the invention
[0004] The embodiments of the present invention provide an air quality index prediction method, device, terminal and storage medium to solve the problem of inaccurate air quality index prediction results.
[0005] In a first aspect, an embodiment of the present invention provides an air quality index prediction method, comprising:
[0006] Acquire an air quality and meteorological data set at an air quality monitoring point within a preset time period; the air quality and meteorological data set includes air quality and meteorological data for multiple consecutive time periods, and the multiple consecutive time periods equally divide the preset time period;
[0007] Input the air quality and meteorological data sets into the pre-trained recurrent neural network prediction model based on the new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period;
[0008] Among them, the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence.
[0009] In one possible implementation, the new gating unit layer includes a plurality of new gating units;
[0010] The new gating unit includes a forget gate, an input gate, and an anti-saturation conversion module.
[0011] In one possible implementation, the expression of the forget gate is:
[0012] f t =σ(W fh ·h t-1 +W fx ·x t +b f )
[0013] The expression of the input gate is:
[0014] i t =σ(W ih ·h t-1 +W ix ·x t +c t-1 +b i )
[0015] The expression of the anti-oversaturation conversion module is:
[0016] Tri t =tanh(i t )
[0017] Among them, c t =f t ×c t-1 +Tri t ;h t =tanh(c t );
[0018] x t is the air quality and meteorological data of the tth period; f t is the output of the forget gate in the tth period; b f is the bias term of the forget gate; σ(x) is the Sigmoid function; W fx is the weight matrix of the forget gate for air quality and meteorological data; h t-1 is the output of the new gating unit in the t-1th period; W fh is the weight matrix of the output of the forget gate for the new gating unit; i t is the output of the input gate in the tth period; W ih is the weight matrix of the input gate for the output of the new gating unit; W ix is the weight matrix of the input gate for air quality and meteorological data; c t-1 is the cell state of the new gated unit in the t-1th period; b i is the bias term of the input gate; Tri t To prevent oversaturation, the output value of the conversion module in the tth period; c t is the cell state of the new gated unit in the tth period; h t is the output of the new gating unit in the tth period.
[0019] In a possible implementation, after obtaining the air quality and meteorological data set of the air quality monitoring point within a preset time period, the air quality index prediction method further includes:
[0020] Perform data filling, data transformation and data normalization on the air quality and meteorological data sets to obtain processed air quality and meteorological data sets;
[0021] Accordingly, the air quality and meteorological data sets are input into the pre-trained recurrent neural network prediction model based on the new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period, including:
[0022] The processed air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on the new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period.
[0023] In one possible implementation, the air quality and meteorological data of the tth time period include the air quality index, CO concentration, NO2 concentration, O3 concentration, PM10 concentration, PM2.5 concentration, SO2 concentration, temperature, humidity, weather and wind speed of the tth time period.
[0024] In a second aspect, an embodiment of the present invention provides an air quality index prediction device, comprising:
[0025] An acquisition module is used to acquire air quality and meteorological data sets at air quality monitoring points within a preset time period; the air quality and meteorological data sets include air quality and meteorological data of multiple continuous time periods, and the multiple continuous time periods divide the preset time period into equal parts;
[0026] A prediction module is used to input air quality and meteorological data sets into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain the predicted value of the air quality index for the next period of a preset time period;
[0027] Among them, the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence.
[0028] In one possible implementation, the new gating unit layer includes a plurality of new gating units;
[0029] The new gating unit includes a forget gate, an input gate, and an anti-saturation conversion module.
[0030] In one possible implementation, the expression of the forget gate is:
[0031] f t =σ(W fh ·h t-1 +W fx ·x t +b f )
[0032] The expression of the input gate is:
[0033] i t =σ(W ih ·h t-1 +W ix ·x t +c t-1 +b i )
[0034] The expression of the anti-oversaturation conversion module is:
[0035] Tri t =tanh(i t )
[0036] Among them, c t =f t ×c t-1 +Tri t ;h t =tanh(c t );
[0037] x t is the air quality and meteorological data of the tth period; f t is the output of the forget gate in the tth period; b f is the bias term of the forget gate; σ(x) is the Sigmoid function; W fx is the weight matrix of the forget gate for air quality and meteorological data; h t-1 is the output of the new gating unit in the t-1th period; W fh is the weight matrix of the output of the forget gate for the new gating unit; i t is the output of the input gate in the tth period; W ih is the weight matrix of the input gate for the output of the new gating unit; W ix is the weight matrix of the input gate for air quality and meteorological data; c t-1 is the cell state of the new gated unit in the t-1th period; b i is the bias term of the input gate; Tri t is the output value of the anti-saturation conversion module in the tth period; ct is the cell state of the new gating unit in the tth period; h t is the output of the new gating unit in the tth period.
[0038] In a third aspect, an embodiment of the present invention provides a terminal, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the air quality index prediction method as described in the first aspect or any possible implementation method of the first aspect are implemented.
[0039] In a fourth aspect, an embodiment of the present invention 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 steps of the air quality index prediction method as described in the first aspect or any possible implementation method of the first aspect are implemented.
[0040] The embodiment of the present invention provides an air quality index prediction method, device, terminal and storage medium, which obtains air quality and meteorological data sets at air quality monitoring points within a preset time period; the air quality and meteorological data sets include air quality and meteorological data of multiple continuous time periods, and the multiple continuous time periods divide the preset time period into equal parts; the air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain an air quality index prediction value for the next time period of the preset time period; the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence, and prediction is performed through the prediction model, which can solve the problem that traditional machine learning algorithms cannot well explore the dependency relationship between time series data, and can improve the accuracy of air quality index prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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 invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1 is a flow chart of an implementation of an air quality index prediction method provided by an embodiment of the present invention;
[0043] Figure 2 is a schematic diagram of the structure of a recurrent neural network prediction model based on a new gating unit provided in an embodiment of the present invention;
[0044] Figure 3 is a schematic structural diagram of a new gate control unit provided in an embodiment of the present invention;
[0045] Figure 4 is a curve diagram of the tanh function and the sigmoid function provided in an embodiment of the present invention;
[0046] Figure 5 is a data flow diagram of a new gating unit provided by an embodiment of the present invention;
[0047] Figure 6 is a curve schematic diagram of the σ(x) function provided in an embodiment of the present invention;
[0048] Figure 7 is (1-tanh(σ(y)) provided by the embodiment of the present invention 2 ) Schematic diagram of the curve of the σ′(y) function;
[0049] Figure 8 is a curve schematic diagram of the z(x, y) function provided by an embodiment of the present invention;
[0050] Fig. 9 It is a schematic diagram comparing the experimental results of the NGCU model, LSTM model and GRU model provided in an embodiment of the present invention;
[0051] Fig.10 is a schematic diagram of the structure of an air quality index prediction device provided by an embodiment of the present invention;
[0052] Fig.11 is a schematic diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] 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 invention. However, it should be clear to those skilled in the art that the present invention may 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 invention.
[0054] In order to make the purpose, technical solutions and advantages of the present invention more clear, specific embodiments will be described below in conjunction with the accompanying drawings.
[0055] See also Figure 1 , which shows an implementation flow chart of the air quality index prediction method provided by an embodiment of the present invention, wherein the execution subject of the air quality index prediction method may be a terminal.
[0056] See also Figure 1 , the air quality index prediction method is detailed as follows:
[0057] In S101, an air quality and meteorological data set of an air quality monitoring point within a preset time period is obtained; the air quality and meteorological data set includes air quality and meteorological data of multiple consecutive time periods, and the multiple consecutive time periods divide the preset time period into equal parts.
[0058] Among them, the air quality monitoring point is the area where the air quality index is to be predicted.
[0059] The preset time period is usually selected from a period before the period to be predicted. The duration of each period is equal, which is one hour. Assume that the preset time period includes n consecutive time periods, and the last time period in the preset time period is consecutive with the time period to be predicted, n≥2; the air quality and meteorological data set includes the air quality and meteorological data of n consecutive time periods.
[0060] In some embodiments, the air quality and meteorological data of the tth time period include the air quality index, CO concentration, NO2 concentration, O3 concentration, PM10 concentration, PM2.5 concentration, SO2 concentration, temperature, humidity, weather and wind speed of the tth time period. 1≤t≤n, n is the number of time periods included in the preset time period.
[0061] The air quality index is calculated mainly through six pollutants: PM2.5, PM10, CO, NO2, SO2, and O3. In addition to being affected by basic pollutants such as ground PM2.5, PM10, and CO, air quality is also affected by meteorological conditions, especially when air pollution emissions are relatively stable, weather, temperature, humidity, and wind force become key factors affecting air quality. Therefore, in this embodiment, air quality and meteorological data include air quality index, CO concentration, NO2 concentration, O3 concentration, PM10 concentration, PM2.5 concentration, SO2 concentration, temperature, humidity, weather, and wind force. Among them, wind force can be wind force level.
[0062] In S102, the air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on a new gate control unit (NGCU) to obtain a predicted value of the air quality index for the next period of a preset time period;
[0063] Among them, see Figure 2 ,The recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer that are connected in sequence.
[0064] In this embodiment, the air quality and meteorological data sets obtained above are input into a pre-trained recurrent neural network prediction model based on a new gating unit, and the air quality index prediction value of the next time period (i.e., the time period to be predicted) of the preset time period can be obtained.
[0065] Among them, the recurrent neural network prediction model based on the new gating unit can be referred to as the NGCU model.
[0066] In a possible implementation, before the above S102, the above air quality index prediction method may further include:
[0067] Obtain a training sample set, the training sample set includes multiple air quality and meteorological data sets, each of which is marked with the corresponding air quality index of the next period;
[0068] Based on the training sample set, the pre-established recurrent neural network prediction model based on the new gating unit is trained to obtain a trained recurrent neural network prediction model based on the new gating unit.
[0069] Among them, training can be performed based on existing methods, which will not be described in detail.
[0070] It can be seen from the above description that this embodiment obtains air quality and meteorological data sets at air quality monitoring points within a preset time period; the air quality and meteorological data sets include air quality and meteorological data of multiple continuous time periods, and the multiple continuous time periods divide the preset time period into equal parts; the air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain an air quality index prediction value for the next time period of the preset time period; the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence. This embodiment proposes a new recurrent neural network prediction description. Prediction through this prediction model can solve the problem that traditional machine learning algorithms cannot well explore the dependency relationship between time series data, and can improve the accuracy of air quality index prediction results.
[0071] In some embodiments, the new gating unit layer includes a plurality of new gating units;
[0072] The new gating unit includes a forget gate, an input gate, and an anti-saturation conversion module.
[0073] The structure of the NGCU model is as follows Figure 2 As shown in Figure 1, the model includes an input layer, a new gated unit layer, and an output layer. The input layer is used to input the relevant data of the time series, namely the air quality and meteorological data set mentioned above; the new gated unit layer predicts the time series; and the output layer outputs the output value of the new gated unit layer to complete the prediction of the next time series data.
[0074] NGCU simplifies calculations to achieve effective control of time series data by the forget gate and input gate. Its structure is as follows: Figure 3 shown. Figure 3 In the example, Forget Gate is the forget gate, Input Gate is the input gate, and Transform Module is the anti-saturation transformation module. The forget gate controls the data information saved from the previous period to the current period. The input gate controls the data information saved from the current period to the current period. NGCU consists of the forget gate and the input gate. The W parameter (W fh , W fx, W ih and W ix ) is 4, and the B parameter (b f and b i ) is 2. In order to improve the sensitivity of NGCU learning, the anti-saturation conversion module Tri is introduced. In addition, NGCU introduces the entire data flow information c up to the previous moment in the "input gate" calculation process. t-1 .
[0075] In some embodiments, the expression of the forget gate is:
[0076] f t =σ(W fh ·h t-1 +W fx ·x t +b f ) (1)
[0077] The expression of the input gate is:
[0078] i t =σ(W ih ·h t-1 +W ix ·x t +c t-1 +b i ) (2)
[0079] The expression of the anti-oversaturation conversion module is:
[0080] Tri t =tanh(i t ) (3)
[0081] in,
[0082] c t =f t ×c t-1 +Tri t (4)
[0083] h t =tanh(c t ) (5)
[0084] x t is the air quality and meteorological data of the tth period; f t is the output of the forget gate in the tth period; b f is the bias term of the forget gate; σ(x) is the Sigmoid function; W fx is the weight matrix of the forget gate for air quality and meteorological data; h t-1 is the output of the new gating unit in the t-1th period; W fhis the weight matrix of the output of the forget gate for the new gating unit; i t is the output of the input gate in the tth period; W ih is the weight matrix of the input gate for the output of the new gating unit; W ix is the weight matrix of the input gate for air quality and meteorological data; c t-1 is the cell state of the new gated unit in the t-1th period; b i is the bias term of the input gate; Tri t To prevent oversaturation, the output value of the conversion module in the tth period; c t is the cell state of the new gated unit in the tth period; h t is the output of the new gating unit in the tth period.
[0085] Forget Gate t It mainly determines how much data from the previous period can be retained in the current period, where x t is the input vector of the tth period, that is, the tth component of the input sequence x, x t By comparing with the weight matrix W fx Multiply to perform a linear transformation. h t-1 What is saved is the data of the previous period t-1, h t-1 By comparing with the weight matrix W fh The two parts of data are added together and then calculated by the Sigmoid activation function, so the numerical result f t Between (0, 1). Its calculation formula is formula (1).
[0086] Input Gate i t It mainly determines how much of the input data in the current period can be retained in the current period. Compared with the "forget gate", the input gate i of NGCU t Introduce the entire data flow information c up to the previous period t-1 , so the "input gate" has a memory effect on the retention of the current period of data. The "input gate" inside the NGCU uses the Sigmoid activation function. When the value of x is less than -3 and greater than 3, the value of the Sigmoid activation function will fall into the oversaturation range. Therefore, when the input data enters the oversaturation area of the input gate, the value will not change significantly, resulting in a decrease in the sensitivity of learning. Its calculation formula is formula (2).
[0087] In order to improve the sensitivity of model learning, the anti-saturation conversion module Tri is introduced in NGCU, as shown in formula (3). The function graph is as follows: Figure 4 As shown. The Sigmoid activation function takes values in the range of (0, 1). When the data passes through the input gate, it is transformed by the conversion module Tri and the resulting value will be in tanh(it ) value, so the obtained value will be more significant.
[0088] c t It is the data information retained from the beginning to the current period. Its calculation formula is formula (4).
[0089] h t The data information retained in the current period. ct controls how much data information in the current period can be retained in the next period through the tanh function. Its calculation formula is formula (5).
[0090] The NGCU model provided in this embodiment can alleviate the problems of "gradient vanishing" and "gradient exploding" in recurrent neural networks, improve the prediction accuracy of the air quality index, and reduce the model training time.
[0091] The following is a formula derivation to further verify the model's ability to alleviate "gradient disappearance" and "gradient explosion":
[0092] NGCU simple data flow is as follows Figure 5 As shown, for a given input sequence <x1,x2,x3,x4,....,x k > represents x t And the encoding of its previous data information. The entire network has two parameter matrices [W fh , W fx ],[W ih , W ix ],h t The calculation formula is shown in formula (5). Where c0 and h0 are the initialization states of the hidden layer, which are generally zero vectors.
[0093] Let W = [W fh , W fx , W ih , W ix ], L t is the encoding h t The corresponding loss is a function of W. L is the total loss. The derivative of W with respect to L is shown in formula (6):
[0094]
[0095] Among them, T=n.
[0096] The recurrent neural network updates the W parameter using formula (7):
[0097]
[0098] in It can be written as formula (8):
[0099]
[0100] By simplifying, we can get the following formula (9):
[0101]
[0102] Among them, c t The calculation formula of is shown in formula (4).
[0103] C t Taking the derivative, we can get formula (10):
[0104]
[0105] The total loss can be written as formula (11):
[0106]
[0107] Let x be equal to formula (12):
[0108] x=W fh ·h t-1 +W fx ·x t +b f (12)
[0109] Let y be equal to formula (13):
[0110] y=W ih ·h t-1 +W ix ·x t +c t-1 +b i (13)
[0111] Then z(x, y) is equal to formula (14):
[0112] z(x,y)=σ(x)+(1-tanh(σ(y)) 2 )σ′(y) (14)
[0113] Among them, the σ(x) function is as follows Figure 6 As shown, (1-tanh(σ(y)) 2 )σ′(y) function is as follows Figure 7 As shown, where σ(x) ranges from (0, 1) and σ(y) ranges from (0, 1), so (1-tanh(σ(y)) 2 )σ′(y) function value is (0.1720, 0.1880). Function gradient z is as follows Figure 8 As shown, from Figure 8 As can be seen, the value range of the function gradient z will be more reasonable.
[0114] In some embodiments, after obtaining the air quality and meteorological data set of the air quality monitoring point within a preset time period, the air quality index prediction method further includes:
[0115] Perform data filling, data transformation and data normalization on the air quality and meteorological data sets to obtain processed air quality and meteorological data sets;
[0116] Accordingly, the air quality and meteorological data sets are input into the pre-trained recurrent neural network prediction model based on the new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period, including:
[0117] The processed air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on the new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period.
[0118] After obtaining air quality and meteorological data, there are often problems such as missing values, duplicate values, and irregular writing formats. In order to improve the availability, accuracy, and stability of the data, the original data needs to be further filled and converted to numerical values. For missing values, the average value of the data before and after can be used to fill them. For duplicate values, deduplication can be performed. For non-numeric data, data conversion can be performed to convert them into numbers.
[0119] Since there are large differences between the items in the data, standardization processing is required before training. The present invention uses the min-max standardization method to perform data standardization processing, and its calculation formula is formula (15):
[0120]
[0121] Among them, min is the minimum value in the corresponding items of the input data, max is the maximum value in the corresponding items of the input data, x is the value to be standardized, and y is the standardized value.
[0122] The following example verifies that the NGCU model has better beneficial effects than the LSTM (Long Short-Term Memory) model and the GRU (Gated Recurrent Unit) model.
[0123] The hourly data of an air quality monitoring point from 00:00 on January 1, 2017 to 23:00 on September 30, 2020 were selected, totaling 32,856 data. All air quality and meteorological data were merged and stored in CSV files in chronological order. Among them, 26,282 data from 00:00 on January 1, 2017 to 23:00 on December 31, 2019 were used as the training set, and 6,574 data from 00:00 on January 1, 2020 to 23:00 on September 30, 2020 were used as the test set.
[0124] Combined with the above data, the specific implementation steps of this embodiment are as follows:
[0125] (1) Data preprocessing process;
[0126] (1.1) Feature screening;
[0127] The air quality index is calculated mainly through six pollutants: PM2.5, PM10, CO, NO2, SO2, and O3. In addition to being affected by basic pollutants such as ground PM2.5, PM10, and CO, air quality is also affected by meteorological conditions, especially when air pollution emissions are relatively stable, weather, temperature, humidity, and wind speed become key factors affecting air quality. Therefore, the data input items in this experiment include air quality index, CO, NO2, O3, PM10, PM2.5, SO2, temperature, humidity, weather, and wind speed.
[0128] (1.2) Data filling and conversion;
[0129] In order to improve the availability, accuracy and stability of the data, the original data needs to be further processed. Some of the original data are shown in Table 1.
[0130] Table 1 Part of the original data
[0131]
[0132] In this embodiment, the missing values are filled with the average of the previous hour's data and the next hour's data. For repeated data, such as the wind data with duplicate items of winp and winpid, this experiment retains the first item and deletes the duplicate items that appear later. The weather data is transformed as shown in Table 2.
[0133] Table 2 Data conversion
[0134]
[0135] After filling and transforming the original data, some of the data are shown in Table 3.
[0136] Table 3 Part of the processed data
[0137]
[0138]
[0139] (1.3) Data normalization;
[0140] Since the differences between different related input items are relatively large, standardization processing is required before training. This embodiment uses the min-max standardization method to perform data standardization processing.
[0141] (2) Model comparison experiment
[0142] In order to prove the effectiveness and advantages of NGCU in predicting the air quality index for the next hour, this experiment used the same experimental data on the same machine to predict the air quality index for the next hour using three prediction models: LSTM, GRU, and NGCU. 2 These three evaluation indicators make an overall assessment of the prediction results.
[0143] (2.1) Parameter settings
[0144] The parameter settings of the three prediction models LSTM, GRU and NGCU are shown in Table 4.
[0145] Table 4 Parameter settings of the three prediction models LSTM, GRU and NGCU
[0146] parameter value Number of hidden units 10 Activation Function tanh Learning Rate 0.001 Loss Function MAE Training rounds epochs 100 batch_size 64 Time step 5 Optimizer Adam
[0147] (2.2) Model comparison experiment
[0148] Using the same experimental data on the same machine, the LSTM, GRU and NGCU prediction models were used to predict the air quality index for the next hour. The comparison between the actual value and the predicted value of the air quality index is shown in the figure below. Fig. 9 The experimental results are shown in Table 5.
[0149] Table 5 Evaluation table of experimental results of three prediction models: LSTM, GRU and NGCU
[0150]
[0151] MAE, MSE, R 2 Among these three evaluation indicators, the smaller the values of MAE and MSE, the closer the predicted value is to the true value, indicating that the prediction is more accurate. 2The closer it is to 1, the smaller the error. From the evaluation results in Table 5, we can see that the prediction error of the air quality index by the NGCU model is smaller than that of the LSTM and GRU models, and the model training time is also reduced.
[0152] The air quality index prediction method based on LSTM has too many parameters, so the calculation of the model is too complicated, resulting in too long training time. Compared with LSTM, the time series prediction method based on the GRU model has a reduced training time due to the reduction in the number of parameters. However, through research, the prediction accuracy and model training time of the time series prediction based on GRU can still be improved. Therefore, the embodiment of the present invention proposes NGCU, which aims to improve the model's prediction accuracy for the air quality index and reduce the model training time under the premise of ensuring that the model can alleviate the "gradient disappearance" and "gradient explosion" problems of the recurrent neural network.
[0153] It should be understood that the order of execution of the steps in the above embodiment does not necessarily 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 embodiment of the present invention.
[0154] The following is an embodiment of the device of the present invention. For details not described in detail therein, reference may be made to the corresponding method embodiment described above.
[0155] Fig.10 The structure diagram of the air quality index prediction device provided by the embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0156] like Fig.10 As shown, the air quality index prediction device 30 includes: an acquisition module 31 and a prediction module 32.
[0157] An acquisition module 31 is used to acquire an air quality and meteorological data set at an air quality monitoring point within a preset time period; the air quality and meteorological data set includes air quality and meteorological data of multiple consecutive time periods, and the multiple consecutive time periods divide the preset time period into equal parts;
[0158] A prediction module 32 is used to input the air quality and meteorological data sets into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain a predicted value of the air quality index for the next period of a preset time period;
[0159] Among them, the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence.
[0160] In one possible implementation, the new gating unit layer includes a plurality of new gating units;
[0161] The new gating unit includes a forget gate, an input gate, and an anti-saturation conversion module.
[0162] In one possible implementation, the expression of the forget gate is:
[0163] f t =σ(W fh ·h t-1 +W fx ·x t +b f )
[0164] The expression of the input gate is:
[0165] i t =σ(W ih ·h t-1 +W ix ·x t +c t-1 +b i )
[0166] The expression of the anti-oversaturation conversion module is:
[0167] Tri t =tanh(i t )
[0168] Among them, c t =f t ×c t-1 +Tri t ;h t =tanh(c t );
[0169] x t is the air quality and meteorological data of the tth period; f t is the output of the forget gate in the tth period; b f is the bias term of the forget gate; σ(x) is the Sigmoid function; W fx is the weight matrix of the forget gate for air quality and meteorological data; h t-1 is the output of the new gating unit in the t-1th period; W fh is the weight matrix of the output of the forget gate for the new gating unit; i t is the output of the input gate in the tth period; W ih is the weight matrix of the input gate for the output of the new gating unit; W ix is the weight matrix of the input gate for air quality and meteorological data; c t-1 is the cell state of the new gated unit in the t-1th period; b i is the bias term of the input gate; Tri tTo prevent oversaturation, the output value of the conversion module in the tth period; c t is the cell state of the new gated unit in the tth period; h t is the output of the new gating unit in the tth period.
[0170] In a possible implementation, the air quality index prediction device 30 further includes a preprocessing module.
[0171] The preprocessing module is used to:
[0172] Perform data filling, data transformation and data normalization on the air quality and meteorological data sets to obtain processed air quality and meteorological data sets;
[0173] Accordingly, the prediction module is specifically used for:
[0174] The processed air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on the new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period.
[0175] In one possible implementation, the air quality and meteorological data of the tth time period include the air quality index, CO concentration, NO2 concentration, O3 concentration, PM10 concentration, PM2.5 concentration, SO2 concentration, temperature, humidity, weather and wind speed of the tth time period.
[0176] Fig.11 is a schematic diagram of a terminal provided by an embodiment of the present invention. Fig.11 As shown, the terminal 4 of this embodiment includes: a processor 40, a memory 41, and a computer program 42 stored in the memory 41 and executable on the processor 40. When the processor 40 executes the computer program 42, the steps in the above-mentioned air quality index prediction method embodiments are implemented, for example Figure 1 Alternatively, when the processor 40 executes the computer program 42, the functions of each module / unit in the above-mentioned device embodiments are realized, for example, Fig.10 Functions of the modules / units 31 to 32 are shown.
[0177] Exemplarily, the computer program 42 may be divided into one or more modules / units, which are stored in the memory 41 and executed by the processor 40 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 42 in the terminal 4. For example, the computer program 42 may be divided into Fig.10 Modules / units 31 to 32 are shown.
[0178] The terminal 4 may include, but is not limited to, a processor 40 and a memory 41. Those skilled in the art will appreciate that Fig.11 It is only an example of terminal 4 and does not constitute a limitation on terminal 4. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal may also include input and output devices, network access devices, buses, etc.
[0179] The processor 40 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 any conventional processor, etc.
[0180] The memory 41 may be an internal storage unit of the terminal 4, such as a hard disk or memory of the terminal 4. The memory 41 may also be an external storage device of the terminal 4, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the terminal 4. The memory 41 is used to store the computer program and other programs and data required by the terminal. The memory 41 may also be used to temporarily store data that has been output or is to be output.
[0181] 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.
[0182] 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.
[0183] Those skilled 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 the present invention.
[0184] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are only 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.
[0185] 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.
[0186] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0187] If the integrated module / 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 invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned air quality index prediction method embodiments can be implemented. 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 include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0188] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those 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 invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for predicting air quality index, characterized in that: include: Acquire an air quality and meteorological data set at an air quality monitoring point within a preset time period; the air quality and meteorological data set includes air quality and meteorological data of multiple consecutive time periods, and the multiple consecutive time periods divide the preset time period into equal parts; Inputting the air quality and meteorological data sets into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain a predicted value of the air quality index for the next period of the preset time period; Wherein, the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence; The new gating unit layer includes a plurality of new gating units; The new gating unit includes a forget gate, an input gate and an anti-oversaturation conversion module; The expression of the forget gate is: f t =σ(W fh ·h t-1 +W fx ·x t +b f ) The expression of the input gate is: i t =σ(W ih ·h t-1 +W ix ·x t +c t-1 +b i ) The expression of the anti-oversaturation conversion module is: Tri t =tanh(i t ) Among them, c t =f t ×c t-1 +Tri t ;h t =tanh(c t ); x t is the air quality and meteorological data of the tth period; f t is the output of the forget gate in the tth period; b f is the bias term of the forget gate; σ(x) is the Sigmoid function; W fx h is the weight matrix of the forget gate for air quality and meteorological data; t-1 is the output of the new gating unit in the t-1th period; W fh is the weight matrix of the output of the forget gate for the new gating unit; i t is the output of the input gate in the tth period; W ih is the weight matrix of the input gate for the output of the new gating unit; W ix is the weight matrix of the input gate for air quality and meteorological data; c t-1 is the cell state of the new gating unit in the t-1th time period; b i is the bias term of the input gate; Tri t is the output value of the anti-oversaturation conversion module in the tth period; c t is the cell state of the new gating unit in the tth time period; h t is the output of the new gating unit in the tth time period.
2. The air quality index prediction method according to claim 1, characterized in that: After obtaining the air quality and meteorological data set of the air quality monitoring point within a preset time period, the air quality index prediction method further includes: Performing data filling, data conversion and data normalization processing on the air quality and meteorological data sets to obtain processed air quality and meteorological data sets; Accordingly, the air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain the predicted value of the air quality index for the next period of the preset time period, including: The processed air quality and meteorological data sets are input into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain an air quality index prediction value for the next period of the preset time period.
3. The air quality index prediction method according to any one of claims 1 to 2, characterized in that: The air quality and meteorological data for the tth period include the air quality index, CO concentration, NO2 concentration, O3 concentration, PM10 concentration, PM2.5 concentration, SO2 concentration, temperature, humidity, weather and wind speed for the tth period.
4. An air quality index prediction device, characterized in that: include: An acquisition module, used to acquire an air quality and meteorological data set of an air quality monitoring point within a preset time period; the air quality and meteorological data set includes air quality and meteorological data of multiple consecutive time periods, and the multiple consecutive time periods divide the preset time period into equal parts; A prediction module, used to input the air quality and meteorological data sets into a pre-trained recurrent neural network prediction model based on a new gating unit to obtain a predicted value of the air quality index for the next period of the preset time period; Wherein, the recurrent neural network prediction model based on the new gating unit includes an input layer, a new gating unit layer and an output layer connected in sequence; The new gating unit layer includes a plurality of new gating units; The new gating unit includes a forget gate, an input gate and an anti-oversaturation conversion module; The expression of the forget gate is: f t =σ(W fh ·h t-1 +W fx ·x t +b f ) The expression of the input gate is: i t =σ(W ih ·h t-1 +W ix ·x t +c t-1 +b i ) The expression of the anti-oversaturation conversion module is: Tri t =tanh(i t ) Among them, c t =f t ×c t-1 +Tri t ;h t =tanh(c t ); x t is the air quality and meteorological data of the tth period; f t is the output of the forget gate in the tth period; b f is the bias term of the forget gate; σ(x) is the Sigmoid function; W fx h is the weight matrix of the forget gate for air quality and meteorological data; t-1 is the output of the new gating unit in the t-1th period; W fh is the weight matrix of the output of the forget gate for the new gating unit; i t is the output of the input gate in the tth period; W ih is the weight matrix of the input gate for the output of the new gating unit; W ix is the weight matrix of the input gate for air quality and meteorological data; c t-1 is the cell state of the new gating unit in the t-1th time period; b i is the bias term of the input gate; Tri t is the output value of the anti-oversaturation conversion module in the tth period; c t is the cell state of the new gating unit in the tth time period; h t is the output of the new gating unit in the tth time period.
5. A terminal comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the air quality index prediction method as described in any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the air quality index prediction method as described in any one of claims 1 to 3 are implemented.
