A hybrid model integrating long short-term memory with adaptive genetic algorithm based on individual ranking for stock index prediction

Modeling and forecasting stock prices have been important financial research topics in academia. This study seeks to determine whether improvements can be achieved by forecasting a stock index using a hybrid model and incorporating financial variables. We extend the literature on stock market forecasting by applying a hybrid model that combines wavelet transform (WT), long short-term memory (LSTM), and an adaptive genetic algorithm (AGA) based on individual ranking to predict stock indices for the Dow Jones Industrial Average (DJIA) index of the New York Stock Exchange, Standard & Poor’s 500 (S&P 500) index, Nikkei 225 index of Tokyo, Hang Seng Index of Hong Kong market, CSI300 index of Chinese mainland stock market, and NIFTY50 index of India. The results indicate an overall improvement in forecasting of the stock index using the AGA-LSTM model compared to the benchmark models. The evaluation indicators prove that this model has a higher prediction accuracy when forecasting six stock indices.


Introduction
Stock market forecasting is one of the most challenging research topics in the financial field. The time series of the stock market has typical characteristics of nonlinearity, high noise, and dynamic change. A company's fundamental information, news, investors' psychological state, industry background, macro policies, and other factors may affect the violent fluctuation of the stock. This high volatility makes it difficult to predict stock markets. The advantage of traditional econometric models is the processing of linear data based on strict basic assumptions. The models include the autoregressive integrated moving average (ARIMA) and generalized autoregressive conditional heteroskedasticity (GARCH) models, which have proven to be effective under these premises [1]. However, the linear model cannot accurately reflect the real distribution of stock data or solve complex financial data series problems. Therefore, traditional econometric methods cannot achieve the best prediction when dealing with nonlinear, non-parametric, and massive data [2]. In recent years, with the development of artificial hyperparameters such as the number of hidden layers, different numbers of nodes for each layer, weights, and biases [27].
GA is a parallel and global search algorithm that can effectively solve complex problems by simulating the genetic operators to imitate the biological process of reproduction. Crossover and mutation are the most important phases in GA operation. The crossover process in the GA may lead to local minima, whereas a mutation is proposed to overcome this issue because it randomly generates a new chromosome called a mutant [28]. GA uses a fixed crossover rate and mutation rate during the evolutionary process. Individuals with inferior fitness can be quickly screened during the early stages of evolution. However, this method suffers from a premature convergence. Ho proposed a sequential optimization method to quantitatively evaluate an optimization method based on random probability [29]. The adaptive genetic algorithm (AGA) based on individual ranking can increase the crossover rate and mutation rate in the middle and late stages of population evolution and accelerate the convergence speed of the population to the optimal solution.
Fixed crossover rate and mutation rate are adopted in canonical genetic algorithms. The advantage of fixed crossover rate and mutation rate that is that the individuals with poor fitness can be quickly screened out in the early stage of evolution. These algorithms cost little computation resources and gain fast convergence speed. However, there is the problem of premature convergence. AGA is a sequential optimization method to quantitatively evaluate the optimization method from the perspective of probability. This random optimization algorithm can be suitable for solving the problem. By using AGA, the average fitness value and all fitness values in the population are calculated and combined into a new fitness value matrix after initialization, selection and other operations. Then, the fitness values, that is, the ranking number of the maximum, minimum and average fitness values, of all individuals are ranked in the new matrix. The ranking number is substituted instead of the specific fixed fitness value into the adaptive calculation formula of crossover rate and mutation rate. By this method, the crossover rate and mutation rate are determined by the ranking position of individual fitness value in the population instead of the actual fitness value. Therefore, the sorting number is used to update the crossover and mutation probability adaptively. The adaptive strategy can increase the crossover rate and mutation rate in the middle and late stage of population evolution, improve the optimization ability of the algorithm, help the algorithm jump out of the local optimal solution and accelerate the convergence speed of the population to the optimal solution.
A hybrid model integrating long short-term memory and adaptive genetic algorithm based on individual ranking (AGA) is proposed in this study. AGA is adopted to optimize the network structure of the LSTM model, the number of neurons in the LSTM layer, the number of neurons in the full connection layer, the exit rate and the training cycle of the neural network. AGA-LSTM model is applied to predict stock price. The main contributions of this study are as follows: (1) High accuracy. AGA-LSTM model is proposed to train the hyperparametric combination to find the optimal hyperparametric combination. Compared with other models, AGA-LSTM model achieves higher accuracy in predicting stock prices. (2) High computational efficiency. The optimization methods of real number coding and individual sequencing are applied in AGA. These optimization strategies help the crossover and mutation probability of genes adjust adaptively. As the difference of each individual's fitness is small, the adaptive algorithm based on individual fitness ranking can improve the speed of finding the optimal solution effectively. AGA-LSTM model has high computational efficiency. (3) Better convergence. The elitist preservation is adopted to ensures the optimal individuals that emerge during the evolutionary process will not lost or destroyed in the processes of selection, crossover and mutation operations. The strategy enhances the ability of the algorithm to converge to the global optimum. The experimental results show that the algorithm has better convergence to the global optimization.
This study will optimize the LSTM model by employing the adaptive genetic algorithm (AGA) based on individual ranking to obtain the superior prediction effect. The model proposed in this study consists of three parts: wavelet transform (WT), adaptive genetic algorithm based on individual sorting (AGA), and long and short-term memory (LSTM). WT was applied for the denoising time series. AGA optimizes the network structure, number of neurons, training times, and forgetting rate of the LSTM model through real number coding, crossover operators, and mutation operators based on individual ranking. The prediction accuracy was evaluated using five measurements: mean square error (MSE) [30][31][32], root mean square error (RMSE) [31][32][33], mean absolute error (MAE) [30][31][32][33], mean absolute percentage error (MAPE) [30][31][32], and goodness of fit (R 2 ) of the model [33,34].
According to the efficient market hypothesis (EMH), the degree of market development is heterogeneous. Six stock indices were used to test the prediction accuracy of the model. These indices include the Dow Jones Industrial Average (DJIA) index of the New York Stock Exchange, Standard & Poor's 500 (S&P 500) index, Nikkei 225 index of Tokyo, Hang Seng Index of Hong Kong market, CSI300 index of Chinese Mainland stock market, and Nifty50 index of India. These six stock indices represent three different developmental stages of the stock market. For example, the New York Stock Market is the most mature and largest exchange in the world. It is considered the most developed and efficient market. The stock markets in Hong Kong and Tokyo are in the middle stage between efficient and inefficient markets. In contrast, the stock markets in mainland China and India are generally considered developing markets; therefore, we can evaluate the effectiveness of our model by testing the stock market in different developmental stages.
The remainder of this paper is organized as follows. Section 2 introduces the methodology applied in this study, including the LSTM, GA, and AGA. Section 3 presents the hybrid model and introduces the details of the experimental design. Section 4 summarizes the experimental results and compares them to those of the benchmark model. Finally, Section 5 summarizes the research.

LSTM
The RNN structures enable the learning of temporal patterns for sequential data. However, RNNs cannot memorize temporal patterns in previous deep feedforward networks over a long period of time because of the gradient disappearance or gradient explosion of RNNs [35]. The LSTM unit was proposed as an RNN variant of RNNs learning sequential patterns [36]. LSTMs have gating mechanisms that can selectively learn and retain temporal patterns over a longer time span. Fig 1 represents the repeating module in an LSTM consisting of a memory cell and gate.
The gating mechanisms, consisting of a sigmoid activation function and point multiplication operation, regulate the flow of information. The three gates are called the input, forget, and output gates, respectively, and the calculations for each gate are performed using the following formulas.
The input gate i t shown in Formula 1 and the candidate value of the memory cellsC t shown in Formula 2 update the selected information. The calculation is performed by multiplying the two vectors created by the input gate layer and the tanh layer.
The forget gate can be written as where σ is the sigmoid activation function, W f represents the connection weight of the previous output, b f is the bias vector, h t−1 and x t correspond to the previous output and the current input, respectively. The output gate updates the temporal state by adding information from the input and forget gates [37]. o t and C t are the values of the output gate and memory cell at time t, respectively.
The new updated state of the memory cell is shown as: The value of the output gate was calculated based on the new state of the memory cell.
The final output value of cell is calculated by The output value of the memory cell is determined by four units: input gate, output gate, forget gate, and self-recurrent neuron. The input gate determines whether the input signal can alter the state of the memory cell. The output gate controls the updated state of the memory cell. Furthermore, the forget gate decides to retain or discard its previous state, and the LSTM

PLOS ONE
architecture is an effective solution for combating vanishing gradients confronted with RNNs using memory cells. Fig 2 shows the LSTM network structure connected to each LSTM unit with a chain structure.
The training process of the LSTM model includes three steps. First, the output value of the LSTM unit was calculated using the forward propagation method, and the error value was back-propagated. Second, the weight gradient is calculated based on the error value. Subsequently, the optimization algorithm is applied for gradient descent, and the weight is continuously updated. Owing to this repeating process, the LSTM architecture is capable of learning long-term patterns at low computational costs [38].
Stochastic gradient descent (SGD), adaptive gradient algorithm (AdaGrad), and adaptive moment estimation algorithm (Adam) are three typical optimization algorithms used in neural networks. The SGD maintains a single learning rate. Conversely, Adam can obtain an independent adaptive learning rate for each parameter based on the calculations of both the firstorder moment estimation and second-order moment estimation [39]. However, long training times and overfitting problems occurred as the number of network layers increased. Adding a dropout rate and omitting a certain ratio of feature detectors randomly in each training case can effectively reduce overfitting [40].

GA
The GA is a metaheuristic and stochastic optimization method that mimics the evolution mechanism of natural selection according to "the survival of the fittest" principle [41]. The GA simulates the natural evolution process through chromosomes, populations, offspring, and parents to search for the optimal solution. The basic steps in heredity include gene coding, generation of the primary population, chromosome selection, chromosome crossover, and chromosome mutation. The GA continuously produces new offspring to determine the optimal solution by gradually transforming the chromosomes that are the candidate solutions to the given problem.

PLOS ONE
The definition of the fitness function, crossover rate, and mutation rate are crucial factors in the GA implementation process. The fitness function can be considered as the degree of adaptation of individuals in the population in nature. The higher the fitness, the greater the chance of reproduction, and vice versa. Therefore, determination of the fitness function is directly related to the search for an optimal solution [28]. The crossover and mutation rates directly affect the optimization ability of the genetic algorithm. The crossover operation is at the core of GA. The large crossover rate causes the pattern of old individuals to be easily destroyed to produce new individuals faster. The recombination of excellent individual genes produces superior individuals with a certain probability. Mutation is a key factor that helps the algorithm jump out of local optimization. However, a low variation rate cannot produce a new pattern structure. However, the high mutation rate makes the algorithm a random-search algorithm.

AGA
The GA uses a fixed crossover rate and mutation rate, which can quickly screen out individuals with poor fitness in the early stages of evolution. However, it is easy to destroy excellent individuals in the late stage of evolution, which leads to premature convergence. The mechanism of adaptive genetic algorithm (AGA) proposes that the crossover rate and mutation rate should change based on the individual fitness value to improve the optimization ability and accelerate the convergence speed.
Srinivas and Patnaik proposed that the crossover rate and mutation rate should be dynamically adjusted according to individual adaptability to balance the search and randomness [42]. The concentration of population fitness and rare diversity restrict most individuals in the population within the local optimal solution set. More concentrated individuals in the population can evolve further by increasing the crossover and mutation rates, which enhances the optimization ability of the algorithm. The dispersion and diversity of population fitness cause the population to scatter in the solution space. The convergence of the individual fitness value towards the optimal solution set can be promoted by reducing the crossover and mutation rates, which accelerates the convergence of the algorithm. However, this adaptive method stagnated during the early stages of the evolution. In addition, when the crossover and mutation rates are zero, superior individuals cannot undergo benign evolution, which makes the evolution process easy to fall into local optimization. The crossover and mutation rates of AGA were calculated as follows.: F max is the maximum fitness value and F avg is the average fitness value of the population.
8 > < > : To solve local optimization problems, Zhang et al. proposed improved calculation formulas for AGA [43]. The improved formulas improve the crossover and mutation rates of superior individuals, which avoids the crossover and mutation rate of individuals with the maximum fitness value from zero. This prevents the potential optimal solution in the initial stage of population evolution from stopping evolution, which makes the algorithm jump out of the local optimal solution to obtain the global optimal solution. The improved formulas are as follows.
8 > > > > < > > > > : Qu et al. suggested that the crossover and mutation rates of superior individuals should be reduced as much as possible to preserve them. Meanwhile, the cross-mutation rate should be increased to change the inferior state as much as possible in inferior individuals [44]. The crossover and mutation rates should be adaptive to different iteration periods. A larger crossover rate and mutation rate can expand the range of solutions and quickly find the optimal solution set in the early stages of population iteration. The smaller crossover and mutation rates cause the population to converge quickly in the optimal solution set in the later stages of the iteration.
Ho proposed an optimization method based on sorting numbers, which uses ordinal numbers instead of cardinal values for optimization [29]. The crossover and mutation rates obtained by this method depend on the ordinal number of individual fitness values in the population, rather than the actual fitness value. The algorithm combines the average fitness value and all the fitness values in the population into a matrix. The ranking number of the maximum, minimum, and average fitness values in the matrix can then be obtained by ranking the fitness values of all individuals. Finally, the ranking number is substituted into the calculation formula of the crossover rate and mutation rate, instead of the specific fitness value. The formulas for the adaptive crossover and mutation rates are as follows: 8 > > > < > > > : N 1 is the ranking number of larger parent fitness values. N 2 is the ranking number of the average fitness value, and N 3 is the ranking number of the maximum fitness value. The ranking method appropriately increases the crossover and mutation rates in the later stages of the population. P c1 is equal to 0.9 or 1. P c2 takes a value in the interval [0.5,1] to adjust the crossover rate. The P m1 is equal to 0.09 or 0.1. P c2 takes a value in the interval [0.05,0.1] to adjust the crossover rate.

A hybrid prediction model based on LSTM approach and AGA
According to recent related studies, LSTM is considered suitable for stock market predictions. In this study, we propose a hybrid model that integrates LSTM and AGA for stock index prediction. This model comprises three main components: data processing, parameter optimization, and model evaluation, as shown in Fig 3. The first component processes the historical stock-trading data used in the model. The second component employs AGA to optimize the parameters based on the LSTM neural network. Finally, the predictive accuracy of the hybrid model was evaluated by combining the optimization results. Furthermore, the model was compared with different benchmark models.

Dataset preparation and prepossessing
3.1.1 Sample selection and predictive inputs. DJIA, S&P500, Hang Seng, Nikkei 225, CSI 300, and Nifty50 are the six stock indices chosen as samples, which represent the categories of markets; all six stock index datasets are from the WIND database (http://www.wind. com.cn) provided by Shanghai Wind Information Co., Ltd, CSMAR database (http://www. gtarsc.com) provided by Shenzhen GTA Education Tech. Ltd., and the global financial portal Investing.com. The time series for the daily datasets were from 2008/07/02 to 2016/09/30. We selected three sets of variables as the inputs. The first set of predictive inputs is the historical trading data of each index, including open, high, low, and close prices (OHLC variables), as well as the trading volume [17,45,46]. These raw prices record fundamental trading information for each index. The second set of predictive inputs consists of 12 technical indicators for each index [47,48]. The details are as follows: moving average convergence divergence

PLOS ONE
behavior or trends in a time series. This representation is more appropriate than raw prices, which simplifies the machine learning models. The final set of predictive inputs is the macroeconomic indicators, including the exchange rate and interest rate, which are the most popular economic indicators used as variables [49,50].
Interest rates have proven useful as predictive inputs [49]. Fundamental analysis uses economic indicators to understand how stock market changes are related to macroeconomic conditions, particularly the influence of the monetary market. As the US dollar plays the most important role in the international monetary market, the US dollar index is used as the proxy for the exchange rate in this study. Regarding the interest rate, the interbank offered rate in each market is appropriate as a proxy [49]. The federal funds rate in the US, Tokyo Interbank Offered Rate (TIBOR), Hong Kong Interbank Offered Rate (HIBOR), Shanghai Interbank Offered Rate (SHIBOR), and Mumbai Interbank Offered Rate (MIBOR) are used as predictive inputs. Tables 1-3 are the data examples. 3.1.2 Data denoising. In this study, the Pywt Library in Python was used for wavelet transform to remove data noise from the six-stock index. Figs 4 and 5 are the closing price curves of the S&P500 before and after wavelet transform, respectively.

Data normalization.
Historical stock price data contain continuous variables with different measurement units for volume and price. Furthermore, some technical indicators include rate measurements. Data normalization is a crucial step that can utilize (13) to process different scaled features. Specifically, the normalization of input feature values is helpful for speeding up gradient descent convergence [26]. As data normalization preserves all relationships in the data precisely, it avoids bias [51].

PLOS ONE
where, x norm is the converted value. x max is the maximum value of the sample and x min is the minimum value of the sample. Through data normalization, the original data sequence x = (x 1 , x 2 ,. . .,x n }, was converted into a new data sequence D = (d 1 , d 2 ,. . .,d n }. The normalized data were divided into training and test sets, d tr = (d 1 , d 2 ,. . .,d m } and d te = (d m+1 , d m+2 ,. . .,d n }, respectively. S is the timestamp of the data, which was set to 50. Therefore, the input data are as follows: X ¼ fX 1 ; X 2 ; :::; X s g; ð14Þ The actual and predicted closing prices are shown as follows.

Real number coding.
The AGA coding method used in this study was real number coding. This coding method has the function of fine-tuning and directly performs genetic operations on the performance of the solution, which can mine heuristic information related to the optimal solution of the problem.

PLOS ONE
Eight genes were identified for each individual. The first gene, with a step size of one, represents the number of LSTM layers. The number of layers ranged from one to two. The second gene, with a step size of 1, represents the number of fully connected layers, and the number of layers ranges from 1 to 2. The third gene with a step size of 1 and the fourth gene with a step size of 1 represent the number of neurons in each LSTM layer. The number of neurons used ranged from 32 to 128. If the represented layer did not exist, the number of neurons was coded as 0. The fifth gene, with a step size of 1, and sixth gene with a step size of 1 represent the number of neurons in the entire junction layer. The number of neurons used ranged from 32 to 128. Similarly, if the represented layer did not exist, the number of neurons was coded as 0. The seventh gene with a step size of 0.1 represented the dropout rate of the dropout layer, and the number of dropout rates ranged from 0.1 to 0.5. The eighth gene, with a step size of 50, represented the number of epochs trained by the neural network. The number of epochs ranged from 50 to 250. In addition, there was only one neuron in the last layer, and the activation function was a sigmoid. To maintain the diversity of solutions, the dropout and epoch genes did not participate in cross-mutation. Fig 6 shows the chromosomes used in this study.

Individual-ordering-based adaptive crossover method.
An adaptive single-point crossing method was adopted in this study. First, an intersection was randomly set in a single chromosome. The two individuals then crossed the genes at the corresponding positions. The first and second numbers did not intersect, because they represent the number of layers. If the two numbers crossed, the number of subsequent neurons was affected. If the third to sixth positions exchanged genes with the number 0, they should not be crossed. The adaptive crossover probability is calculated based on Eq (5) mentioned in Section 2.3.

Individual-ordering-based adaptive mutation method.
The adaptive single-point mutation method was used in this study. This method adjusts only the individual values after the first two genes and randomly selects the values according to the corresponding range. The third to sixth values were randomly selected from 32 to 128. The seventh value was randomly selected from 0.1 to 0.5. The final values were randomly selected from 50 to 250. The adaptive mutation probability is calculated based on Eq (6) mentioned in Section 2.3.

Elitist preservation strategy.
The roulette method is used to select individuals based on the proportion of generated random numbers in the GA. However, the roulette method may mistakenly eliminate individuals with high fitness, and the fitness of each individual in this experiment was similar. The crossover and mutation operators used in the roulette method may destroy the high-average fitness pattern. Selection, crossover, and mutation may lead to erroneous elimination of the best individuals in the current population. In addition, this error may occur repeatedly during evolution. To avoid this phenomenon, we adopt an elite protection strategy, that is, copy the best individual (called an elite individual) in the population in the process of evolution into the next generation before crossover. Elites are individuals with the highest fitness value, best genetic structure, and good characteristics searched by a genetic algorithm in the process of population evolution. Therefore, the optimal individuals generated in the evolution process will not be lost or destroyed because of the selection, crossover, and mutation operations, which improves the ability of the algorithm to converge to global optimization.

AGA training method.
The first 82% of all stock data were used as training data and the last 18% as test data in the AGA-LSTM model. The specific steps of the adaptive genetic algorithm are as follows. First, the population was initialized, and the value of each chromosome was determined. Subsequently, the number of network layers, hidden neurons, and iterations of the LSTM neural network were determined. Next, the neural network was trained to predict the stock index. Finally, the prediction effect of the model is obtained by comparing the actual price of the sample with the predicted price of the model. In this study, the mean square error (MSE) of the model was used as the fitness function, and the smaller the MSE, the higher the prediction accuracy.
whereŷ i is the predicted price of the model's ith observation, y i is the desired price, and n is the number of samples. The roulette method was used to generate a next-generation population. The adaptive crossover and mutation operations are performed on the individuals of the new population to generate new individuals. This process is repeated to reach the maximum number of iterations, output the optimal individual, and retain the optimal LSTM model. Finally, the training data are processed in the optimal LSTM model to output the predicted price, which is then compared with the actual price.

Evaluation indicators
The evaluation indicators used in this study were the mean square error (MSE) [30][31][32], root mean square error (RMSE) [31][32][33], mean absolute error (MAE) [30][31][32][33], mean absolute percentage error (MAPE) [30][31][32], and goodness of fit (R 2 ) of the model [33,34]. RMSE is defined as RMSE ¼ ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi ffi 1 n MAE is given as MAPE is defined as R 2 is defined as The MSE, RMSE, MAE, and MAPE were used to measure the deviation between the actual and predicted values. The smaller the value, the closer the predicted value to the actual value. R 2 was used to measure the degree of model fitting. The closer it was to 1, the better the model fitting.

Parameter setting
The hardware and software environment used in the experiment were as follows: the processor was an Intel (R) Core (TM) i5-9500 CPU with 8.0 GB memory; the system was Windows 10 (64 bit); the programming language version was Python 3.8.5; and the IDE was Jupyter 2021.8 in Visual Studio code extension. The AGA-LSTM, GA-LSTM, and LSTM were implemented in the Keras library with Tensorflow as the backend. Other machine learning (ML) models have been implemented in scikit-learn. This study used the first 82% of all stock data as training data and the last 18% as test data. Table 4 expresses the parameter set for the adaptive genetic algorithm.

Convergence comparison 4.2.1 Convergence of AGA-LSTM algorithm.
The convergence of the algorithm is the key to improving its performance. The AGA-LSTM neural network was trained 250 times and its change pattern was observed. As shown in Fig 7, with an increase in training time, the error gradually converges, indicating that the algorithm is stable. This evolutionary method is suitable for the later stages of population evolution, as it can retain excellent individuals and achieve rapid convergence.

Optimal individual.
According to the statistics of 50 optimal individuals, as shown in Fig 8, the correlation coefficients of nod, nofl, nosd, and MSE are 0.12, -0.1 and 0.15, respectively, with weak correlation, and the correlation coefficients of nol, nofl, and nofd with MSE are -0.044, -0.046 and 0.032, respectively, with little relevance.
A fine comparison of the 30 optimal individual statistical parameters is shown in Fig 9; the correlation coefficients of nosl, nofd, and MSE are 0.16 and 0.29, respectively, with weak correlation; The correlation coefficients of nol, nod, nofl, and MSE were 0.084, 0.006 and 0.015, respectively, with little relevance.
A detailed comparison of the statistical parameters of the first 50 individuals and a statistical description of the prediction accuracy are shown in Table 5. Among the first 50 optimal value data generated by 50 iterations, the search coverage of nol and nod is 1~2; The search range of nofl, nosl, nofd, and nosd is 32~128; The search range of the six parameters is close to the full search space, and the error obtained is approximately the optimal solution. The minimum error was 5.23E-05 and the average error was 6.09E-05.
A detailed comparison of the statistical parameters of the first 30 individuals and a statistical description of the prediction accuracy are shown in Table 6. In the first 30 optimal value data generated by 30 iterations, the search coverage of nol and nod was 1-2, the search range of nofl, nosl, nofd, and nosd was 32-128, the search range of the six parameters was close to the full search space, and the error obtained was approximately the optimal solution. The minimum error was 5.23E-05 and the average error was 5.77e-05.    Fig  10, AGA-LSTM, and GA-LSTM can quickly determine the approximate optimal solution in the search space. Compared with GA, the convergence effect of AGA shows little difference in the early and middle stages, but the convergence speed of AGA suddenly accelerates in the later stage. The results verify that the adaptive strategy proposed in this study improves the crossover and mutation rates of the algorithm in the later stages of evolution. This new optimization mode drives individuals to continuously evolve and helps the algorithm eliminate the old model and jump out of the local optimization.

PLOS ONE
The convergence diagram of the six stock indices (Fig 11) shows that the AGA-LSTM model attained good convergence.

Conclusion
The main contribution of this study is the optimization of the LSTM model using an adaptive genetic algorithm. The optimization mechanism based on individual raking can automatically adjust the network structure of the model and slightly tune the combination of hyperparameters, which significantly reduces the frequencies of the hyperparameter adjustment. This study constructs a high-precision model of AGA-LSTM stock price prediction. We performed a quantitative analysis of the six stock indices. The results show that the proposed model performs better than the LSTM alone. The predictive performance of AGA-LSTM is also better than that of GA-LSTM and other machine learning models. The methods used in the model are as follows. Real number coding was performed to find the optimal solution directly in the solution space. The adaptive crossover and mutation probability were adjusted to accelerate the speed of finding the optimal solution and hyperparameter combination. These optimization methods made the model achieve the predominant prediction objectives. In this study,  because the fitness difference of each individual was not obvious, an adaptive algorithm based on individual fitness ranking was proposed to improve the speed of finding the optimal solution. In addition, the convergence efficiency of AGA was higher than that of GA. To obtain better accuracy, there are many directions to explore in the future. For example, using more features of big data, such as the emotional characteristics of investors in the stock market, may improve prediction accuracy. With the further application of deep learning, high-dimensional data mining and time-series prediction, considering the influence of multi-state correlation will also become the next research direction.