Research on the Prediction Method of Stock Price Based on RBF Neural Network Optimization Algorithm

With the development of social economy, people pay more and more attention to investment and financial management. However, due to the strong volatility of the stock market, it is difficult to accurately predict the future trend of stock and the investment risk is very high. This paper proposes an optimization algorithm based on RBF neural network to predict the stock price. On the basis of RBF neural network, K-means clustering algorithm is introduced to optimize the network parameters, improve the training speed and prediction accuracy of the algorithm, and set corresponding evaluation indexes to evaluate the performance of the algorithm. The method proposed in this paper is applied to the stock prediction of stock market, and the closing price of several stocks in a period of time is predicted. The experimental results show that the method proposed in this paper has better prediction accuracy than other methods, and it is practical in the field of stock prediction.


INTRODUCTION
With the improvement of the national economy, more and more people choose to invest in the stock market. The stock market has become an important part of the financial market and plays an important role in the redistribution of social wealth. Due to the large size of the stock market, investors have different understandings and are easily affected by the national economic policies. The internal law of the stock market is very complex, and the change cycle is disordered. The stock market investment is accompanied by high risk at the same time of high return. In the complex stock market, an effective stock market analysis method is urgently needed by investors to help them make correct investment decisions, reduce investment risk as much as possible and obtain maximum return. Therefore, the research on stock market prediction method has important practical significance in theory and practice [1][2].
Stock prediction refers to the combination of stock market information with other statistical information and the use of scientific methods to judge the status of the stock market.. Traditional statistical methods have great limitations in fault tolerance, learning ability and adaptability. However, the stock market is an extremely complex nonlinear dynamic system due to the influence of various factors such as economy and policy, which has strong complexity and nonlinearity. Moreover, in the stock market, due to a large number of transactions every day, it has to deal with the huge amount of stock predict The traditional statistical methods are not satisfactory in stock prediction. The rapid development of computer technology and artificial intelligence technology has opened up a new path for stock prediction and achieved good results. Among them, the application of neural network to the prediction of the stock market has been widely concerned by scholars at home and abroad. Because of its strong nonlinear approximation ability, self-organization and self-adaptive characteristics, neural network is very suitable for the modeling and control of multivariable nonlinear systems, so it is suitable for stock market prediction. Most of the traditional stock market prediction methods are suitable for medium and long-term stock market trend prediction, but they are not able to predict the changeable short-term stock market trend. Neural network can overcome the shortcomings of traditional prediction methods, and do not need to establish complex nonlinear mathematical model and mapping relationship. The characteristics of stock market movement determine that neural network is more suitable for the prediction of stock market [3][4][5].
This paper first analyzes the challenges of stock price prediction and the feasibility of applying neural network to stock price prediction. Then it introduces the principle and derivation process of RBF neural network algorithm, expounds the principle of K-means algorithm, explains the principle of applying k-means algorithm to RBF neural network parameter optimization, and designs the specific steps of the model for stock price prediction. Based on the RBF neural network model with parameter optimization, this paper predicts the closing prices of three stocks in the same period, and analyzes the prediction effect of training set and test set with evaluation indexes.

The Challenges of Prediction of Stock Price
It has been hundreds of years since the birth of the stock, so far many prediction methods of stock price have emerged. Stock technical index is one of the most commonly used stock price prediction methods. Stock technical index is produced in the early stage of the birth of the stock market. It is usually used to study stock price columns, such as KDJ, RSI, MACD, obv and boll. So far, a large number of stock technical indicators have been found, and in some cases, some stock technical indicators do have certain prediction effect. At present, stock technical index is one of the most commonly used stock price prediction methods. In economics, it is considered that the rise and fall of stock price depends on the relationship between supply and demand. In this relationship, various technical indicators of stock can be calculated based on the data of stock price and trading volume. This prediction method based on the technical index of stock makes the prediction of stock price have a certain theoretical basis. There are thousands of technical indicators calculated by using the basic data such as the highest price, the lowest price, the closing price, the opening price, the trading volume and the adjusted price. According to the technical index of the stock, the prediction and the operation of buying and selling are carried out. However, the effective technical indexes are not enough This method is less, and the method often appears lag and instability in application, so it has great limitations.
In addition, time series model is also used to predict stock prices, such as AR, MA, ARMA, SAR and CAMP. These models can be combined with other methods to predict stock prices. This combination model is better than single model. The technical index method and time series model do realize the prediction of stock price to a certain extent in a period of time, so that people have a basis in predicting the stock price. Today, time series model, technical index method and simple data analysis method are still common methods to solve the problem of stock price prediction. However, with the advancement of economic globalization, the changes in the stock market have become more and more complicated. The complexity of the stock market has significantly increased the chaotic and non-linear characteristics of stock prices. The factors affecting the rise and fall of stock prices have also shown a diversified trend, making stock price prediction face huge challenge.

The Feasibility Analysis of Neural Network Applied in Stock Price Prediction
With the continuous development of computer technology in recent years, machine learning algorithms have been widely used in various fields. Since stock prices fluctuate in real time, if real-time prediction of stock prices can be achieved, the return on stock investment can be improved to a large extent, and the practical value of stock price prediction methods can therefore become higher. With the development of machine learning algorithms becoming more and more mature, applying machine learning algorithms to real-time prediction of stock prices has become one of the research trends in the field of stock price prediction.
When the non-convex problem is transformed into a convex optimization problem, the efficiency of solving the problem can be effectively improved. The objective function defined in the machine learning algorithm is a convex function, which turns the problem solved by the algorithm into a convex optimization problem. Therefore, the machine learning algorithm has a strong ability to handle complex data. The neural network algorithm is the most representative algorithm among machine learning algorithms, so it is very suitable for solving the problem of stock price prediction. The activation function of the hidden layer in the RBF neural network uses a radial basis function, which enables the network to effectively map data in a low-dimensional space to a high-dimensional space, and it is not easy to fall into a local optimal solution. The topology of the network is relatively simple, the amount of training calculation is not large, and the prediction accuracy of nonlinear data is high. Therefore, it can be considered that it is feasible to apply the RBF neural network model to the field of stock price prediction.

Basic Principles of RBF Neural Network
RBF neural network is a single hidden layer neural network. The activation function of the hidden layer adopts radial basis function. The radial basis function maps the data of input layer to the high-dimensional data space of hidden layer. The closer the input signal is to the central range of the basis function, the output of hidden layer will be larger. The activation function of RBF neural network can adopt various types of radial basis function, Gaussian radial basis function is one of the most commonly used activation functions. Once the data point center of radial basis function is determined, the mapping relationship will be determined. The output of the network is the linear weighted sum of the outputs of the neurons in the hidden layer. RBF neural network has the advantages of simple structure design, easy training, fast convergence, can effectively fit any nonlinear function and is not easy to fall into the local optimal solution [6].
In this paper, Gaussian radial basis function is used as the activation function of RBF neural network. If i C and i X are the center point and sample point vector of data respectively, and the number of neurons in the hidden layer of the network is N, then the activation function F is shaped as follows [7].
Gaussian radial basis function f maps m-dimensional data samples into N-dimensional space by taking the data point center i C and extension constant i  as parameters, and obtains the output ˆj Y of the network by the following formula weighted sum.
The loss function of RBF neural network model is The process of network parameter updating is to find the partial derivative of loss function W, C and  to make it equal to 0. The gradient of these three parameters is obtained by multiplying the learning rate  a by the deception of these three variables. W, C and  subtract their respective gradients, and the parameters are updated.
It is found that if the random number is used as the initial value of data point center, expansion constant and network weight in RBF neural network, the prediction accuracy and training speed of the algorithm will be greatly reduced. Therefore, this paper uses K-means clustering algorithm to determine the values of C and  [8].

Optimization of RBF Neural Network by Kmeans Algorithm
The basic idea of K-means clustering algorithm is to divide the sample set into K clusters according to the distance between the sample points in the sample set, so that the distance between the sample points in the cluster is as small as possible, and the distance between clusters is as large as possible. The objective function of K-means algorithm is as follows [9][10].
Where the sample set is divided into K clusters If the shape of Gaussian radial basis function of hidden layer of RBF neural network is shown in formula (1), C i is the center of sample point, i  is the expansion constant, K-means is used to cluster the sample data set to obtain the clustering centers of n clusters, and N central points are taken as the initial data point centers c K of N activation functions of RBF neural network. The minimum distance between each center vector and other center vectors is expanded by i  times to obtain i D , and i D is taken as the value of the extension constant 6I of the corresponding activation function. Therefore, the expansion constant i  can be calculated by using the following formula min , After clustering the data and getting the parameters of the activation function, the output P of the hidden layer of the network is calculated through the C and  obtained by clustering. If the actual value of the network output, which is the dependent variable of the data, is y, then the initial weight value of the RBF neural network can be calculated by using the following formula.
In order to improve the prediction accuracy, the online and offline training methods of the model are integrated. The three parameters are taken as the initial values of the network parameters, and a small batch of gradient descent method is used to update the network parameters.
Therefore, before the experiment, the optimal cluster number of data is determined to make the number of hidden layer neurons of RBF neural network equal to the optimal number of clustering clusters. K-means algorithm is used to cluster the data. The clustering center is taken as the initial data point center of Gaussian radial basis function, and the expansion constant of Gaussian radial basis function is calculated to obtain the initial weight of the network.

Evaluation indexes
Using a variety of evaluation methods to evaluate the prediction effect of the model can make the analysis conclusion more objective and more in line with the actual situation. Therefore, this paper uses the three indicators of mean square error (MSE) and mean absolute error (MAE) to evaluate the prediction effect of the proposed algorithm. The calculation formulas of MSE and MAE are as follows. In the formula, y is the mean value of the normalized closing price sequence. The data of these three evaluation indexes are the prediction results after inverse normalization on training set and test set.
In the experiment, MSE and MAE are used to calculate the error size of the algorithm on the test set, which is helpful to analyze and compare the advantages and disadvantages of the prediction effect of the algorithms.

Parameter Setting
In this paper, the initial data point center and expansion constant of activation function of hidden layer neurons in RBF neural network model are determined by K-means algorithm, and the number of hidden layer neurons is equal to the optimal cluster number. Set the maximum cluster number to 30 and the minimum cluster number to 2. The number of hidden layer neurons of RBF neural network is 8,15,22,10,2,8,2,2. The optimal number of clusters is used to cluster the data to get the clustering center and the expansion constant.
At this time, the topological structure of RBF neural network and the initial data point center and expansion constant of activation function are determined. On this basis, the network initial weights are calculated, and the network parameters are further updated by using small batch gradient descent method; In the experiment, the data of the training set is arranged in disorder, and the last eight samples of the training set are taken as the verification set, and different learning rates are set to predict respectively. The model with the lowest prediction error on the verification set is selected to predict the test set data. The prediction results of the verification set are included in the calculation of the prediction effect evaluation index of the training set.

Prediction Results
The main content of this section is to show the prediction results of RBF neural network optimization algorithm on the closing prices of three stocks, and evaluate the prediction effect of RBF neural network optimization algorithm according to the prediction results and the evaluation index values on the training set and test set. The test set of the predicted stocks is the stock prices from August 20 to August 29, 2018. The unit of stock price is USD. The prediction results are shown in Figure 1.  By observing the prediction results of RBF neural network optimization algorithm on the closing prices of three stocks in the eight trading days after August 20, 2018, it can be seen that the predicted value and the actual value approach in each trading day, and the MSE and MAE values of the algorithm are smal., The RBF neural network optimization algorithm has the smallest prediction error for met stock price, the largest prediction error for TR stock price, and the prediction effect for CCU stock price is between MET and TR. The number of hidden layer neurons of RBF neural network is the optimal cluster number of data, so it is possible that the number of hidden layer neurons is not enough, which leads to the poor fitting effect of the model to the training set data, but the use of fewer neurons in the hidden layer can effectively avoid over fitting and reduce the error on the prediction set. The results show that the algorithm has high prediction accuracy for the closing prices of three stocks.

CONCLUSION
This paper introduces the background and challenges of stock price forecasting, analyzes the feasibility of using neural network to predict stock price, expounds the basic principles of RBF neural network and K-means algorithm, and the method of optimizing RBF neural network by Kmeans algorithm. The optimized RBF neural network is applied to predict the closing prices of several stocks on trading days. The experimental results show that the proposed method has small error and high accuracy.