# Air Quality Prediction Model Using Deep Learning in Internet of Things Environmental Monitoring System

Authors: Yongliang Feng
Journal: Mobile Information Systems
 (2022)

---

## Abstract

In order to realize the accurate prediction of spatial-temporal air quality index, this paper constructs a STAQI prediction model based on deep learning, including data processing, spatial feature acquisition, temporal feature acquisition, and STAQI prediction. Firstly, the spatial interpolation method is used to optimize the sample data set to provide reliable data; the improved graph convolutional network and the improved long short-term memory are used to effectively extract the spatial and temporal distribution characteristics of AQI data; and then, the extreme learning machine model is used to accurately predict and analyze AQI data. Simulation results show that the evaluation indexes RMSE and MAE of the constructed prediction model are 4.51 and 3.92, respectively, showing excellent curve fitting ability and AQI prediction ability.


---

## Body

## 1. Introduction

With the rapid development of the world economy and the acceleration of industrialization and urbanization, energy consumption has increased sharply, and the problem of air pollution is particularly prominent [1, 2]. In recent years, the concentration of air pollutants exceeds the standard frequently [3, 4]. Air pollution not only leads to a significant decline in atmospheric visibility in some areas but also poses a great threat to human health [5].Research shows that suspended particulate matter is one of the most deadly air pollutants, containing a large number of harmful substances. Long-term exposure to the suspended particulate matter will increase the risk of the respiratory system, cardiovascular system, lung cancer, and other diseases, and even increase mortality [6, 7]. Therefore, air quality index (AQI) is the fundamental point to achieve comprehensive environmental governance, which is of great significance to people’s healthy life and government decision-making [8].Traditional air quality prediction can be divided into numerical prediction method and regression statistical prediction method. The principle of the numerical prediction model is to simulate the pollutant movement process by using the monitoring data of a fixed number of air quality monitoring stations. It depends on a large number of empirical assumptions and parameters, which is not enough to accurately reflect the real atmospheric environment, and its prediction performance is subject to certain constraints [9]. The regression statistical method focuses on analyzing the internal laws of the data, does not involve the complex physical and chemical reactions between air pollutants, and uses the statistical modeling method to obtain the predicted value, which depends on the stationary hypothesis, which limits the fitting ability of the model to a certain extent [10].To solve the above problems, this paper analyzes the time and spatial aspects, and constructs a spatial-temporal air quality index (STAQI) prediction model based on deep learning. The model mainly optimizes the Graph Convolutional Network (GCN) and gated recurrent unit (GRU) models to realize the deep extraction of spatial features of the STAQI. At the same time, the F-LSTM prediction network can also quickly obtain the time characteristics of data, so as to improve the fitting ability of the prediction model. Simulation results show that the proposed model has excellent curve fitting ability and prediction ability.


## 2. Air Quality Monitoring and Data Preprocessing

### 2.1. Air Quality Monitoring

Air quality prediction mainly faces the following four challenges:(1)
Air quality will be affected by many factors, such as traffic. These influencing factors are difficult to obtain or model in advance.(2)
Air quality shows high uncertainty in the time dimension [20, 21]. As shown in Figure 1, taking the PM2.5 mass concentration parameter, one of the main pollutants characterizing air quality, as an example, the mass concentration at each time in a given 2d varies greatly, and the PM2.5 mass concentration shows significant changes at different times in 1d, and the difference between the highest and lowest mass concentrations can reach 100 mg/m3.(3)
There are significant differences in air quality data in different geographical locations [22]. As shown in Figure 2, the PM2.5 mass concentration change curves of three monitoring stations in Beijing were different within 1d. The two monitoring points A and B are close, while the monitoring point C is located in the suburbs and far away from monitoring points A and B. It can be seen from Figure 2 that in most periods, the PM2.5 mass concentration monitored by the three stations is quite different, and the PM2.5 mass concentration of monitoring point C is relatively low.(4)
Due to the limitation of practical conditions, there will be a certain amount of missing basic data obtained for prediction, such as the lack of timestamp attribute value in the data entry or the lack of specific monitoring data.Figure 1
Change in mass concentration during different monitoring periods.Figure 2
Changes in mass concentration at different monitoring stations.Table1 lists the missing data of the real data set used in the study. PM10 lacks tens of thousands of data, and other data are also missing to varying degrees, which has a great impact on the work efficiency of the model. Therefore, it is necessary to design and construct corresponding data preprocessing schemes to reduce data noise.Table 1
Sample characteristics of real data set.
ParameterAmount of missing dataProportion of missing data (%)CO5499185.152O34549123.219NO24948614.594SO25548425.184PM2.56118457.157PM107244899.154


### 2.2. Data Preprocessing

According to the analysis of regional division results, an air quality monitoring station is affected by multiple surrounding affected subareas. The number of stations contained in each subarea is different, and there may be zero, one, or more stations. Therefore, for different division results, corresponding methods are adopted for area filling, and finally, the air quality value of each affected subarea can be obtained.For the affected subarea with one monitoring station, the monitoring value can be directly used as the air pollution degree of the current area. During prediction, the monitoring value is directly used as the input parameter for model training. The relationship between regional air quality and monitoring station air quality can be expressed asaiAQI=sAQIs∈ai, where s∈ai means that the monitoring station s is in the affected subarea ai, i means the number of the affected subarea, and AQI is the air quality collection, including PM2.5, PM10, SO2, NO2, CO, and O3.The situation that there are no monitoring stations and multiple monitoring stations in the affected subregion needs to be considered separately. When there are multiple monitoring stations in the affected subarea, different weights are set according to the distance from each monitoring station to the monitoring station to be predicted. The monitoring values of each monitoring station in the area are multiplied by the weights and accumulated. The result is the average air quality of the area and reflects the average air pollution degree of the affected subarea. The calculation method when there are multiple monitoring stations in the affected subarea is shown in (1):(1)aiAQI=∑j=1ksjAQIWj,where k is the number of monitoring stations in the area, and its value range is 1−k; j refers to the number of monitoring stations in the area; and Wj is the influence weight of the j monitoring station.If there are no monitoring stations in the affected subarea and there are missing values, the spatial interpolation method is used for spatial interpolation. As shown in Figure3, the left side of the figure shows the air quality distribution around the monitoring station without filling the null area, and the right side of the figure shows the air quality distribution around the monitoring station after filling the null area with the spatial interpolation method.Figure 3
Air quality distribution map.In order to better realize the quantitative analysis of data, the air quality index is numerically transformed according to the division of air quality grade. The specific replacement method is shown in Table2. If the air quality index is in the range of 0 ∼ 50, replace it with the number 1 in the original data set; if it is in the range of 51 ∼ 100, replace it with the number 2; if it is in the range of 101 ∼ 150, replace it with the number 3; if it is in the range of 151 ∼ 200, replace it with the number 4; if it is in the range of 201 ∼ 300, replace it with the number 5; if it is greater than 300, replace it with the number 6.Table 2
Air quality index classification.
Air quality gradeAQIClassification levelExcellent0∼501Good51∼1002Light pollution101∼1503Moderate pollution151∼2004Severe pollution201∼3005Serious pollution>3006


## 2.1. Air Quality Monitoring

Air quality prediction mainly faces the following four challenges:(1)
Air quality will be affected by many factors, such as traffic. These influencing factors are difficult to obtain or model in advance.(2)
Air quality shows high uncertainty in the time dimension [20, 21]. As shown in Figure 1, taking the PM2.5 mass concentration parameter, one of the main pollutants characterizing air quality, as an example, the mass concentration at each time in a given 2d varies greatly, and the PM2.5 mass concentration shows significant changes at different times in 1d, and the difference between the highest and lowest mass concentrations can reach 100 mg/m3.(3)
There are significant differences in air quality data in different geographical locations [22]. As shown in Figure 2, the PM2.5 mass concentration change curves of three monitoring stations in Beijing were different within 1d. The two monitoring points A and B are close, while the monitoring point C is located in the suburbs and far away from monitoring points A and B. It can be seen from Figure 2 that in most periods, the PM2.5 mass concentration monitored by the three stations is quite different, and the PM2.5 mass concentration of monitoring point C is relatively low.(4)
Due to the limitation of practical conditions, there will be a certain amount of missing basic data obtained for prediction, such as the lack of timestamp attribute value in the data entry or the lack of specific monitoring data.Figure 1
Change in mass concentration during different monitoring periods.Figure 2
Changes in mass concentration at different monitoring stations.Table1 lists the missing data of the real data set used in the study. PM10 lacks tens of thousands of data, and other data are also missing to varying degrees, which has a great impact on the work efficiency of the model. Therefore, it is necessary to design and construct corresponding data preprocessing schemes to reduce data noise.Table 1
Sample characteristics of real data set.
ParameterAmount of missing dataProportion of missing data (%)CO5499185.152O34549123.219NO24948614.594SO25548425.184PM2.56118457.157PM107244899.154


## 2.2. Data Preprocessing

According to the analysis of regional division results, an air quality monitoring station is affected by multiple surrounding affected subareas. The number of stations contained in each subarea is different, and there may be zero, one, or more stations. Therefore, for different division results, corresponding methods are adopted for area filling, and finally, the air quality value of each affected subarea can be obtained.For the affected subarea with one monitoring station, the monitoring value can be directly used as the air pollution degree of the current area. During prediction, the monitoring value is directly used as the input parameter for model training. The relationship between regional air quality and monitoring station air quality can be expressed asaiAQI=sAQIs∈ai, where s∈ai means that the monitoring station s is in the affected subarea ai, i means the number of the affected subarea, and AQI is the air quality collection, including PM2.5, PM10, SO2, NO2, CO, and O3.The situation that there are no monitoring stations and multiple monitoring stations in the affected subregion needs to be considered separately. When there are multiple monitoring stations in the affected subarea, different weights are set according to the distance from each monitoring station to the monitoring station to be predicted. The monitoring values of each monitoring station in the area are multiplied by the weights and accumulated. The result is the average air quality of the area and reflects the average air pollution degree of the affected subarea. The calculation method when there are multiple monitoring stations in the affected subarea is shown in (1):(1)aiAQI=∑j=1ksjAQIWj,where k is the number of monitoring stations in the area, and its value range is 1−k; j refers to the number of monitoring stations in the area; and Wj is the influence weight of the j monitoring station.If there are no monitoring stations in the affected subarea and there are missing values, the spatial interpolation method is used for spatial interpolation. As shown in Figure3, the left side of the figure shows the air quality distribution around the monitoring station without filling the null area, and the right side of the figure shows the air quality distribution around the monitoring station after filling the null area with the spatial interpolation method.Figure 3
Air quality distribution map.In order to better realize the quantitative analysis of data, the air quality index is numerically transformed according to the division of air quality grade. The specific replacement method is shown in Table2. If the air quality index is in the range of 0 ∼ 50, replace it with the number 1 in the original data set; if it is in the range of 51 ∼ 100, replace it with the number 2; if it is in the range of 101 ∼ 150, replace it with the number 3; if it is in the range of 151 ∼ 200, replace it with the number 4; if it is in the range of 201 ∼ 300, replace it with the number 5; if it is greater than 300, replace it with the number 6.Table 2
Air quality index classification.
Air quality gradeAQIClassification levelExcellent0∼501Good51∼1002Light pollution101∼1503Moderate pollution151∼2004Severe pollution201∼3005Serious pollution>3006


## 3. Short-Term Single Step Prediction Model of Air Quality

### 3.1. Model Building

There is a strong spatial-temporal correlation between air quality data sets [23]. In the prediction process, only considering the temporal correlation and ignoring the analysis of spatial features will inevitably reduce the prediction performance of the model.Considering the special spatial-temporal data such as air quality, this study applies a STAQI prediction model based on deep learning to the short-term one-step prediction of AQI at target stations. As shown in Figure4, the STAQI prediction model can be structurally divided into global components and local components, which respectively model and analyze the air quality (spatial correlation) in the adjacent area and the concentration (temporal correlation) of multiple air pollutants at the target site. Finally, the temporal and spatial features extracted from local components and global components are fused to obtain the AQI single-step prediction value of the target site. The specific implementation process is as follows.Figure 4
STAQI prediction model.


### 3.2. Global Component

The distribution of monitoring stations in the city is not established with a certain law and equal spacing, and the topology between monitoring stations is a typical graph structure. Therefore, the data composed of air quality information monitored by multiple stations is a special kind of graph data. The core idea of graph convolution neural network is to learn a function mapping so that the nodes in the graph can aggregate the characteristics of their own nodes and neighbor nodes to obtain a new representation of nodes. The emergence of GCN makes it possible for deep learning to effectively extract spatial features from graph data.Definition 1.
Topology graphG:G=V,E can be used to describe the topology between multiple environmental monitoring sites. The graph is composed of nodes and edges. Each node in the figure represents an environmental monitoring station; V represents the collection of multiple monitoring stations, i.e., V=V1,V2,…,VN, where N is the total number of monitoring stations and E represents the collection of edges between monitoring stations.
According to the first law of geography, everything has different degrees of influence, and the closer things are, the more obvious the relevance is. The spatial correlation of air quality among multistations also obviously conforms to the law. Therefore, the distance between every two stations in the city is calculated according to (2). The greater the distance is, the weaker the correlation is, and on the contrary, the stronger the correlation is. The strong and weak correlation degree between the two STAQI is expressed by calculating the reciprocal of the distance between the two stations and is stored in the adjacency matrix A as the edge weight value of the corresponding station, A∈RN×N.(2)L=2r∗arcsinsin(a−c2))2+cos(a)∗cos(c)∗(sin(b−d2))2,where Xa,b and Yc,d are the geographical locations of the two stations; a and c are the respective latitude information of the station; b and d are the longitude information of each point; and r is the radius of the ball.Definition 2.
Characteristic matrixXN×r: The characteristic matrix is used to store the attribute characteristics of each node in the graph, that is, the STAQI data of each monitoring station, expressed as X∈RN×r; P represents the quantitative characteristics of the node in the graph, corresponding to the historical time window size of model input; Xt∈RN×i represents the STAQI value of each monitoring station at time i.
The implementation process of GCN is as follows:(1)
According to the geographical location information of each station, the topologyG of the urban environmental monitoring station where the target station is located is constructed, and the correlation degree between the two stations is calculated and stored in the adjacency matrix A.(2)
The characteristic matrixX is constructed based on the STAQI observations of the target urban environmental monitoring station at different times.(3)
The adjacency matrixA generates matrix A^A^=D˜12A˜D˜12 through Laplace transform, where A^=A+IN is the self-connected adjacency matrix, IN is the identity matrix, and D˜ is the degree matrix.(4)
Use (3) to aggregate and transform the characteristics of associated nodes to calculate the new characteristics of target nodes:(3)Hi+1=σA^HiWi,where σ is the nonlinear activation function; Wi is the weight matrix of layer i; Hi is the activation value of layer i; and H0=X.
According to the geographical location information of environmental monitoring stations in different corners of the city, the geographical distance between different stations is calculated. The inverse distance value is taken as the edge weight of the corresponding edge between two stations and stored in the adjacency matrix. At the same time, the air quality of multiple historical moments at all monitoring stations in the city is used as the input matrix. By multiplying the information of the column of the target site in the Laplace matrix with the input matrix to dynamically aggregate the impact of the air quality status of different environmental monitoring sites on the air quality status of the target site at the same time, a new expression of the air quality of the target site can be obtained. The data of spatial features extracted by the graph convolution network is input into the GRU, the temporal features are dynamically obtained through the information transmission between units, and the network output is transformed by the fully connected layers.
Figure5 visually shows the internal structure of the global component. The left area represents the overall structure of the global component. Each basic cycle unit block is GG (GCN-GRU). The right area is the specific structure of GG unit cells. Among them, GCN represents the graph convolution operation on the current data, and the input data xt generates xt′ after extracting spatial features through GCN. ut represents the update gate, rt represents the reset gate, ct represents the cell state at time t, and ht represents the output at time t. GCN extracts the spatial features in the multistation air quality feature data by relying on the topology G of multiple monitoring stations and the corresponding air quality feature matrix X, so that the nodes in the graph have the ability to deeply extract the features of their own nodes and adjacent nodes.
The global component calculation process is as follows:(4)ut=σWufA,Xt,ht−1+bu,rt=σWrfA,Xt,ht−1+br,ct=tanhWcfA,Xt,rt∗ht−1+bc,ht=ut∗ht−1+1−ut∗ct,where fA,Xt is the graph convolution process; W is the weight in the training process; and b represents the bias during training.Figure 5
Internal structure of global components.


### 3.3. Local Component

The local components are composed of LSTM network, which is characterized by multivariate historical time series composed of predicting the concentration of main air pollutants and air quality at the station.This paper improves the cell structure of LSTM, eliminates the dependence of the current cell state and hidden layer state on the last hidden layer state, realizes faster state update, and obtains the F-LSTM (fast long short-term memory) cell structure. The F-LSTM structure is shown in Figure6.Figure 6
F-LSTM structure.F-LSTM includes an input gateit, a forgetting gate ft, and a reset gate rt. First, calculate the intermediate state x˜t according to the input, and then calculate the state of other doors. The calculation formula is as follows:(5)x˜t=Wxt,ft=σWfxt+bf,rt=σWrxt+br.The above operation only depends onxt, which makes this part of the operation in the F-LSTM unit can be expanded in parallel. The forgetting gate is used to control the internal state ct, ct and the reset gate is used to calculate the output state C. The calculation formula is as follows:(6)ct=ft⊙ct−1+1−ft⊙x˜t,ht=rt⊙gct+1−rt⊙xt,where g is the activation function used to calculate the output state.


### 3.4. ELM Prediction

After multilayer hidden layer feature learning, the learned data features are input into the extreme learning machine (ELM) model for training and prediction [24, 25]. Let the eigenvector x of the air quality data and the corresponding STAQI prediction vector be t. For a set of samples xi,tii=1,2,3,…,k, the neural network with L hidden layer nodes can be expressed as follows:(7)oLx=∑i=1Lβqwixi+ci,xi∈Rk,wi∈Rk,βi∈Rm,where xi=xi1,xi2,xi3,…,xinT∈Rk, ti=ti1,ti2,ti3,…,tinT∈Rm, βi is the output weight matrix connecting the i hidden layer and the output layer, wi is the connection weight between the feature vector layer and the hidden layer, ci is the offset vector of the hidden layer, and q is the activation function.The purpose of single hidden layer neural network training is to minimize the output error, that is, there arew,β, and c, so that o and t are approximately equal.(8)∑i=1Lβgwixi+ci=ti.


### 3.5. Loss Function

Loss function plays a key role in the process of model training. Minimizing the value of loss function is the ultimate goal of model training. The smaller the loss value, the higher the learning ability of the model to the input data and the better the performance of the model. Compared with shallow neural network, the number of model parametersw of deep neural network increases gradually due to the increase in the number of network layers. The overfitting phenomenon is prevented by adding the L2 regularization term to the original loss function Low. The loss function Lw can be expressed as follows:(9)Lw=Low+λ2n∑i=1nwi2.DerivativeLw:(10)∂Lw∂w=∂L0w∂w+λw.Update parameterw as follows:(11)w′=w−η∂Lw∂w=w−ηλwn−∂L0w∂w=1−ηλnw−∂L0w∂w.It can be seen that whenw approaches 0, adding the L2 regularized loss function can restrict the model parameters to a small range, reduce the computational complexity of the model, and improve the training speed of the model. The loss function used in the STAQI model is as follows:(12)loss=Yi−Y^i+λLreg,where Yi is the actual STAQI value of the target site; Y^i is the predicted STAQI value of the target station; Lreg is the L2 regularization term; and λ is a super parameter.


### 3.6. Model Algorithm Flow

The process of the proposed model is shown in Algorithm 1:Algorithm 1: Model algorithm flow.
Input: test dataOutput: predicted valueSteps:(1)
Assign values to multiple groups of super parameters of the model.(2)
Obtain the constructed adjacency matrixA and model sample data set from external files.(3)
The min-max method is used to normalize the data to eliminate the impact of different dimensions among multiple influencing factors on the model prediction.(4)
According to the size of the specific time window, the supervised data set is constructed and divided into training set and test set.(5)
Calculate the total training batch according to the batch size and the total number of training samples.(6)
Build global components. By inheriting the RNN cell class and overriding _init_ and _call_ Methods, the cell structure of the GG unit was realized. In _init_, the activation function, the number of nodes, the number of hidden cells, and other parameters need to be specified, and the Laplace matrix calculated by the adjacency matrix is loaded. The _ call_ Function to extract the spatial features of the input data and calculate the cell state of GRU unit. Call the user-defined GG cell class that can extract spatial-temporal features, and take the output value of the last cell state as the input of the fully connected layer.(7)
Build local components. The output value of the last unit time obtained by the forward propagation of the F-LSTM network is used as the input of the fully connected layer.(8)
The temporal and spatial features extracted by global and local components are weighted and fused to obtain the prediction results.(9)
Specify the loss function used in model training and the error evaluation index used in model testing.(10)
Adam optimizer is used to minimize the loss value.(11)
Train the model and repeat the following steps within a specific number of training times: first, the input data in the training set is divided into global component and local component. Second, call the model. Thirdly, the local component input, global component input, and label data of the current batch are used as filling data to dynamically perform the calculation of optimizer, loss function value, and prediction value.(12)
Test the trained model and obtain the model output value.(13)
Carry out inverse normalization processing of the output value to obtain the actual prediction value.(14)
The error between the predicted value and the real value is evaluated by a variety of evaluation indexes.


## 3.1. Model Building

There is a strong spatial-temporal correlation between air quality data sets [23]. In the prediction process, only considering the temporal correlation and ignoring the analysis of spatial features will inevitably reduce the prediction performance of the model.Considering the special spatial-temporal data such as air quality, this study applies a STAQI prediction model based on deep learning to the short-term one-step prediction of AQI at target stations. As shown in Figure4, the STAQI prediction model can be structurally divided into global components and local components, which respectively model and analyze the air quality (spatial correlation) in the adjacent area and the concentration (temporal correlation) of multiple air pollutants at the target site. Finally, the temporal and spatial features extracted from local components and global components are fused to obtain the AQI single-step prediction value of the target site. The specific implementation process is as follows.Figure 4
STAQI prediction model.


## 3.2. Global Component

The distribution of monitoring stations in the city is not established with a certain law and equal spacing, and the topology between monitoring stations is a typical graph structure. Therefore, the data composed of air quality information monitored by multiple stations is a special kind of graph data. The core idea of graph convolution neural network is to learn a function mapping so that the nodes in the graph can aggregate the characteristics of their own nodes and neighbor nodes to obtain a new representation of nodes. The emergence of GCN makes it possible for deep learning to effectively extract spatial features from graph data.Definition 1.
Topology graphG:G=V,E can be used to describe the topology between multiple environmental monitoring sites. The graph is composed of nodes and edges. Each node in the figure represents an environmental monitoring station; V represents the collection of multiple monitoring stations, i.e., V=V1,V2,…,VN, where N is the total number of monitoring stations and E represents the collection of edges between monitoring stations.
According to the first law of geography, everything has different degrees of influence, and the closer things are, the more obvious the relevance is. The spatial correlation of air quality among multistations also obviously conforms to the law. Therefore, the distance between every two stations in the city is calculated according to (2). The greater the distance is, the weaker the correlation is, and on the contrary, the stronger the correlation is. The strong and weak correlation degree between the two STAQI is expressed by calculating the reciprocal of the distance between the two stations and is stored in the adjacency matrix A as the edge weight value of the corresponding station, A∈RN×N.(2)L=2r∗arcsinsin(a−c2))2+cos(a)∗cos(c)∗(sin(b−d2))2,where Xa,b and Yc,d are the geographical locations of the two stations; a and c are the respective latitude information of the station; b and d are the longitude information of each point; and r is the radius of the ball.Definition 2.
Characteristic matrixXN×r: The characteristic matrix is used to store the attribute characteristics of each node in the graph, that is, the STAQI data of each monitoring station, expressed as X∈RN×r; P represents the quantitative characteristics of the node in the graph, corresponding to the historical time window size of model input; Xt∈RN×i represents the STAQI value of each monitoring station at time i.
The implementation process of GCN is as follows:(1)
According to the geographical location information of each station, the topologyG of the urban environmental monitoring station where the target station is located is constructed, and the correlation degree between the two stations is calculated and stored in the adjacency matrix A.(2)
The characteristic matrixX is constructed based on the STAQI observations of the target urban environmental monitoring station at different times.(3)
The adjacency matrixA generates matrix A^A^=D˜12A˜D˜12 through Laplace transform, where A^=A+IN is the self-connected adjacency matrix, IN is the identity matrix, and D˜ is the degree matrix.(4)
Use (3) to aggregate and transform the characteristics of associated nodes to calculate the new characteristics of target nodes:(3)Hi+1=σA^HiWi,where σ is the nonlinear activation function; Wi is the weight matrix of layer i; Hi is the activation value of layer i; and H0=X.
According to the geographical location information of environmental monitoring stations in different corners of the city, the geographical distance between different stations is calculated. The inverse distance value is taken as the edge weight of the corresponding edge between two stations and stored in the adjacency matrix. At the same time, the air quality of multiple historical moments at all monitoring stations in the city is used as the input matrix. By multiplying the information of the column of the target site in the Laplace matrix with the input matrix to dynamically aggregate the impact of the air quality status of different environmental monitoring sites on the air quality status of the target site at the same time, a new expression of the air quality of the target site can be obtained. The data of spatial features extracted by the graph convolution network is input into the GRU, the temporal features are dynamically obtained through the information transmission between units, and the network output is transformed by the fully connected layers.
Figure5 visually shows the internal structure of the global component. The left area represents the overall structure of the global component. Each basic cycle unit block is GG (GCN-GRU). The right area is the specific structure of GG unit cells. Among them, GCN represents the graph convolution operation on the current data, and the input data xt generates xt′ after extracting spatial features through GCN. ut represents the update gate, rt represents the reset gate, ct represents the cell state at time t, and ht represents the output at time t. GCN extracts the spatial features in the multistation air quality feature data by relying on the topology G of multiple monitoring stations and the corresponding air quality feature matrix X, so that the nodes in the graph have the ability to deeply extract the features of their own nodes and adjacent nodes.
The global component calculation process is as follows:(4)ut=σWufA,Xt,ht−1+bu,rt=σWrfA,Xt,ht−1+br,ct=tanhWcfA,Xt,rt∗ht−1+bc,ht=ut∗ht−1+1−ut∗ct,where fA,Xt is the graph convolution process; W is the weight in the training process; and b represents the bias during training.Figure 5
Internal structure of global components.


## 3.3. Local Component

The local components are composed of LSTM network, which is characterized by multivariate historical time series composed of predicting the concentration of main air pollutants and air quality at the station.This paper improves the cell structure of LSTM, eliminates the dependence of the current cell state and hidden layer state on the last hidden layer state, realizes faster state update, and obtains the F-LSTM (fast long short-term memory) cell structure. The F-LSTM structure is shown in Figure6.Figure 6
F-LSTM structure.F-LSTM includes an input gateit, a forgetting gate ft, and a reset gate rt. First, calculate the intermediate state x˜t according to the input, and then calculate the state of other doors. The calculation formula is as follows:(5)x˜t=Wxt,ft=σWfxt+bf,rt=σWrxt+br.The above operation only depends onxt, which makes this part of the operation in the F-LSTM unit can be expanded in parallel. The forgetting gate is used to control the internal state ct, ct and the reset gate is used to calculate the output state C. The calculation formula is as follows:(6)ct=ft⊙ct−1+1−ft⊙x˜t,ht=rt⊙gct+1−rt⊙xt,where g is the activation function used to calculate the output state.


## 3.4. ELM Prediction

After multilayer hidden layer feature learning, the learned data features are input into the extreme learning machine (ELM) model for training and prediction [24, 25]. Let the eigenvector x of the air quality data and the corresponding STAQI prediction vector be t. For a set of samples xi,tii=1,2,3,…,k, the neural network with L hidden layer nodes can be expressed as follows:(7)oLx=∑i=1Lβqwixi+ci,xi∈Rk,wi∈Rk,βi∈Rm,where xi=xi1,xi2,xi3,…,xinT∈Rk, ti=ti1,ti2,ti3,…,tinT∈Rm, βi is the output weight matrix connecting the i hidden layer and the output layer, wi is the connection weight between the feature vector layer and the hidden layer, ci is the offset vector of the hidden layer, and q is the activation function.The purpose of single hidden layer neural network training is to minimize the output error, that is, there arew,β, and c, so that o and t are approximately equal.(8)∑i=1Lβgwixi+ci=ti.


## 3.5. Loss Function

Loss function plays a key role in the process of model training. Minimizing the value of loss function is the ultimate goal of model training. The smaller the loss value, the higher the learning ability of the model to the input data and the better the performance of the model. Compared with shallow neural network, the number of model parametersw of deep neural network increases gradually due to the increase in the number of network layers. The overfitting phenomenon is prevented by adding the L2 regularization term to the original loss function Low. The loss function Lw can be expressed as follows:(9)Lw=Low+λ2n∑i=1nwi2.DerivativeLw:(10)∂Lw∂w=∂L0w∂w+λw.Update parameterw as follows:(11)w′=w−η∂Lw∂w=w−ηλwn−∂L0w∂w=1−ηλnw−∂L0w∂w.It can be seen that whenw approaches 0, adding the L2 regularized loss function can restrict the model parameters to a small range, reduce the computational complexity of the model, and improve the training speed of the model. The loss function used in the STAQI model is as follows:(12)loss=Yi−Y^i+λLreg,where Yi is the actual STAQI value of the target site; Y^i is the predicted STAQI value of the target station; Lreg is the L2 regularization term; and λ is a super parameter.


## 3.6. Model Algorithm Flow

The process of the proposed model is shown in Algorithm 1:Algorithm 1: Model algorithm flow.
Input: test dataOutput: predicted valueSteps:(1)
Assign values to multiple groups of super parameters of the model.(2)
Obtain the constructed adjacency matrixA and model sample data set from external files.(3)
The min-max method is used to normalize the data to eliminate the impact of different dimensions among multiple influencing factors on the model prediction.(4)
According to the size of the specific time window, the supervised data set is constructed and divided into training set and test set.(5)
Calculate the total training batch according to the batch size and the total number of training samples.(6)
Build global components. By inheriting the RNN cell class and overriding _init_ and _call_ Methods, the cell structure of the GG unit was realized. In _init_, the activation function, the number of nodes, the number of hidden cells, and other parameters need to be specified, and the Laplace matrix calculated by the adjacency matrix is loaded. The _ call_ Function to extract the spatial features of the input data and calculate the cell state of GRU unit. Call the user-defined GG cell class that can extract spatial-temporal features, and take the output value of the last cell state as the input of the fully connected layer.(7)
Build local components. The output value of the last unit time obtained by the forward propagation of the F-LSTM network is used as the input of the fully connected layer.(8)
The temporal and spatial features extracted by global and local components are weighted and fused to obtain the prediction results.(9)
Specify the loss function used in model training and the error evaluation index used in model testing.(10)
Adam optimizer is used to minimize the loss value.(11)
Train the model and repeat the following steps within a specific number of training times: first, the input data in the training set is divided into global component and local component. Second, call the model. Thirdly, the local component input, global component input, and label data of the current batch are used as filling data to dynamically perform the calculation of optimizer, loss function value, and prediction value.(12)
Test the trained model and obtain the model output value.(13)
Carry out inverse normalization processing of the output value to obtain the actual prediction value.(14)
The error between the predicted value and the real value is evaluated by a variety of evaluation indexes.


## 4. Example Verification

This paper develops an air quality prediction system based on multisource data fusion. The main functions of the system include data import, data preprocessing, model training, model prediction, prediction result display, etc. By importing the data set of the city and selecting the training parameters of the model, the system conducts training. After the model training is completed, different models and different time spans can be selected for analysis and prediction, and the prediction and analysis results can be conveniently presented.The hardware environment of the experimental simulation is NVIDIA GeForce MX450 graphics card and Intel Core i7 1165g7 processor; the software environment is Python 3.6 and the machine learning framework is Keras. Keras is a high-level neural network API, which can encapsulate Theano and TensorFlow again and omit the underlying development details. Therefore, it has good scalability and thus it is easy to build a network.In this paper, a total of 1520 groups of air quality data from January 2019 to January 2021 in Beijing, China, are obtained. The sample database is constructed after preprocessing the original data. 80% of the data in the sample database are randomly selected as the training set, and the remaining sample datasets are used as the test set for model training and testing.


### 4.1. Evaluating Indicator

The purpose of this study is to predict the changing trend of air quality and pollutant concentration in the air of small and micromonitoring stations in grid monitoring. Therefore, in order to better measure the prediction effect, this paper adopts two evaluation indexes: mean absolute error (MAE) and root mean squared error (RMSE). This paper uses these two evaluation indexes to analyze the deviation between the predicted results and the real measured values.Generally speaking, the smaller the deviation between the predicted value and the real value, the smaller the values of MAE and RMSE, that is, the smaller the values of MAE and RMSE, the better the prediction effect.(13)MAE=1N∑i=1Nyi−y^i,RMSE=1N∑i=1Nyi−y^i2,where yi is the true STAQI measurement and B is the predicted value of STAQI.


### 4.2. Parameter Sensitivity Analysis

For the prediction model proposed in this paper, the number of hidden layer units is very important for the prediction accuracy of the model. Therefore, the number of hidden layer elements is discussed in this paper. Table3 shows the results of network under different number of hidden layer units.Table 3
Evaluation indexes under different number of hidden layer units.
Number of hidden layer cellsRMSEMAE87.896.54167.015.14325.645.06644.513.921284.824.242564.994.69As shown in Table3, with the gradual increase of the number of hidden layer units, the evaluation index of the STAQI prediction model decreases first and then increases. When it exceeds a certain critical value, the model loses the ability to effectively learn the data, resulting in an increase in the prediction deviation of the model. When the number of hidden layer units in the STAQI prediction model is 64, the minimum value of RMSE is 4.51 and the value of MAE is 3.92. Therefore, it can be explained that when the number of hidden layer units of the prediction model is 64, its prediction performance is the best.


### 4.3. Model Prediction Analysis

In this paper, the simulation results of the model are analyzed by using the fitting curve of STAQI predicted value and real value, the MAE curve of STAQI, and the RMSE curve of STAQI.Figure7 shows the prediction and analysis results of the STAQI prediction model proposed in this paper in Beijing.Figure 7
STAQI prediction fitting curve.As can be seen from Figure7, the prediction results of the STAQI prediction model proposed in this paper are basically consistent with the actual measured values. Based on the temporal and spatial characteristics of STAQI data, it provides reliable and complete data support for elm network model. Therefore, the proposed model can show good fitting ability.In order to intuitively evaluate the tracking analysis ability of the proposed prediction model, this paper also uses RMSE and MAE to realize mathematical quantitative evaluation and analysis. Figure8 shows the evaluation index analysis of the proposed model.Figure 8
Evaluation index of the proposed model: (a) RMSE; (b) MAE.
(a)(b)As shown in Figure8(a), the RMSE of the predicted value of most test samples is less than 6, and the RMSE of a few samples is between 6 and 8; at the same time, it can be seen from Figure 8(b) that most of the MAE prediction indicators are within 5, and only a few samples have MAE between 5 and 7. From the above results, it can be seen that the air quality evaluation and prediction model has high prediction accuracy. Based on the spatial distribution characteristics of AQI data, the effective spatial feature extraction of sample data is realized by using the depth network combined with GCN and GRU.In order to more comprehensively evaluate the performance of the spatial-temporal air quality prediction model in this paper, the MAE and RMSE are used to compare the algorithm in this paper with References [16, 19]. The results are shown in Table 4.Table 4
Analysis of prediction results under prediction models.
MethodRMSEMAEThe proposed model4.513.92Reference [16]6.575.99Reference [19]5.835.82In conclusion, it can be confirmed that the STAQI model constructed in this paper has excellent tracking and fitting ability, and can achieve accurate and efficient STAQI prediction.


## 4.1. Evaluating Indicator

The purpose of this study is to predict the changing trend of air quality and pollutant concentration in the air of small and micromonitoring stations in grid monitoring. Therefore, in order to better measure the prediction effect, this paper adopts two evaluation indexes: mean absolute error (MAE) and root mean squared error (RMSE). This paper uses these two evaluation indexes to analyze the deviation between the predicted results and the real measured values.Generally speaking, the smaller the deviation between the predicted value and the real value, the smaller the values of MAE and RMSE, that is, the smaller the values of MAE and RMSE, the better the prediction effect.(13)MAE=1N∑i=1Nyi−y^i,RMSE=1N∑i=1Nyi−y^i2,where yi is the true STAQI measurement and B is the predicted value of STAQI.


## 4.2. Parameter Sensitivity Analysis

For the prediction model proposed in this paper, the number of hidden layer units is very important for the prediction accuracy of the model. Therefore, the number of hidden layer elements is discussed in this paper. Table3 shows the results of network under different number of hidden layer units.Table 3
Evaluation indexes under different number of hidden layer units.
Number of hidden layer cellsRMSEMAE87.896.54167.015.14325.645.06644.513.921284.824.242564.994.69As shown in Table3, with the gradual increase of the number of hidden layer units, the evaluation index of the STAQI prediction model decreases first and then increases. When it exceeds a certain critical value, the model loses the ability to effectively learn the data, resulting in an increase in the prediction deviation of the model. When the number of hidden layer units in the STAQI prediction model is 64, the minimum value of RMSE is 4.51 and the value of MAE is 3.92. Therefore, it can be explained that when the number of hidden layer units of the prediction model is 64, its prediction performance is the best.


## 4.3. Model Prediction Analysis

In this paper, the simulation results of the model are analyzed by using the fitting curve of STAQI predicted value and real value, the MAE curve of STAQI, and the RMSE curve of STAQI.Figure7 shows the prediction and analysis results of the STAQI prediction model proposed in this paper in Beijing.Figure 7
STAQI prediction fitting curve.As can be seen from Figure7, the prediction results of the STAQI prediction model proposed in this paper are basically consistent with the actual measured values. Based on the temporal and spatial characteristics of STAQI data, it provides reliable and complete data support for elm network model. Therefore, the proposed model can show good fitting ability.In order to intuitively evaluate the tracking analysis ability of the proposed prediction model, this paper also uses RMSE and MAE to realize mathematical quantitative evaluation and analysis. Figure8 shows the evaluation index analysis of the proposed model.Figure 8
Evaluation index of the proposed model: (a) RMSE; (b) MAE.
(a)(b)As shown in Figure8(a), the RMSE of the predicted value of most test samples is less than 6, and the RMSE of a few samples is between 6 and 8; at the same time, it can be seen from Figure 8(b) that most of the MAE prediction indicators are within 5, and only a few samples have MAE between 5 and 7. From the above results, it can be seen that the air quality evaluation and prediction model has high prediction accuracy. Based on the spatial distribution characteristics of AQI data, the effective spatial feature extraction of sample data is realized by using the depth network combined with GCN and GRU.In order to more comprehensively evaluate the performance of the spatial-temporal air quality prediction model in this paper, the MAE and RMSE are used to compare the algorithm in this paper with References [16, 19]. The results are shown in Table 4.Table 4
Analysis of prediction results under prediction models.
MethodRMSEMAEThe proposed model4.513.92Reference [16]6.575.99Reference [19]5.835.82In conclusion, it can be confirmed that the STAQI model constructed in this paper has excellent tracking and fitting ability, and can achieve accurate and efficient STAQI prediction.


## 5. Conclusion

The accurate prediction of air quality index (AQI) has important practical significance and social value. However, the current method ignores the temporal and spatial distribution characteristics of AQI data, which is difficult to extract the characteristics of sample data effectively. To solve this problem, this paper constructs an air quality prediction model based on deep learning. Based on the spatial distribution characteristics of AQI data, the effective spatial feature extraction of sample data is realized by using the depth network combined with GCN and GRU. Based on the time distribution characteristics of AQI data, the improved LSTM network model is used to realize faster state update and effectively extract the time distribution characteristics of sample data.Air quality analysis is actually affected by many complex factors. This paper only takes the air pollutant concentration data as the model input, which has a certain one-sidedness. The modeling and analysis of meteorological conditions, human activities, and other influencing factors will be added to future research work, so as to more accurately predict the change trend of air quality in the future.



---

*Source: 7221157-2022-09-29.xml*