# Research on PM2.5 Concentration Prediction Based on the CE-AGA-LSTM Model
## 3 Methods
### AGA-LSTM Prediction Model  
LSTM is a subtle control of the combination of short-term memory and long-term memory through a \"gate structure\", which solves the problem of gradient disappearance to a certain extent and gives better results than a recurrent neural network for time series data analysis. However, in the process of constructing the LSTM model, some model parameters, such as the number of neurons in the hidden layer, the number of training times, the learning rate, etc., need to be assumed first, and the selection of these parameters also affects the prediction accuracy of the model. In this paper, a heuristic search algorithm-genetic algorithm was used to determine the model parameters by optimizing the global optimal solution and improve the accuracy of model prediction.  
Genetic algorithms (GA) are a class of stochastic search algorithms that draw inspiration from natural selection and natural genetic mechanisms in biology. They are very suitable for dealing with complex and nonlinear optimization problems which are difficult to solve by traditional search methods. The crossover probability and mutation probability of genetic algorithms are the key parameters which affect their behavior and performance and directly influence the convergence of the algorithms. Adaptive genetic algorithms (AGAs) [28] enable the crossover probability and mutation probability to change automatically with fitness. In this paper, AGA and LSTM were integrated to build an AGA-LSTM prediction model so to achieve PM2.5 prediction. The basic framework of the AGA-LSTM prediction model is shown in Figure 1.  
Basic process of the AGA-LSTM prediction model:  
Step 1. Binary encode of the number of neurons, training times and learning rates of the parameters' hidden layer in the LSTM.  
Step 2. Generate the initial population N (even number).  
Step 3. Establish the LSTM model, train and predict the data of training set and test set and take the predicted mean-square error as the AGA fitness value \(f_{i}\).  
Step 4. Select N individuals according to the roulette rule and calculate \(f_{avg}\) and \(f_{\max}\).  
Step 5. Each individual in the population is randomly paired into pairs, forming a total of N/2 pairs, and each pair of individuals is calculated according to the adaptive formula \(P_{c}=\begin{cases}\frac{k_{1}(f_{\max}-f^{\prime})}{f_{\max}-f_{avg}},&f^{ \prime}>f_{avg}\\ k_{2},&f^{\prime}\leq f_{avg}\end{cases}\) to generate the adaptive crossover probability, randomly generating R (0,1), if \(R<P_{c}\); then, the crossover operation is performed on a pair of chromosomes.  
Step 6. For all individuals N in the population, calculate the adaptive variation probability according to the adaptive variation formula \(P_{m}=\begin{cases}\frac{k_{3}(f_{\max}-f_{avg})}{f_{\max}-f_{avg}},&f>f_{avg} \\ k_{4},&f\leq f_{avg}\end{cases}\) and, if \(R<P_{m}\), then perform crossover operations on that chromosome.  
Step 7. Calculate the fitness of new individuals generated by crossover and mutation, which together with their parents form a new population.  
Step 8. Determine whether the termination condition is satisfied; if it is satisfied, the termination returns the optimal parameters, otherwise execute step 4.  
Step 9. Use the optimal parameters obtained by AGA to construct the LSTM network model; train the model and obtain the prediction results.