Air quality prediction model and system based on multi-measuring-point correlation analysis
Through multi-test point correlation analysis method and feature selection technology, combined with Transformer and OSRVFL models, hyperparameters are optimized, and the problem of insufficient accuracy and adaptability in air quality prediction in traditional methods is solved, achieving high-precision and strong generalization capabilities of air Quality prediction.
Patent Information
- Application Number
- CN202410039312.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2024-12-13
Smart Images

Figure CN119129788A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of air quality prediction, and relates to an air quality prediction model and system based on multi-measurement point correlation analysis. Background Art
[0002] At present, there are two main methods for predicting air quality: numerical simulation and artificial intelligence algorithms. The numerical simulation method considers the transformation between various pollutants in the atmosphere and establishes a model to simulate the relationship between meteorological, emission and chemical changes. This method uses a large amount of real-time information on air quality changes to monitor the process of pollutant generation, exchange, diffusion and discharge in the region. Common numerical simulation methods include general multi-scale air quality models and weather research and prediction models. Numerical simulation methods are highly adaptable and professional, but require a lot of prior knowledge to simulate the laws of atmospheric changes. Due to the influence of factors such as irregular pollutant data, complex basic atmospheric conditions, and insufficient theoretical information, the prediction accuracy needs to be improved. On the other hand, artificial intelligence algorithms can predict air quality by learning a large amount of data, with better adaptability and prediction accuracy.
[0003] Artificial intelligence algorithms use statistical modeling methods to predict air quality. Common methods include support vector machines, artificial neural networks, etc. These algorithms usually use historical data to train prediction models. However, the spatial distribution and temporal trend of air quality processes are affected by many factors, including atmospheric pollutant emissions and deposition, weather conditions, and human activities. As a result, the air quality process becomes complicated, and there are spatial connections between different sites. Traditional machine learning models have certain limitations when processing such complex and large air quality data. These models cannot effectively capture the feature distribution in air quality data sets, thereby increasing the difficulty of using traditional machine learning models to predict air quality. Therefore, the present invention proposes an air quality prediction model and system based on multi-point correlation analysis, using feature selection and decomposition methods to pre-process air quality data and AQI data, and then using Transformer and OSRVFL to establish an air quality prediction model based on multi-point correlation analysis. Summary of the invention
[0004] Purpose of the invention: In response to the problems pointed out in the background technology, the present invention discloses an air quality prediction model and system based on multi-measurement point correlation analysis, uses Transformer and OSRVFL to predict air quality, and uses intelligent algorithms to optimize the model hyperparameters, and finally can obtain a high-precision and strong generalization ability air quality prediction model.
[0005] Technical solution: The present invention discloses an air quality prediction method based on multi-measurement point correlation analysis, comprising the following steps:
[0006] Step 1: Collect air quality data and meteorological data of a certain area, and reasonably optimize the data anomalies and missing points to obtain a complete data set, which includes the air quality data and meteorological data of the predicted site and the AQI of the adjacent city site; the air quality data of the predicted site includes AQI, PM2.5, nitrogen oxides, carbon oxides, and sulfides; the meteorological data includes temperature, humidity, and wind speed;
[0007] Step 2: Use the Pearson correlation coefficient to calculate the correlation between the AQI of neighboring city sites, other air quality indices, meteorological data and the AQI of the predicted site, extract strong correlation factors, perform feature dimensionality reduction on the high-dimensional data set, and finally determine the input dimension of each component;
[0008] Step 3: Use singular spectrum analysis (SSA) to decompose the AQI data of the predicted site, extract the periodic components in the AQI data, and decompose them into trend, oscillation component and noise;
[0009] Step 4: Use reverse learning to optimize the artificial fish swarm algorithm and propose an improved artificial fish swarm algorithm IABC;
[0010] Step 5: Transformer and online sequence random vector functional link network OSRVFL are used to model the high-frequency signal and low-frequency signal of AQI data respectively, and a high- and low-frequency air quality prediction model of Transformer and online sequence random vector functional link network OSRVFL is established. The air quality prediction model uses IABC to optimize the hyperparameters of Transformer and OSRVFL;
[0011] Step 6: Use the historical air quality data selected by the Pearson correlation coefficient in step 2 and the improved artificial fish swarm algorithm IABC to train the high and low frequency air quality prediction models of the established Transformer and online sequential random vector functional link network OSRVFL to find the optimal model parameters and minimize the loss function error;
[0012] Step 7: Use the trained model to predict future data and output the prediction results.
[0013] Furthermore, in step 2, the Pearson correlation coefficient is used to perform feature selection on the air quality data set. The steps of the Pearson correlation coefficient are as follows:
[0014] The Pearson correlation coefficient is a statistical method to calculate the linear correlation between two features. i ,f j The Pearson correlation coefficient is:
[0015]
[0016] In the formula, Cov(f i , f j ) represents the covariance of the feature f i , f j , and Var(f i ) represents the variance of the feature f i . The features are scored by calculating the correlation coefficients between AQI and other air quality data and meteorological data. The higher the score, the better the feature.
[0017] Furthermore, in step 3, singular spectrum analysis (SSA) is used to decompose the AQI data, and the periodic components in the AQI data are extracted to decompose the trend, oscillation components, and noise. The specific steps are as follows:
[0018] (1) Embedding
[0019] For a time series [x1, x2,..., x N , the first step is to select an appropriate window length L to lag the original time series, so as to obtain a trajectory matrix:
[0020]
[0021] Select L < N / 2. Let K = N - L + 1, then the trajectory matrix X is an L * K matrix:
[0022]
[0023] (2) Decomposition
[0024] The eigenvalues λ1, λ2,..., λ L and their corresponding eigenvectors U1, U2,..., U L are obtained by performing eigenvalue decomposition (EVD) on the covariance matrix of the trajectory matrix. The singular value decomposition (SVD) of X is expressed as:
[0025]
[0026] where
[0027] (3) Reorganization
[0028] First, calculate the projection of the lagged sequence X i onto U m :
[0029]
[0030] where X i represents the i-th column of the trajectory matrix X, and ai m is the x in the original sequence i+1 ,x i+2 ,...,x i+L X is reflected in each stage i The weights of the time-evolving patterns represented by , which are called temporal principal components;
[0031] Then, the empirical orthogonal function and time principal component are used to reconstruct the sequence. The specific reconstruction procedure is as follows:
[0032]
[0033] The sum of all reconstructed sequences is equal to the original sequence, where x i As shown below:
[0034]
[0035] Furthermore, the improved artificial bee colony algorithm steps in step 4 are as follows:
[0036] (1) Generate the initial nectar source location using reverse learning improved strategy; First, use formula (8) to randomly generate some nectar source locations as the initial solution to the problem before the bees collect nectar, and then use formula (9) to reversely learn and calculate the reverse nectar source location; Assume that in D-dimensional space, randomly generate N nectar source locations and use X i =(x i1 ,x i2 ,...,x id ) represents the i-th honey source information:
[0037] x id =L d +rand*(U d -L d ) (8)
[0038] x new_id =(U d +L d )-x id (9)
[0039] Where: x id is the position of the i-th nectar source in the d-th dimension space, x new_id For x id The reverse nectar source position, U d and L d Respectively represent the upper and lower bounds of the search space, rand is a random number (0,1), then calculate x new_id and x id The fitness value of the nectar source is retained as the initial nectar source;
[0040] (2) The bees conduct neighborhood search. The number of bees corresponds to the information of the initial nectar source. When the initial nectar source information is generated, the bees will conduct neighborhood search around the initial nectar source and compare the newly obtained nectar source information with the previous nectar source information. Finally, the better nectar source information is retained to complete the update of the nectar source. The neighborhood search formula of bees is:
[0041]
[0042] Among them, v id represents the new nectar source location information, j is another bee number besides i, is a random number uniformly distributed between [-1,1], which determines the amplitude of the disturbance;
[0043] (3) Follower bees follow up the search. When the honey bees complete the neighborhood search, they return to the hive and share the new nectar source information with the follower bees in the form of a tail-wagging dance. The follower bees follow up the search using the roulette method based on the nectar source information provided by the honey bees. The nectar source location with a larger amount of nectar, closer to the hive, and easier to mine is more likely to be selected. The probability of a nectar source location being selected is p. i for:
[0044]
[0045] Among them, p i is the probability of the i-th nectar source being selected, fit i is the nectar value of the i-th nectar source, which is closely related to the quality of the nectar source. The better the nectar source information, the greater the probability of being selected;
[0046] (4) Global search by scout bees. When the location information of a nectar source does not change for many consecutive times, the follower bees will abandon the location of the nectar source and transform themselves into scout bees, jumping out of the local optimum to conduct a global search and randomly update the location of the nectar source using formula (9).
[0047] Furthermore, in step 5, the high and low frequencies of the Transformer and the online sequential random vector functional link network OSRVFL are constructed, wherein the Transformer models the high frequency signal of the AQI data, and the input data includes the high frequency part of the AQI decomposed by SSA in step 3 and the strongly correlated features extracted by the Pearson correlation coefficient in step 2, and the output is the prediction result of the high frequency part of the AQI decomposed by SSA; the specific steps are as follows:
[0048] The Transformer structure consists of multiple encoders and decoders stacked together. Each layer has the same structure. After the information is input into an encoder, it is output and input into all encoders in succession. The last encoder then outputs the information to the decoder. The encoder module includes multi-head attention and a feedforward neural network. The decoder module has an additional masked multi-head attention. A residual connection and layer normalization part are connected after each layer in the encoder and decoder.
[0049] The position encoding method uses sine and cosine functions to encode position information; for each position in the sequence, the position encoder generates a vector of fixed size, where each dimension corresponds to a sine or cosine function of a different frequency, and the encoding vectors at different positions have different angles in space, thereby expressing the relative position relationship between them. The formula for position encoding is as follows:
[0050]
[0051]
[0052] Among them, pos represents the position, i represents the dimension index, and d model Represents the dimensions of the model;
[0053] The multi-head self-attention mechanism incorporates the position trajectory vector of the previous and next time perception into the attention calculation, and for the embedded feature vector The multi-head self-attention mechanism first calculates the query vector from t=1 to T Key Vector Sum value vector The calculation formula for attention is as follows:
[0054]
[0055] Among them, d k represents the dimension of each vector, The product term represents the numerical stability of attention, and softmax is a normalized exponential function;
[0056] The multi-head attention mechanism allows the model to jointly focus on information from different representations at different locations when calculating attention. The calculation formula with h attention heads is as follows:
[0057]
[0058] Among them, f c (·) is a fully connected layer that merges the outputs of h attention heads, Att i(Q, K, V) represents the self-attention of the i-th head, and then the output of the multi-head attention MultiHeadAtt(Q, K, V) passes through the Add&Nom layer and the feedforward neural network layer to output the updated trajectory feature vector. The calculation formula of the Add&Norm layer is as follows:
[0059] LayerNorm(X+MultiHeadAtt(X)) (15)
[0060] Among them, X and MultiHeadAtt(X) represent the input and output vectors of the multi-head attention layer respectively. The input and output have the same dimensions and are connected with residuals to solve the gradient vanishing problem of multi-layer network training and make the network pay attention to global and local feature vectors.
[0061] Finally, the encoded feature representation is output by the feedforward network layer, which consists of two fully connected layers. The activation function of the first layer is Relu, and the second layer does not use an activation function. The calculation formula is as follows:
[0062] FNN(X)=max(0,XW i +b i )w2+b2 (16)
[0063] Among them, X represents the input, W1 and W2 are weights, and b1 and b2 are biases;
[0064] Finally, the feedforward neural network layer FFN(X) outputs the encoded trajectory feature representation, and the dimension of the output matrix is consistent with X.
[0065] Furthermore, in step 5, a high- and low-frequency air quality prediction model of Transformer and online sequence random vector functional link network OSRVFL is constructed, wherein the online sequence random vector functional link network OSRVFL models the low-frequency signal of the AQI data, and its input data includes low-frequency data and strongly correlated factors, which are opposite to the high-frequency part here. The input data includes the low-frequency part of the AQI decomposed by SSA in step 3 and the strongly correlated features extracted by the Pearson correlation coefficient in step 2, and the output is the prediction result of the low-frequency part of the AQI decomposed by SSA. The specific steps are as follows
[0066] The OSRVFL model introduces the idea of sequential learning into the random vector function link network. In the initial training stage, the output weight β0 of OSRVFL is initialized with a small number of samples, and then enters the online sequential learning stage, and the output weight β learned in the initial stage is iteratively adjusted through each input sample.
[0067] Assume that the constructed network has r neurons in the input layer, l neurons in the hidden layer, and m neurons in the output layer. In the initial training stage, there are N0 arbitrary training samples (x i ,t i ), where x i =[x i1 ,x i2 ,...,x ir ] T ,t i =[t i1 ,t i2 ,...,t ir ] T , using the idea of traditional RVFL, the model with l hidden nodes and nonlinear mapping as the activation function g(x) is:
[0068]
[0069] In formula (17): w i =[w i1 ,w i2 ,...,w ir ] T is the weight connecting the i-th hidden node and the input layer; b i is the bias of the i-th hidden node, both of which are randomly generated; x i With t i are the input and output of the jth sample respectively; β i =[β i1 ,β i2 ,...,β ir ] T is the input weight connecting the i-th hidden node and the output node;
[0070] When β=[β1,β2,...,β r ] T is the target matrix of the training data, i=1,2,…,r, and the output matrix H0 of the hidden layer is:
[0071]
[0072] Then the matrix relationship is:
[0073] H0β=T0 (19)
[0074] In formula (19): The goal of RVFL network learning is to minimize the output error value. After calculating the hidden layer output, it is only necessary to solve the weight of the output layer. The objective function is:
[0075] min|H0β-T0|(20)
[0076] According to the generalized inverse method, the minimum β0 that meets the conditions is obtained:
[0077] β0=H + T0 (21)
[0078] In formula (21): H + is the generalized inverse matrix of H0, Let the intermediate matrix In the online learning phase, the hidden layer output H in the k+1th learning (k=0,1,…) is calculated k+1 , then P k+1 And the output weight β k+1 as follows:
[0079]
[0080]
[0081] Where: I is the unit matrix.
[0082] Furthermore, in step 5, IABC is used to optimize the hyperparameters of Transformer and OSRVFL. The hyperparameter of OSRVFL is the number of hidden layer nodes, and the hyperparameters of Transformer include: the number of layers, model dimension, and the number of heads.
[0083] The present invention also discloses an air quality prediction system based on multi-measurement point correlation analysis, comprising the following modules:
[0084] Data acquisition module, used to collect data on air quality, including AQI, PM2.5, nitrogen oxides, carbon oxides, and sulfides;
[0085] The data processing module uses the Pearson correlation coefficient to calculate the correlation between the AQI of neighboring city sites, other air quality indexes, meteorological data and the AQI of the predicted site, extracts strong correlation factors, performs feature dimensionality reduction on high-dimensional data sets, and finally determines the input dimension of each component; uses singular spectrum analysis SSA to decompose the AQI data of the predicted site, extracts the periodic components in the AQI data, and decomposes them into trends, oscillation components and noise;
[0086] The neural network module uses the Transformer and OSRVFL models to model the high-frequency and low-frequency signals of AQI data respectively, and establishes an air quality prediction model based on the multi-measurement point correlation analysis of Transformer and OSRVFL. The established Transformer and OSRVFL models are trained through the historical air quality data and the intelligent optimization module to obtain the optimal network parameters.
[0087] The intelligent optimization module uses reverse learning initialization to improve ABC and obtain the improved artificial bee colony algorithm IABC, which is used to optimize the hyperparameters of the Transformer and OSRVFL models.
[0088] The cloud platform module displays historical data and air quality forecast results for a period of time in real time through the cloud platform.
[0089] Beneficial effects:
[0090] (1) The present invention uses the Pearson correlation coefficient feature selection to select the air quality index (AQI) sequence and factors such as humidity, temperature, wind speed, visibility and adjacent site AQI, thereby obtaining the degree of correlation between AQI and meteorological factors, determining the model input dimension, and simplifying the calculation without reducing the prediction accuracy.
[0091] (2) Use singular spectrum analysis (SSA) to decompose the AQI data and extract the periodic components in the AQI data into trend, oscillation components and noise;
[0092] (3) A high- and low-frequency air quality prediction model based on Transformer and online sequential random vector functional link network (OSRVFL) is established. The air quality prediction model uses IABC to optimize the hyperparameters of Transformer and OSRVFL to improve the model prediction accuracy and generalization ability.
[0093] (4) The present invention proposes to use IABC to optimize the hyperparameters of Transformer and OSRVFL. The ABC algorithm is improved by reverse learning, and IABC is proposed. IABC is used to optimize the hyperparameters of Transformer and OSRVFL to improve the prediction accuracy and generalization ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0094] Figure 1 It is the Transformer structure diagram;
[0095] Figure 2 It is the structure diagram of OSRVFL;
[0096] Figure 3 It is the air quality prediction model and system flow chart;
[0097] Figure 4 It is a fitting diagram of the predicted value and the true value of the air quality prediction model based on multi-measurement point correlation analysis. DETAILED DESCRIPTION
[0098] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.
[0099] Step 1: Collect air quality data for a certain area, and optimize the data anomalies and missing points reasonably to obtain a complete air quality data set, which includes air quality data and meteorological data as well as the AQI of neighboring city stations. The air quality data includes AQI, PM2.5, nitrogen oxides, carbon oxides, and sulfides, and the meteorological data includes temperature, humidity, and wind speed.
[0100] Step 2: Use the Pearson correlation coefficient to calculate the correlation between the AQI of adjacent city sites, other air quality indices, meteorological data and the AQI of the predicted site, extract the strongly correlated factors, and finally determine the input dimension of each component to prepare for the subsequent model building.
[0101] The Pearson correlation coefficient is a statistical method to calculate the linear correlation between two features. i ,f j The Pearson correlation coefficient is:
[0102]
[0103] In the formula, Cov(f i ,f j ) represents the feature f i ,f j The covariance of Var(f i ) represents the feature f i The feature is scored by calculating the correlation coefficient between AQI and other air quality data and meteorological data. The higher the score, the better the feature.
[0104] Step 3: Use singular spectrum analysis (SSA) to decompose the AQI data, extract the periodic components in the AQI data, and decompose them into trends, oscillation components, and noise.
[0105] Singular spectrum analysis (SSA) is used to decompose the AQI data, extract the periodic components in the AQI data, and decompose the trend, oscillation component and noise. The specific steps are as follows:
[0106] (1) Embedding
[0107] For a time series [x1,x2,...,x N ], the first step is to choose a suitable window length L to lag behind the original time series, so as to obtain a trajectory matrix:
[0108]
[0109] Generally, select \(L < N / 2\). Let \(K = N - L + 1\), then the trajectory matrix \(X\) is an \(L\times K\) matrix.
[0110]
[0111] (2) Decomposition
[0112] The eigenvalues \(\lambda_1,\lambda_2,...,\lambda\) L and their corresponding eigenvectors \(U_1,U_2,...U\) L can be obtained by performing eigenvalue decomposition (EVD) on the covariance matrix of the trajectory matrix. The singular value decomposition (SVD) of \(X\) is expressed as:
[0113]
[0114] where,
[0115] (3) Recombination
[0116] First, calculate the projection of the lag sequence \(X\) i onto \(U\) m :
[0117]
[0118] where \(X\) i represents the \(i\)-th column of the trajectory matrix \(X\), is the weight reflecting the time evolution pattern represented by \(X\) i+1 , \(x\) i+2 ,..., \(x\) i+L in the \(x\) i of the original sequence, which is called the time principal component.
[0119] Then, the empirical orthogonal function and the time principal component can be used to reconstruct the sequence. The specific reconstruction procedure is as follows:
[0120]
[0121] In this way, the sum of all reconstructed sequences should be equal to the original sequence, where \(x\) i is as follows.
[0122]
[0123] Step 4: Use reverse learning to optimize the artificial fish swarm algorithm to propose an improved artificial fish swarm algorithm IABC to improve the global search ability of the artificial fish swarm algorithm.
[0124] (1) Generate the initial nectar source location using reverse learning improved strategy; first use formula (8) to randomly generate some nectar source locations as the initial solution to the problem before the bees collect nectar, and then use formula (9) to reversely learn and calculate the reverse nectar source location. Assume that in D-dimensional space, N nectar source locations are randomly generated and X i =(x i1 ,x i2 ,...,x id ) represents the i-th nectar source information, and the formula for generating the initial nectar source position is:
[0125] x id =L d +rand*(U d -L d ) (8)
[0126] x new_id =(U d +L d )-x id (9)
[0127] Where: x id is the position of the i-th nectar source in the d-th dimensional space, x new_id For x id The reverse nectar source position. d and L d They represent the upper and lower bounds of the search space, and rand is a random number (0,1). Then, calculate x new_id and x id The fitness value of the nectar source is increased, and the better nectar source is retained as the initial nectar source.
[0128] (2) Bee collectors conduct neighborhood search. The number of bees collectors corresponds to the information of the initial nectar source. When the initial nectar source information is generated, the bees collectors will conduct neighborhood search around the initial nectar source and compare the newly obtained nectar source information with the previous nectar source information. Finally, the better nectar source information is retained to complete the update of the nectar source. The formula for the neighborhood search of bees collectors is:
[0129]
[0130] Among them, v id represents the new nectar source location information, and j is another bee number besides i. is a random number uniformly distributed between [-1,1], which determines the amplitude of the disturbance;
[0131] (3) Follow-up search by follower bees. When the honey bees complete the neighborhood search, they will return to the hive and share the new nectar source information with the follower bees in the form of a tail-wagging dance. The follower bees will follow up the search using the roulette method based on the nectar source information provided by the honey bees. The nectar source location with a larger amount of nectar, closer to the hive, and easier to mine is more likely to be selected. The probability of a nectar source location being selected is p. i for:
[0132]
[0133] Among them, p i is the probability of the i-th nectar source being selected, fit i is the nectar value of the i-th nectar source, which is closely related to the quality of the nectar source. The better the nectar source information, the greater the probability of being selected.
[0134] (4) Global search by scout bees. When the location information of a nectar source does not change for several consecutive times, the follower bee will abandon the location of the nectar source and transform itself into a scout bee, jumping out of the local optimum to conduct a global search and randomly updating the location of the nectar source using formula (9).
[0135] (5) Algorithm process design
[0136] Step 4.1: Initialize relevant parameters, including the path starting point, end point, maximum number of iterations iterMax, total number of bee colonies N, nectar source dimension, map range, etc.
[0137] Step 4.2: Generate the first generation of nectar source locations using (8)(9).
[0138] Step 4.3: The honey bees use formula (10) to search the neighborhood of the first generation nectar source and update the nectar source location.
[0139] Step 4.4: The follower bee completes the neighborhood search and updates the location of the nectar source using the roulette method based on the nectar source information provided by the honey bees.
[0140] Step 4.5: When a certain nectar source location has not been updated for several times, the nectar source location is abandoned and the scout bees conduct a global search again.
[0141] Step 4.6: Repeat steps 4.1 to 4.5 until the maximum number of iterations is reached.
[0142] Step 4.7: Complete the iteration and output the optimal value of the iteration.
[0143] Step 5: Establish a high- and low-frequency air quality prediction model of Transformer and online sequential random vector functional link network (OSRVFL). The air quality prediction model uses IABC to optimize the hyperparameters of Transformer and OSRVFL to improve the prediction accuracy of the model.
[0144] Transformer models the high-frequency signal of AQI data. The input data includes the high-frequency part of AQI decomposed by SSA in step 3 and the strongly correlated features extracted by Pearson correlation coefficient in step 2. Its output is the prediction result of the high-frequency part of AQI decomposed by SSA, as follows:
[0145] (1) Transformer
[0146] The structure of Transformer is mainly composed of multiple encoders and decoders stacked together. Each layer has the same structure. After the information is input into an encoder, it will be output and input into all encoders successively. The last encoder will output the information to the decoder. The encoder module includes multi-head attention and feed-forward neural network. The decoder module has an additional masked multi-head attention. Each layer in the encoder and decoder is connected to a residual connection and layer normalization (Add&Nrom) part.
[0147] A common position encoding method is to use sine and cosine functions to encode position information. For each position in the sequence, the position encoder generates a vector of fixed size, where each dimension corresponds to a sine or cosine function of a different frequency. In this way, the encoding vectors at different positions have different angles in space, thereby expressing the relative position relationship between them. The formula for position encoding is as follows:
[0148]
[0149]
[0150] Among them, pos represents the position, i represents the dimension index, and d model Represents the dimensions of the model.
[0151] The multi-head self-attention mechanism aims to incorporate the position trajectory vector of the previous and next time perception into the attention calculation. The multi-head self-attention mechanism first calculates the query vector from t=1 to T Key Vector Sum value vector The calculation formula for attention is as follows:
[0152]
[0153] Among them, d k represents the dimension of each vector, The product term represents the numerical stability of attention, and softmax is a normalized exponential function. The self-attention mechanism can learn feature dependencies over a long period of time and calculate the weight vectors embedded in the features of different time trajectories. In addition, decoupling self-attention into query, key, and value tuples allows the self-attention mechanism to capture more complex temporal dependencies.
[0154] The multi-head attention mechanism allows the model to jointly focus on information from different representations at different locations when calculating attention. The calculation formula with h attention heads is as follows:
[0155]
[0156] Among them, f c (·) is a fully connected layer that merges the outputs of h attention heads, Att i (Q, K, V) represents the self-attention of the i-th head. Then the output of the multi-head attention MultiHeadAtt(Q, K, V) passes through the Add&Nom layer and the feedforward neural network layer to output the updated trajectory feature vector. The calculation formula of the Add&Norm layer is as follows:
[0157] LayerNorm(X+MultiHeadAtt(X)) (15)
[0158] Among them, X and MultiHeadAtt(X) represent the input and output vectors of the multi-head attention layer respectively. The input and output have the same dimension and perform residual connection to solve the gradient vanishing problem of multi-layer network training and let the network focus on global and local feature vectors.
[0159] Finally, the encoded feature representation is output by the feedforward network layer, which consists of two fully connected layers. The activation function of the first layer is Relu, and the second layer does not use an activation function. The calculation formula is as follows:
[0160] FNN(X)=max(0,XW i +b i )w2+b2 (16)
[0161] Among them, X represents the input, W1 and W2 are weights, and b1 and b2 are biases.
[0162] Finally, the feedforward neural network layer FFN(X) outputs the encoded trajectory feature representation, and the dimension of the output matrix is consistent with X.
[0163] The online sequential random vector functional link network OSRVFL models the low-frequency signal of AQI data. Its input data includes low-frequency data and strongly correlated factors, which are opposite to the high-frequency part. The input data includes the low-frequency part of AQI decomposed by SSA in step 3 and the strongly correlated features extracted by Pearson correlation coefficient in step 2. The output is the prediction result of the low-frequency part of AQI decomposed by SSA, which is as follows:
[0164] (2) OSRVFL
[0165] The characteristic of the OSRVFL model in implementing online training is that it introduces the idea of sequential learning into the random vector functional link network. During the online learning process, the model will update the sample data set and network parameters in a timely manner, effectively solving the problem of long training time caused by the increase in input data.
[0166] The OSRVFL network structure is as follows Figure 2 As shown in Figure 2, in the initial training stage, the output weight β0 of SFNN can be initialized with fewer samples, and then enter the online sequential learning stage to iteratively adjust the output weight β learned in the initial stage through each input sample.
[0167] Assume that the constructed network has r neurons in the input layer, l neurons in the hidden layer, and m neurons in the output layer. In the initial training stage, there are N0 arbitrary training samples (x i ,t i ), where x i =[x i1 ,x i2 ,...,x ir ] T ,t i =[t i1 ,t i2 ,...,t ir ] T Using the idea of traditional RVFL, the model with l hidden nodes and nonlinear mapping as activation function g(x) is:
[0168]
[0169] In formula (17): w i =[w i1 ,w i2 ,...,w ir ] Tis the weight connecting the i-th hidden node and the input layer; b i is the bias of the i-th hidden node, both of which are randomly generated; x i With t i are the input and output of the jth sample respectively; β i =[β i1 ,β i2 ,...,β ir ] T is the input weight connecting the i-th hidden node and the output node.
[0170] When β=[β1,β2,...,β r ] T is the target matrix of the training data, i=1,2,…,r, and the output matrix H0 of the hidden layer is:
[0171]
[0172] Then the matrix relationship is:
[0173] H0β=T0 (19)
[0174] In formula (19): The goal of RVFL network learning is to minimize the output error value. After calculating the hidden layer output, it is only necessary to solve the weight of the output layer. The objective function is:
[0175] min|H0β-T0| (20)
[0176] According to the generalized inverse method, the minimum β0 that meets the conditions is obtained.
[0177] β0=H + T0 (21)
[0178] In formula (21): H + is the generalized inverse matrix of H0, Let the intermediate matrix In the online learning phase, the hidden layer output H in the k+1th learning (k=0,1,…) is calculated k+1 , then P k+1 And the output weight β k+1 as follows:
[0179]
[0180] In formula (22): I is the unit matrix.
[0181]
[0182] Step 6: Use the air quality historical data in step 2 and the improved equilibrium optimization algorithm to train the air quality prediction model based on Transformer and OSRVFL multi-point correlation analysis to find the optimal model parameters and minimize the loss function error.
[0183] Step 7: Use the trained model to predict future data and output the prediction results.
[0184] The air quality prediction system disclosed in the present invention comprises:
[0185] The data acquisition module is used to collect data on air quality, including AQI, PM2.5, nitrogen oxides, carbon oxides, and sulfides.
[0186] The data processing module uses the Pearson correlation coefficient to calculate the correlation between the AQI of adjacent city sites, other air quality indices, meteorological data and the AQI of the predicted site, extracts strong correlation factors, performs feature dimensionality reduction on high-dimensional data sets, and finally determines the input dimension of each component; uses singular spectrum analysis SSA to decompose the AQI data of the predicted site, extracts the periodic components in the AQI data, and decomposes them into trends, oscillation components and noise.
[0187] In the neural network module, the Transformer and OSRVFL models are used to model the high-frequency and low-frequency signals of the AQI data respectively, and an air quality prediction model based on the multi-measurement point correlation analysis of Transformer and OSRVFL is established. The established Transformer and OSRVFL models are trained through the historical air quality data and the intelligent optimization module to obtain the optimal network parameters.
[0188] The intelligent optimization module uses reverse learning initialization to improve ABC to enhance the global search capability of the algorithm. A new improved artificial bee colony algorithm IABC is proposed and used for hyperparameter optimization of Transformer and OSRVFL models.
[0189] The cloud platform module displays historical data and air quality forecast results for a period of time in real time through the cloud platform.
[0190] The present invention compares the results of the test samples with those of the prediction model of the present invention, calculates the root mean square error (RMSE) and mean absolute percentage error (MAPE) between the predicted AQI and the actual AQI, and evaluates the effectiveness of the multi-suggestion method in this paper.
[0191] The specific formulas for the mean absolute error (RMSE) and mean absolute percentage error (MAPE) are:
[0192]
[0193]
[0194]
[0195] Among them, α(t) is the true value of the t-th sample, β(t) is the predicted value of the t-th sample, and N is the total number of samples.
[0196] In order to demonstrate the effectiveness and improvement of the proposed algorithm, this paper takes the air quality data of a certain city as an example. Table 1 shows the variables contained in the air quality data, and Table 2 shows the indicator results of the predicted values and true values of Transformer, OSRVFL and the model proposed in this paper.
[0197] Table 1 Air quality data variable names
[0198]
[0199]
[0200] Table 2 Comparison of the accuracy of different air quality prediction methods
[0201]
[0202] It can be clearly seen from Table 2 that the method proposed in this paper has the highest prediction accuracy and can provide a more accurate method for air quality prediction.
[0203] Figure 4 This is a fitting diagram of the predicted values and true values of the model of the present invention, Transformer, and OSRVFL. It can be seen from the figure that the value predicted by the model of the present invention is closer to the true value.
[0204] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the protection scope of the present invention.
Claims
1. An air quality prediction method based on multi-measurement point correlation analysis, characterized in that: It includes the following steps: Step 1: Collect the air quality data and meteorological data of a certain area, and reasonably optimize the data anomaly points and missing points to obtain a complete data set, which includes the air quality data and meteorological data of the predicted site and the AQI of adjacent city sites; the air quality data of the predicted site includes AQI, PM2.5, nitrogen oxides, carbon oxides, and sulfides; the meteorological data includes temperature, humidity, and wind speed. Step 2: Use the Pearson correlation coefficient to calculate the correlation degree between the AQI of adjacent city sites, other air quality indexes, meteorological data and the AQI of the predicted site, extract the strongly correlated factors, perform feature dimensionality reduction on the high-dimensional data set, and finally determine the input dimension of each component. Step 3: Use singular spectrum analysis (SSA) to decompose the AQI data of the site to be predicted, and extract the periodic components in the AQI data to decompose the trend, oscillation components and noise. Step 4: Optimize the artificial fish swarm algorithm using reverse learning to propose an improved artificial fish swarm algorithm IABC. Step 5: Respectively model the high-frequency signal and low-frequency signal of the AQI data by Transformer and the online sequential random vector functional link network OSRVFL, and establish the high-low frequency air quality prediction models of Transformer and the online sequential random vector functional link network OSRVFL. The air quality prediction model uses IABC to optimize the hyperparameters of Transformer and OSRVFL. Step 6: Train the high-low frequency air quality prediction models of the established Transformer and the online sequential random vector functional link network OSRVFL with the air quality historical data selected by the Pearson correlation coefficient in Step 2 and the improved artificial fish swarm algorithm IABC, and find the optimal parameters of the models and minimize the loss function error. Step 7: Use the trained model to predict future data and output the prediction results.
2. The air quality prediction method based on multi-measurement point correlation analysis according to claim 1 is characterized in that: In Step 2, the Pearson correlation coefficient is used to perform feature selection on the air quality data set. The steps of the Pearson correlation coefficient are as follows: The Pearson correlation coefficient is a statistical method to calculate the linear correlation between two features. i ,f j The Pearson correlation coefficient is: In the formula, Cov(f i ,f j ) represents the feature f i ,f j The covariance of Var(f i ) represents the feature f i The feature is scored by calculating the correlation coefficient between AQI and other air quality data and meteorological data. The higher the score, the better the feature.
3. The air quality prediction method based on multi-measurement point correlation analysis according to claim 1 is characterized in that: In Step 3, singular spectrum analysis (SSA) is used to decompose the AQI data and extract the periodic components in the AQI data to decompose the trend, oscillation components and noise. The specific steps are as follows: (1) Embedding For a time series [x1,x2,...,x N ], the first step is to choose a suitable window length L to lag behind the original time series to obtain a trajectory matrix: Select L < N / 2. Let K = N - L + 1, then the trajectory matrix X is an L*K matrix: (2) Decomposition Eigenvalues λ1,λ2,...,λ L and its associated eigenvectors U1,U2,...,U L The eigenvalue decomposition EVD of the covariance matrix of the trajectory matrix is obtained, and the singular value decomposition SVD of X is expressed as: in, (3) Reorganization First, calculate the lagged series X i in U m Projection on: Among them, X i represents the i-th column of the trajectory matrix X, is the x in the original sequence i+1 ,x i+2 ,...,x i+L X is reflected in each stage i The weights of the time-evolving patterns represented by , which are called temporal principal components; Then use the empirical orthogonal function and the time principal component to reconstruct the sequence. The specific reconstruction procedure is as follows: The sum of all reconstructed sequences is equal to the original sequence, where x i As shown below:
4. The air quality prediction method based on multi-measurement point correlation analysis according to claim 1 is characterized in that: The steps of the improved artificial bee colony algorithm in Step 4 are as follows: (1) Generate the initial nectar source location using reverse learning improved strategy; First, use formula (8) to randomly generate some nectar source locations as the initial solution to the problem before the bees collect nectar, and then use formula (9) to reversely learn and calculate the reverse nectar source location; Assume that in D-dimensional space, randomly generate N nectar source locations and use X i =(x i1 ,x i2 ,...,x id ) represents the i-th honey source information: x id =L d +rand*(U d -L d ) (8) x new_id =(U d +L d )-x id (9) Where: x id is the position of the i-th nectar source in the d-th dimension space, x new_id For x id The reverse nectar source position, U d and L d Respectively represent the upper and lower bounds of the search space, rand is a random number (0,1), then calculate x new_id and x id The fitness value of the nectar source is retained as the initial nectar source; (2) The forager bees perform neighborhood search. The number of forager bees corresponds one-to-one to the information of the initial nectar source. After the information of the initial nectar source is generated, the forager bees will perform neighborhood search around the initial nectar source, compare the newly obtained nectar source information with the previous nectar source information, and finally retain the better one of the nectar source information, thus completing the update of the nectar source; the forager bee neighborhood search formula is: Among them, v id represents the new nectar source location information, j is another bee number besides i, is a random number uniformly distributed between [-1,1], which determines the amplitude of the disturbance; (3) Follower bees follow up the search. When the honey bees complete the neighborhood search, they return to the hive and share the new nectar source information with the follower bees in the form of a tail-wagging dance. The follower bees follow up the search using the roulette method based on the nectar source information provided by the honey bees. The nectar source location with a larger amount of nectar, closer to the hive, and easier to mine is more likely to be selected. The probability of a nectar source location being selected is p. i for: Among them, p i is the probability of the i-th nectar source being selected, fit i is the nectar value of the i-th nectar source, which is closely related to the quality of the nectar source. The better the nectar source information, the greater the probability of being selected; (4) Global search by scout bees. When the location information of a nectar source does not change for many consecutive times, the follower bees will abandon the location of the nectar source and transform themselves into scout bees, jumping out of the local optimum to conduct a global search and randomly update the location of the nectar source using formula (9).
5. The air quality prediction method based on multi-measurement point correlation analysis according to claim 1 is characterized in that: In step 5, the high and low frequencies of the Transformer and the online sequential random vector functional link network OSRVFL are constructed, wherein the Transformer models the high frequency signal of the AQI data, and the input data includes the high frequency part of the AQI decomposed by SSA in step 3 and the strongly correlated features extracted by the Pearson correlation coefficient in step 2, and the output is the prediction result of the high frequency part of the AQI decomposed by SSA; the specific steps are as follows: The Transformer structure is composed of multiple encoders and decoders stacked together. Each layer has the same structure. After the information is input into an encoder, it is output and input into all encoders in succession. The last encoder then outputs the information to the decoder. The encoder module includes multi-head attention and feedforward neural network. The decoder module has an additional masked multi-head attention, a residual connection and layer normalization after each layer in the encoder and decoder; The position encoding method uses sine and cosine functions to encode position information; for each position in the sequence, the position encoder generates a vector of fixed size, where each dimension corresponds to a sine or cosine function of a different frequency, and the encoding vectors at different positions have different angles in space, thereby expressing the relative position relationship between them. The formula for position encoding is as follows: Among them, pos represents the position, i represents the dimension index, and d model Represents the dimensions of the model; The multi-head self-attention mechanism incorporates the position trajectory vector of the previous and next time perception into the attention calculation, and for the embedded feature vector The multi-head self-attention mechanism first calculates the query vector from t=1 to T Key Vector Sum value vector The calculation formula for attention is as follows: Among them, d k represents the dimension of each vector, The product term represents the numerical stability of attention, and softmax is a normalized exponential function; The multi-head attention mechanism allows the model to jointly focus on information from different representations at different locations when calculating attention. The calculation formula with h attention heads is as follows: Among them, f c (·) is a fully connected layer that merges the outputs of h attention heads, Att i (Q, K, V) represents the self-attention of the i-th head, and then the output of the multi-head attention MultiHeadAtt(Q, K, V) passes through the Add&Nom layer and the feedforward neural network layer to output the updated trajectory feature vector. The calculation formula of the Add&Norm layer is as follows: LayerNorm(X+MultiHeadAtt(X)) (15) Among them, X and MultiHeadAtt(X) represent the input and output vectors of the multi-head attention layer respectively. The input and output have the same dimensions and are connected with residuals to solve the gradient vanishing problem of multi-layer network training and make the network pay attention to global and local feature vectors. Finally, the encoded feature representation is output by the feedforward network layer, which consists of two fully connected layers. The activation function of the first layer is Relu, and the second layer does not use an activation function. The calculation formula is as follows: FNN(X)=max(0,XW i +b i )w2+b2 (16) Among them, X represents the input, W1 and W2 are weights, and b1 and b2 are biases; Finally, the feedforward neural network layer FFN(X) outputs the encoded trajectory feature representation, and the dimension of the output matrix is consistent with X.
6. The air quality prediction method based on multi-measurement point correlation analysis according to claim 1 is characterized in that: In step 5, a high- and low-frequency air quality prediction model of Transformer and online sequence random vector functional link network OSRVFL is constructed, wherein the online sequence random vector functional link network OSRVFL models the low-frequency signal of AQI data, and its input data includes low-frequency data and strong correlation factors, which are opposite to the high-frequency part here. The input data includes the low-frequency part of AQI decomposed by SSA in step 3 and the strong correlation features extracted by Pearson correlation coefficient in step 2, and the output is the prediction result of the low-frequency part of AQI decomposed by SSA. The specific steps are as follows The OSRVFL model introduces the idea of sequential learning into the random vector function link network. In the initial training stage, the output weight β0 of OSRVFL is initialized with a small number of samples, and then enters the online sequential learning stage, and the output weight β learned in the initial stage is iteratively adjusted through each input sample. Assume that the constructed network has r neurons in the input layer, l neurons in the hidden layer, and m neurons in the output layer. In the initial training stage, there are N0 arbitrary training samples (x i ,t i ), where x i =[x i1 ,x i2 ,...,x ir ] T ,t i =[t i1 ,t i2 ,...,t ir ] T , using the idea of traditional RVFL, the model with l hidden nodes and nonlinear mapping as the activation function g(x) is: In formula (17): w i =[w i1 ,w i2 ,...,w ir ] T is the weight connecting the i-th hidden node and the input layer; b i is the bias of the i-th hidden node, both of which are randomly generated; x i With t i are the input and output of the jth sample respectively; β i =[β i1 ,β i2 ,...,β ir ] T is the input weight connecting the i-th hidden node and the output node; When β=[β1,β2,...,β r ] T is the target matrix of the training data, i=1,2,…,r, and the output matrix H0 of the hidden layer is: Then the matrix relationship is: H0β=T0 (19) In formula (19): T i =[t1,t2,...,t N0 ] T , the goal of RVFL network learning is to minimize the output error value. After calculating the hidden layer output, it is only necessary to solve the weight of the output layer. The objective function is: min|H0β-T0| (20) According to the generalized inverse method, the minimum β0 that meets the conditions is obtained: β0=H + T0 (21) In formula (21): H + is the generalized inverse matrix of H0, Let the intermediate matrix In the online learning phase, the hidden layer output H in the k+1th learning (k=0,1,…) is calculated k+1 , then P k+1 And the output weight β k+1 as follows: Where: I is the unit matrix.
7. The air quality prediction system based on multi-measurement point correlation analysis according to claim 6, characterized in that: In step 5, IABC is used to optimize the hyperparameters of Transformer and OSRVFL. The hyperparameter of OSRVFL is the number of hidden layer nodes, and the hyperparameters of Transformer include: the number of layers, model dimension, and the number of heads.
8. An air quality prediction system based on the multi-measurement point correlation analysis according to any one of claims 1 to 7, characterized in that: Includes the following modules: Data acquisition module, used to collect data on air quality, including AQI, PM2.5, nitrogen oxides, carbon oxides, and sulfides; The data processing module uses the Pearson correlation coefficient to calculate the correlation between the AQI of neighboring city sites, other air quality indexes, meteorological data and the AQI of the predicted site, extracts strong correlation factors, performs feature dimensionality reduction on high-dimensional data sets, and finally determines the input dimension of each component; uses singular spectrum analysis SSA to decompose the AQI data of the predicted site, extracts the periodic components in the AQI data, and decomposes them into trends, oscillation components and noise; The neural network module uses the Transformer and OSRVFL models to model the high-frequency and low-frequency signals of AQI data respectively, and establishes an air quality prediction model based on the multi-measurement point correlation analysis of Transformer and OSRVFL. The established Transformer and OSRVFL models are trained through the historical air quality data and the intelligent optimization module to obtain the optimal network parameters. The intelligent optimization module uses reverse learning initialization to improve ABC and obtain the improved artificial bee colony algorithm IABC, which is used to optimize the hyperparameters of the Transformer and OSRVFL models. The cloud platform module displays historical data and air quality forecast results for a period of time in real time through the cloud platform.
