Air quality prediction method and device based on neural network and medium

By using TimeGAN model for data processing and improved LSTM model for prediction in air quality prediction, the problem of low accuracy of air quality prediction in the prior art is solved, and higher prediction accuracy and speed are achieved.

CN120069655APending Publication Date: 2025-05-30SICHUAN UNIVERSITY OF SCIENCE AND ENGINEERING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510132427.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-06
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In the prior art, the air quality index prediction model will directly affect the results of air quality prediction when the training data is poor or the quantity is insufficient, resulting in low prediction accuracy.

Method used

The air quality prediction method based on neural network is adopted, and by obtaining air quality data, the time series generation adversarial network TimeGAN model is used for feature extraction and reconstruction, new time series data is generated, and the original data is merged with the new data and scaling is performed. At the same time, an improved long and short-term memory network LSTM model is built, the original activation function is replaced with the corrected linear unit ReLU, and a full connection layer is added before it, and the model parameters are optimized through the adam optimization algorithm.

Benefits of technology

Through this method, the generated data better learns the distribution of the original data, improves the prediction accuracy of the model, and can capture the long-term dependence and nonlinear relationships in the time series data, thereby improving the accuracy of air quality prediction and effectively improving the prediction speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120069655A_ABST
    Figure CN120069655A_ABST
Patent Text Reader

Abstract

The invention discloses an air quality prediction method and device based on a neural network and a medium, and relates to the field of ambient air, and the method comprises the steps: obtaining air quality data of a test area; performing data enhancement on the air quality data based on a time series generative adversarial network TimeGAN model, obtaining data generated by data enhancement, and merging and scaling the data with the original air quality data; constructing an improved long short-term memory (LSTM) network model; based on the original multilayer LSTM model, replacing an activation function of the original multilayer LSTM with a correction linear unit ReLU, and adding a full connection layer in front of the correction linear unit ReLU; based on the zoomed air quality data, training an improved LSTM model to obtain an air quality prediction model for air quality prediction; and inputting air quality data to be detected into the air quality prediction model to obtain an air quality prediction result, thereby realizing accurate prediction of the air quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of ambient air, and particularly to an air quality prediction method, device and medium based on a neural network. Background Art

[0002] With the acceleration of the urbanization process, environmental pollution problems have become prominent, and among them, the air quality problem has attracted particular attention. Air pollution not only affects people's daily lives but is also closely related to health.

[0003] As an important branch of artificial intelligence technology, deep learning has demonstrated powerful data processing and pattern recognition capabilities in multiple fields in recent years. By constructing complex neural network models, it can extract features from data and learn the potential relationships between data, providing a solution for air quality prediction. However, due to the existing air quality index prediction model in the prior art ignoring the impact of training data on the model prediction performance, when the quality of training data is poor or the quantity is insufficient, it will directly affect the result of air quality prediction. Summary of the Invention

[0004] The present invention provides an air quality prediction method, device and medium based on a neural network to solve the above problems existing in the prior art, that is, the problem of how to improve the accuracy of air quality prediction in the prior art. The present invention provides an air quality prediction method based on a neural network, and the method includes:

[0005] Obtain the air quality data of the test area, and generate original air quality time series data according to the air quality data;

[0006] Based on the Time Series Generative Adversarial Network (TimeGAN) model, extract and reconstruct the features of the original air quality time series data, generate new time series data, and merge the original air quality data with the new time series data to obtain the merged air quality data, and then perform scaling processing on the merged air quality data;

[0007] Construct an improved Long Short-Term Memory (LSTM) model; based on the original multi-layer LSTM model, replace the activation function of the original multi-layer LSTM with the Rectified Linear Unit (ReLU), and add a fully connected layer before the Rectified Linear Unit (ReLU);

[0008] Based on the scaled air quality data, train the improved LSTM model to obtain an air quality prediction model for air quality prediction;

[0009] Input the air quality data to be detected into the air quality prediction model to obtain the air quality prediction result.

[0010] Optionally, the Time Series Generative Adversarial Network (TimeGAN) model specifically includes:

[0011] An embedding module, a reconstruction module, a generation module, and a discrimination module. Among them, the embedding module is used to extract the features of time series data; the reconstruction module is used to reconstruct the original time series data; the generation module is used to generate new time series data; and the discrimination module is used to determine whether the generated data is similar to the real data.

[0012] Optionally, before using the TimeGAN model to extract features and reconstruct the original air quality time series data, the K-nearest neighbor filling method is used to fill the original air quality time series data, and then the filled original air quality time series data is normalized, and feature selection is performed through the Pearson correlation coefficient.

[0013] Optionally, when training the improved Long Short-Term Memory (LSTM) model, the adaptive moment estimation (adam) optimization algorithm is used to optimize the hyperparameters of the improved LSTM model.

[0014] Optionally, the air quality data specifically includes:

[0015] Fine particulate matter PM2.5, inhalable particulate matter PM10, sulfur dioxide SO2, nitrogen dioxide NO2, carbon monoxide CO, and the 8-hour moving average concentration of ozone O3_8h.

[0016] The present invention provides an air quality prediction device based on a neural network, including:

[0017] An acquisition module, configured to acquire air quality data of a test area and generate original air quality time series data according to the air quality data;

[0018] A data processing module, configured to perform feature extraction and reconstruction on the original air quality time series data based on the Time Series Generative Adversarial Network (TimeGAN) model, generate new time series data, merge the original air quality data with the new time series data to obtain the merged air quality data, and then perform scaling processing on the merged air quality data;

[0019] A construction module, configured to construct an improved Long Short-Term Memory (LSTM) model; based on the original multi-layer LSTM model, replace the activation function of the original multi-layer LSTM with the Rectified Linear Unit (ReLU), and add a fully connected layer before the Rectified Linear Unit (ReLU);

[0020] A training module, configured to train the improved LSTM model based on the scaled air quality data to obtain an air quality prediction model for air quality prediction;

[0021] A prediction module for inputting air quality data to be detected into an air quality prediction model to obtain an air quality prediction result.

[0022] The present invention provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the above-mentioned air quality prediction method based on a neural network.

[0023] Compared with the prior art, the beneficial effects of the present invention are as follows: The present invention provides an air quality prediction method based on a neural network. This method fills air quality data by using the K-nearest neighbor filling method, and based on the Time Series Generative Adversarial Network (TimeGAN) model, extracts and reconstructs features from the original air quality time series data to generate new time series data, and merges the original air quality data with the new time series data, and then scales the merged air quality data to generate data that well learns the distribution of the original data, improving the prediction accuracy of the model; at the same time, based on the original multi-layer LSTM model, replacing the activation function of the original multi-layer LSTM with the Rectified Linear Unit (ReLU), and adding a fully connected layer before the ReLU, an improved LSTM model can be constructed. By using the improved LSTM model to predict air quality data, long-term dependencies and non-linear relationships in time series data can be captured, thereby improving the accuracy of air quality prediction; in addition, the improved LSTM model is optimized with reasonable hyperparameters by the adam optimization algorithm, effectively improving the air quality prediction speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] The drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present invention and used together with the specification to explain the principles of the present invention.

[0025] Figure 1 It is a flowchart of an air quality prediction method based on a neural network provided by an embodiment of the present invention;

[0026] Figure 2 It is a structure diagram of an LSTM model provided by an embodiment of the present invention;

[0027] Figure 3 It is a t-SNE graph provided by an embodiment of the present invention;

[0028] Figure 4 It is a loss curve graph before optimizing the parameters of the LSTM model provided by an embodiment of the present invention;

[0029] Figure 5 It is a loss curve graph after optimizing the parameters of the LSTM model provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0030] To make the objectives, technical solutions, and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without creative efforts shall fall within the protection scope of the present invention.

[0031] The technical solutions of the present invention and how the technical solutions of the present invention solve the above technical problems will be described in detail below with specific embodiments. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.

[0032] Figure 1 is a flowchart of an air quality prediction method based on a neural network provided by an embodiment of the present invention. As Figure 1 shown, an air quality prediction method based on a neural network shown in this embodiment includes:

[0033] S1: Obtain the air quality data of the test area, and generate the original air quality time series data according to the air quality data.

[0034] Exemplarily, the obtained air quality data may be, for example, fine particulate matter PM2.5, inhalable particulate matter PM10, sulfur dioxide S02, nitrogen dioxide NO2, carbon monoxide CO, and the 8-hour moving average concentration of ozone O3_8h.

[0035] S2: Based on the time series generative adversarial network TimeGAN model, perform feature extraction and reconstruction on the original air quality time series data, generate new time series data, merge the original air quality data with the new time series data, obtain the merged air quality data, and then perform scaling processing on the merged air quality data.

[0036] Optionally, before using the TimeGAN model to perform feature extraction and reconstruction on the original air quality time series data, use the K-nearest neighbor filling method to fill the original air quality time series data, and then perform normalization processing on the filled original air quality time series data, and perform feature selection through the Pearson correlation coefficient.

[0037] Exemplarily, the K-nearest neighbor filling method is used to fill the missing values in the original air quality time series data. Among the adjacent data, by finding the K data that are most similar to the missing value, that is, the K nearest neighbors, and then using these neighbor values to estimate the missing value. The formula of the method is:

[0038]

[0039] The maximum - minimum normalization method is used to normalize the data, turning the data into decimals within the interval (0, 1) to eliminate the influence of dimensions. The formula for this method is:

[0040]

[0041] Pearson correlation analysis is used to analyze whether there is a correlation among variables, whether the correlation is significant, and the magnitude of the correlation.

[0042] Table 1 Pearson Correlation Analysis Table

[0043]

[0044] Note: ***, **, * represent the significance levels of 1%, 5%, and 10% respectively

[0045] It can be seen from Table 1 above that variable X 1 (PM2.5) and variable X 2 (PM10) have a strong correlation with the dependent variable Y (AQI). Variable X 3 (SO 2 )、variable X 4 (NO 2 ) and variable X 5 (CO) have a moderate - degree linear relationship. Although the correlation between variable X 6 (O3_8h) and the dependent variable Y (AQI) is not significant, it has a correlation with variable X 5 (CO) and has a certain impact on its air quality index. All variables are used.

[0046] TimeGAN mainly consists of four parts, namely the embedding module, the reconstruction module, the generation module, and the discriminant module. The first two modules are auto - encoding components, and the latter two are adversarial components. When the auto - encoding components and the adversarial components are jointly trained, they can simultaneously learn encoding features, generate representations, and perform cross - time iteration. The embedding module can provide a latent space in which the adversarial network operates, and the latent dynamics of real data and synthetic data are synchronized through the supervised loss.

[0047] During the model training process, real time - series data is reconstructed in the auto - encoder, and its embedding and reproduction functions are:

[0048] h S = e S (s), h t = e X (h S , ht-1 , x t )

[0049]

[0050] Where S is static data, X is time series data, e is the embedding function of the corresponding variable, r is the reproduction function of the corresponding variable, and h S and h t is the latent space corresponding to the static data and time series data, and is the input data decoded by the reproduction function.

[0051] The generation function can be defined as:

[0052]

[0053] The adversarial function can be defined as:

[0054]

[0055] The three loss functions utilized in TimeGAN are as follows:

[0056]

[0057]

[0058] Exemplarily, the maximum-minimum normalization method can be adopted to normalize the data, converting the data into decimals within the range of (0, 1) to eliminate the influence of the dimension.

[0059] S3: Construct an improved long short-term memory network LSTM model; based on the original multi-layer LSTM model, replace the activation function of the original multi-layer LSTM with the rectified linear unit ReLU, and add a fully connected layer before the rectified linear unit ReLU.

[0060] As Figure 2 shown, the LSTM model contains three gating units, namely the input gate i t , the forget gate f t , the output gate o t , and C t-1 is the memory cell, is the candidate memory cell, X t is the input, h t-1 is the hidden state, and W ii is the weight.

[0061] The forward calculation formula of LSTM is as follows:

[0062]

[0063] h t = o t ⊙ tanh(C t )

[0064]

[0065] The backpropagation of the LSTM error term includes two directions. One is to calculate the error term at each time step starting from the current time step t, and the other is to propagate the error term to the previous layer and then calculate the gradient of each weight according to the corresponding error term.

[0066] LSTM has two hidden states h t and C t , and defines two deltas:

[0067]

[0068]

[0069] The loss function L(t) is divided into two parts. One part is the loss l(t) at the position of time step t, and the other part is the loss L(t + 1) after time step t, as follows:

[0070]

[0071] The delta of τ at the last sequence index position τh and delta τC are:

[0072]

[0073] Next, from delta (t+1)h and delta (t+1)C derive delta th and delta tC backward:

[0074]

[0075] ΔC = o t+1 ⊙ [1 - tanh 2 (C t+1 )]

[0076]

[0077] Therefore, the formulas for the gradients of each weight are as follows:

[0078]

[0079]

[0080] Exemplarily, when constructing an improved long short-term memory network (LSTM) model, the number of neurons in the first LSTM layer can be set to 32, which is the length of the input sequence and the number of features of the time step; the number of neurons in the second LSTM layer can be set to 16.

[0081] S4: Based on the air quality data after scaling processing, train the improved LSTM model to obtain an air quality prediction model for air quality prediction.

[0082] Exemplarily, when training the improved TimeGAN model, first set the environmental variable 'PYTHONSHSEED' to ensure that the memory address allocation of the dictionary object is repeatable, and set the seed value to 42; then define the time series generative adversarial network TimeGAN, construct the generator model, use two LSTMs and a time-distributed fully connected layer, and set the activation function to ReLU; construct the discriminator model, use two LSTMs and a time-distributed fully connected layer, and the activation function is sigmoid. Calculate the losses of the generator and the discriminator, and use the binary cross-entropy loss function; then load the preprocessed data, set the length of the time series to 30, the dimension of the generator latent space to 10, the number of hidden units in the LSTM layer to 24, and the length of the generated data to the length of the dataset; finally, train the TimeGAN model and set the number of training times to 150.

[0083] Exemplarily, after generating the data, first use PCA to perform pre-dimensionality reduction on the generated data, which can accelerate t-SNE; then extract 1000 samples from it and use t-SNE of sklearn for data evaluation as Figure 3 shown. The green dots are the original data points, and the red dots are the generated data points. It can be seen that the distribution of the newly generated data in the t-SNE space overlaps well with the original data, and the generated data maintains a similar degree of dispersion to the original data, indicating that the TimeGAN model can learn the original time series data relatively well.

[0084] Table 2 t-SNE distance information

[0085]

[0086] Table 2 is the t-SNE distance information table. The mean t-SNE distance of the original data in the table is 24.402195, and the mean t-SNE distance of the generated data is 24.80232. The difference between the two is only about 0.4. The standard deviation of the t-SNE distance of the original data is 7.4342155, and the standard deviation of the t-SNE distance of the generated data is 7.931808. The difference between the two is also only about 0.5. It can be seen that the generated data has learned the distribution of the original data well. Finally, the original data and the generated data are merged, and the merged data is rescaled.

[0087] Optionally, after training the model parameters using the adam optimization algorithm, the mean squared error (MSE) is used as the loss function to measure the difference between the predicted value and the actual value of the model.

[0088] As Figure 4 shown, the horizontal axis represents the training cycle, and the vertical axis represents the range of loss values. The solid line "Training loss" is the training loss curve, and the dashed line "Validation loss" is the prediction loss curve. It can be seen that as the training cycle increases, the loss value before parameter optimization of the improved LSTM model gradually decreases, indicating that the model is gradually learning and optimizing its parameters to better fit the data.

[0089] Then, after optimizing and adjusting the parameters of the improved LSTM model using the adam optimization algorithm, the obtained loss curve diagram is as Figure 5 shown. Obviously, its loss value has decreased, and the model can better fit the data.

[0090] S5: Input the air quality data to be detected into the air quality prediction model to obtain the air quality prediction result.

[0091] Exemplarily, according to the "Technical Regulations on Ambient Air Quality Index (AQI)", the AQI index is divided into the following six levels as shown in Table 3 below. When the AQI index is between 0 and 50, it is at level one, and the AQI index category is excellent; when the AQI index is between 51 and 100, it is at level two, and the AQI index category is good; when the AQI index is between 101 and 150, it is at level three, and the AQI index category is mild pollution; when the AQI index is between 151 and 200, it is at level four, and the AQI index category is moderate pollution; when the AQI index is between 201 and 300, it is at level five, and the AQI index category is severe pollution; when the AQI index is greater than 300, it is at level six, and the AQI index category is serious pollution.

[0092] Table 3 AQI Index and Corresponding Levels

[0093] AQI Index Level AQI Index Category 0-50 Level 1 Excellent 51-100 Level 2 Good 101-150 Level 3 Light Pollution 151-200 Level 4 Moderate Pollution 201-300 Level 5 Heavy Pollution >300 Level 6 Severe Pollution

[0094] The prediction model is for the changing trend of the air quality index and its pollution degree in Yibin City over a certain period in the future. First, the real data of the air quality index in Yibin City from June 2024 to September 2024 is collected; then the data of each month is divided into three time periods: the first, middle, and last ten days of the month; the processing process of the prediction data is the same as above; finally, the changing trend of the air quality index and the pollution degree of the real data and the prediction data are compared to evaluate the prediction model. From the comparison of the real value and the prediction value in Table 4, it can be seen that the accuracy rate of the air quality prediction using the prediction method proposed in the present invention is 75%.

[0095] Table 4 Comparison Table of Real Value and Prediction Value

[0096]

[0097] The above is the air quality prediction method based on neural network provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding air quality prediction device based on neural network, including:

[0098] An acquisition module, configured to acquire the air quality data of the test area and generate original air quality time series data according to the air quality data;

[0099] A data processing module, configured to generate a new time series data by extracting and reconstructing the features of the original air quality time series data based on the TimeGAN model of the time series generative adversarial network, merge the original air quality data with the new time series data to obtain the merged air quality data, and then perform scaling processing on the merged air quality data;

[0100] A construction module, configured to construct an improved long short-term memory network (LSTM) model; based on the original multi-layer LSTM model, replace the activation function of the original multi-layer LSTM with the rectified linear unit (ReLU), and add a fully connected layer before the rectified linear unit (ReLU);

[0101] A training module, configured to train the improved LSTM model based on the scaled air quality data to obtain an air quality prediction model for air quality prediction;

[0102] A prediction module, configured to input the air quality data to be detected into the air quality prediction model to obtain an air quality prediction result.

[0103] For the specific limitations of the air quality prediction device based on neural network, reference can be made to the limitations of the air quality prediction method based on neural network in the above text, which will not be elaborated here. Each module in the above air quality prediction device based on neural network can be implemented in whole or in part by software, hardware and their combination. The above modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so as to facilitate the processor to call and execute the operations corresponding to the above modules.

[0104] The present invention also provides a computer-readable storage medium, which stores a computer program that can be used to execute the above-provided air quality prediction method based on neural network.

[0105] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in the present invention.

Claims

1. A method for predicting air quality based on a neural network, characterized in that: include: Acquire air quality data of the test area, and generate original air quality time series data based on the air quality data; Based on the time series generative adversarial network TimeGAN model, the original air quality time series data is feature extracted and reconstructed to generate new time series data. The original air quality data is merged with the new time series data to obtain the merged air quality data, which is then scaled. Construct an improved long short-term memory network LSTM model; Based on the original multi-layer LSTM model, the activation function of the original multi-layer LSTM is replaced with the rectified linear unit ReLU, and a fully connected layer is added before the rectified linear unit ReLU; Based on the scaled air quality data, the improved LSTM model is trained to obtain an air quality prediction model for air quality prediction; The air quality data to be tested is input into the air quality prediction model to obtain the air quality prediction result.

2. The air quality prediction method based on a neural network as claimed in claim 1, characterized in that: The time series generative adversarial network TimeGAN model specifically includes: An embedding module, a reconstruction module, a generation module and a discrimination module; wherein the embedding module is used to extract the features of time series data; the reconstruction module is used to reconstruct the original time series data; the generation module is used to generate new time series data; and the discrimination module is used to determine whether the generated data is similar to the real data.

3. The air quality prediction method based on neural network as claimed in claim 1, characterized in that: Before using the TimeGAN model to extract and reconstruct the features of the original air quality time series data, the K nearest neighbor filling method is used to fill the original air quality time series data, and then the filled original air quality time series data is normalized, and feature selection is performed using the Pearson correlation coefficient.

4. The air quality prediction method based on neural network as claimed in claim 1, characterized in that: When the improved LSTM model is trained, the hyperparameters of the improved LSTM model are optimized by adopting the adaptive moment estimation adam optimization algorithm.

5. The air quality prediction method based on neural network as claimed in claim 1, characterized in that: The air quality data specifically includes: 8-hour sliding average concentration of fine particulate matter PM2.5, inhalable particulate matter PM10, sulfur dioxide S02, nitrogen dioxide NO2, carbon monoxide CO and ozone O3_8h.

6. An air quality prediction device based on a neural network, characterized in that: include: An acquisition module is used to acquire air quality data of the test area and generate original air quality time series data according to the air quality data; A data processing module is used to extract and reconstruct features of the original air quality time series data based on the time series generative adversarial network TimeGAN model, generate new time series data, merge the original air quality data with the new time series data, obtain the merged air quality data, and then perform scaling processing on the merged air quality data; Building module for building improved long short-term memory network LSTM model; Based on the original multi-layer LSTM model, the activation function of the original multi-layer LSTM is replaced with the rectified linear unit ReLU, and a fully connected layer is added before the rectified linear unit ReLU; A training module, used for training the improved LSTM model based on the scaled air quality data to obtain an air quality prediction model for air quality prediction; The prediction module is used to input the air quality data to be detected into the air quality prediction model to obtain the air quality prediction result.

7. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the air quality prediction method based on a neural network as described in any one of claims 1 to 5 is implemented.