Renewable energy company stock dynamics forecast in the period of sustainable development based on Fractal-FOA-LSTM

. In stock trend forecasting system, feature selection and model building are two major factors that affect prediction performance. In order to improve the accuracy of prediction and the stability of the model, a stock trend prediction model of Fractal-FOA-LSTM is proposed. Firstly, the features are selected by using the FOA (fruit fly algorithm) combined with the fractal dimension to reduce the redundancy of the features, and the selected indexes are used as the system input. And proposing a double input LSTM(long-short term memory) network prediction model and optimizing its parameters, it can select the best parameters for different data automatically. This paper test on 4 sets of UCI database and Shanghai Composite Index and proved the feature selection method is effective, through the empirical analysis of the Shanghai Composite Index and S&P500, and compared the results with SVM and PNN, verified the feasibility and superiority of the stock trend forecasting system base on fractal-FOA-LSTM.


Introduction
A large number of experimental studies show that the stock market is nonlinear, nonstationary and highly noisy [9,6]. In prediction system, feature selection and model building are two major factors that affect prediction performance. In the study of feature selection, literature [8] proposed the stock prediction model of CFS and fractal feature selection algorithm respectively, which proved the validity of the fractal feature selection, but it was not combined with the fruit fly algorithm in the swarm intelligence algorithm.
In the study of prediction model, literature [12] constructed the PCA-ANN stock price prediction model, but the prediction training speed is slow and easy to fall into the local optimal, and the selection of the number of hidden layer nodes greatly affects the prediction accuracy. The literature [5] combined the Boruta algorithm feature selection with the PSO optimization SVM to classify the return rate, and the literature [4] used SVM combines the feature selection algorithm to predict the stock trend. Deep learning is a new field in the study of machine learning, Chen K and others verify the validity of LSTM in China's stock market prediction [3], and Akita R uses the basic analysis and LSTM model to predict the stock market [2]. The parameter of the prediction models has a great influence on the prediction effect, and the best parameters is different for different input data. The LSTM prediction model involves more parameters, and the choice of parameters has a greater impact on the prediction effect In order to improve the accuracy of stock trend prediction, combined with the above analysis, the fast optimization ability of FOA is combined with fractal dimension, and the parameters of double input LSTM are optimized by the global optimization ability of the FOA, and a prediction model combine the deep learning and fruit fly algorithm is designed. Through the simulation and empirical analysis, proved the prediction system enables to select better feature sets and model parameters for different data. Due to the improvement of feature selection and model construction, the accuracy of prediction has been greatly improved.

The LSTM
The deep learning was put forward by Hinton and others in 2006. It is a new field in machine learning. It uses different training mechanisms from traditional artificial neural networks to overcome the problem of traditional neural network [7,1]. Deep learning has been widely used in various fields and achieved good results [10,14].Recurrent neural network is an effective network for analyzing time series.The LSTM (long and short term memory) network effectively solves the problem of gradient disappearance or gradient explosion of ordinary recurrent neural network. Fig.1 is structure diagram of LSTM, which describes the state of memory cell at time t and the recursive connection at time t-1, t +1.   ) ( hf W is weight matrix from the last hidden status To be updated information t s is determined by the input gate t i ,which is added to the memory cell at time t and output from a fully connected tanh layer according t x and The current state is combining the past memory with new memory, the past memory is the last memory unit status 1  t s and the new memory is the To be updated information t s , the formula is as follows: The output Each layer of neurons of LSTM has three "gates," so that some of the errors can propagate through the "gate" to the next without depending on the current neuron, which makes no matter how far the gradient propagates will not disappear, so the convergence is good.

Feature Selection Based on Fractal Dimension and FOA
The traditional FOA is aimed at the optimization of continuous space, and the flight mode is unrestricted in the optimization process. However, it is not suitable for the optimization of discrete space. Therefore, this paper improve the FOA and combine with fractal dimension for feature selection, which improves the efficiency of feature selection. The following steps are mainly designed: • Flight mode The feature selection is a discrete problem, this paper redefined a flight mode for this problem. Assuming the current position of fruit fly i is , the R is the group radius, and is the maximum distance of a flight, then the position coordinates update to N r x i )% (  , N is the total number of features, % is the remainder of the operation.
• Search stopping condition The number of features to be selected is the upper bound of fractal dimension. Drosophila does not have to reach every feature node in the process of optimization, as long as the number of features to be searched reaches the fractal dimension of the upper bound, that is, the number of features, the search process can be stopped to get a subset of features.
• The fitness The connection between FOA and feature selection is based on the fractal dimension through the fitness function. The fitness function is to evaluate the quality of the subset of features, which determines the next round of fruit flies search. The closer the fractal dimension of feature subset is to the fractal dimension of the original dataset, the better the subsets of features are. So the fitness of this paper is is the fractal dimension of the feature, and the process of searching is to find the minimum value of f .

• Variation operation
In order to prevent the flies from getting into the local optimum in the optimization process, the introduction of mutation operation in this paper. Using non-uniform mutation, according to the mutation probability 0 p to determine whether mutation, the all mutation individual variation of each dimension according the formula is as follows: where t is number of the current iterations, T is the maximum number of iterations, b is the parameters of degree of non-uniformity of variation, which general value is from 2 to 5, the smaller value, the greater the range of variation,this paper takes 2 to make the magnitude of variation larger.
-Step7. According to the mutation probability 0 p to determine whether the variation, nonuniform variation is adopted, and if the fitness of the subset corresponding to the mutation is better, and the subset mutationed is determined as the optimal subset; -Step8. Save the best flavor concentration and corresponding subset encoding, fruit fly flew to this location visually; -Step9. Repeat steps 2-8, when the number of iterations reaches the maximum number of iterations or the optimal slution does not change within a certain number of generations, the process is over.

Improved double-input LSTM model
The Keras is the most convenient Python library for constructing LSTM, which complied with the fully connected layer (Dense layer), active layer, LSTM layer, Dropout layer and optimizer module. The traditional LSTM time series prediction is an input and an output, the method of feature processing will make the model lost some important information during the prediction process. So a two input and one output LSTM prediction model can be constructed, which can input another indicator like price information to prevent information loss. We called this structure as double-input LSTM prediction model, that is to add an additional indicator in the LSTM layer, take the LSTM layer output and the indicator together as the input of the back of the Dense layer , the structure as follows: The parameters of double-input LSTM prediction model include weight regular terms, epoch and batch and so on. Weight regularization is an important method to prevent over fitting, a epoch means that all samples of the training set are involved in a round of training, taking batch as the preface, the size of batch determines the gradient value and the frequency of weight update. These parameter are selected by people. In order to analyze the influence of each parameter on prediction model, take the data from 2005.01.01 to 2010.07.19 of Shanghai composite index to predict the stock trend, take 20 numbers droupout_W and droupout_U increased by 0.02 from 0.02 to 0.4 respectively, take 20 numbers epoch increased by 100 from 100 to 2000, and take 20 numbers batch size increased by 1 from 1 to 20, when take one parameter, the others unchanged, the result of the prediction accuracy under each parameter as shown in Fig.3.  Fig.3. The accuracy of LSTM with each parameter changing As shown in Fig.3, epoch has the greatest impact on the accuracy of stock trend prediction. Droupout_W, droupout_U and batch also have some effect on the prediction accuracy. Therefore, in order to get effective parameters, optimizing the parameters by FOA to get the best parameters, the following steps are designed:

Feature selection analysis
In order to verify the validity of the feature selection algorithm based on fractal dimension and FOA, this paper test on the tree, breast-cancer, waveform and segmentation data sets of UCI. The basic information of the data set and the number of to be selected features are shown in Table1. The features selected by the method of proved feature selection and the classification results are shown in Table2 In Table1, the fractal dimension of each data set is calculated and the number of features to be selected is determined. In Table2, the population size is initialized to Sizepop = 20, the maximum number of iterations is initialized to Maxgen = 50, through the comparison of the results, the dimension of data set after feature selection is greatly reduced, the classification accuracy is only one data set decreased, and the other three are improved, especially the segmentation data set with obvious fractal characteristics, the classification accuracy is greatly improved after the feature selection.
Literature [8] compared different feature selection algorithms for SSCI, and it take the 20 technical indexes of SSCI in 2000 -2008 to select features. On this basis, taking the same data and use the fractal combined with FOA proposed by this paper to predict the stock trend, and the results as shown in Table3. As shown in Table3, the fractal combined with FOA method select index VR, MTM, RSI, MFI, though the number of features is not the least, the classification accuracy is highest. The UCI database analysis and the empirical analysis of SSCI prove the fractal combined with FOA feature selection method is effective.  As shown in Table4, the accuracy of all models using selected features is higher than using all features with each model, and prove the validity of feature selection method with fractal and FOA proposed in this paper. The highest prediction accuracy is this paper method, and it respectively higher than LSTM model 4.09% and 3.71% for SCCI and S&P500, and prove the validity and accuracy of this paper prediction model in stock trend prediction. Although in the SSCI prediction, this paper algorithm is 1.19% higher than the second good SVM combined with the feature selection model, in the S&P500 prediction, this paper algorithm is 1.17% higher than the second better PNN combined with the feature selection model, the slight improvement in prediction performance is also important for the exploration and research of stock trend prediction.

Conclusion
Stock market is a dynamic and nonlinear complex system. There are a lot of research on stock trend forecasting. The features selection and the model construction are the two factors that affect the accuracy of the forecast. There are many parameters involved in the construction of long and short time memory network model. The selection of parameters has a great influence on the accuracy of the prediction, and the optimal parameters for the model are different for the different input data.
Therefore, in order to improve the prediction accuracy and the model stability, this paper combines the fractal dimension and the fruit fly algorithm to select the best features from characteristics technical, and uses the fruit fly algorithm to optimize the parameters of the double-input LSTM model, and the optimal parameters can be selected automatically for different data to get a suitable prediction model. This paper test on 4 sets of UCI database and Shanghai Composite Index proved the feature selection method is effective, through the empirical analysis of the Shanghai Composite Index and S&P500 verified the feasibility of this model, and through the experiments compared with SVM and PNN verified the superiority of fractal-FOA-LSTM model.