# The Stock Index Prediction Based on SVR Model with Bat Optimization Algorithm
## 3 Materials and Methods
### The Proposed Improved SVR Model  
Support Vector Machine (SVM) models have been widely used and developed in academic circles since they were proposed. Depending on the data structure, SVM models can be divided into SVR models for regression and SVC models for classification. Compared with other learning methods, SVM is based on structural risk minimization, so it has strong generalization ability, and the local optimal point is the global optimal solution. The basic principles are shown below.  
Given an \(n\)-dimensional data set \(\{(x_{1},y_{1}),(x_{2},y_{2}),\ldots,(x_{i},y_{i}),\ldots,t(x_{n},y_{1n})\mid x _{i}\in R^{n}\), \(y\in R,i=1,2,\ldots,n\}\), the regression function of the output space to the input space is \(f(x)=\omega\cdot\phi(x)+\alpha,x\in R^{n},\alpha\in R\), where \(\omega\) is the weight and \(\alpha\) is the threshold.  
The objective of the SVR is to find \(f(x)\) such that the error between the true value and the predicted value is less than or equal to a given error \(\epsilon\). The problem is then transformed into a conditional constrained optimization problem and expressed as:  
\[\begin{split}&\min\frac{1}{2}\|\omega\|^{2}+C\cdot\sum_{i=1}^{n}( \xi_{i}+\xi_{i}^{*})\\ &\text{s.t. }\left\{\begin{array}{l}y-f(x_{i})\leq\epsilon+\xi_{i}, \xi_{i}\geq 0\\ y-f(x_{i})\geq\epsilon+\xi_{i}^{*},\xi_{i}^{*}\geq 0\end{array}\right.\end{split} \tag{6}\]  
In Equation (6), the parameter \(C\) is a penalty factor, which indicates the complexity of the model and the accuracy of sample fitting. The parameter \(\epsilon\) is the insensitive loss coefficient and are slack variables, which are meaningful only for outliers. Consideringthe introduction of Lagrangian operators \(\beta_{i}\) and \(\beta_{i}^{*}\), the pairwise problem of Equation (6) is  
\[\begin{split}&\max-\frac{1}{2}\sum_{i,j=1}^{n} \left(\beta_{i}-\beta_{i}^{*}\right)\left(\beta_{j}-\beta_{j}^{*}\right)K\big{(} x_{i},y_{j}\big{)}-\epsilon\sum_{i=1}^{i=1}(\beta_{i}+\beta_{i}^{*})+\sum_{l}^{i=1 }y_{i}(\alpha_{i}-\alpha_{i}^{*})\\ &\text{s.t. }\left\{\begin{array}{l}\sum_{j=1}^{m}\left(\beta_{i}- \beta_{i}^{*}\right)=0\\ C\geq\beta_{i}\geq 0,C\geq\beta_{i}^{*}\geq 0\end{array}\right.\end{split} \tag{7}\]  
In Equation (7), the kernel function \(K(x_{i},y_{i})\) can make the function of the low-dimensional input space equal to the inner product of the high-dimensional space to achieve the dimensionality reduction effect. Generally speaking, it is divided into linear kernel functions, polynomial kernel functions and Gaussian kernel functions. For SVR can achieve high accuracy of nonlinear prediction by selecting the kernel function, this paper constructs SVR based on the Gaussian Radial Basis Function (RBF), and its formula is expressed as  
\[K\big{(}x_{i},x_{j}\big{)}=\exp\Bigl{(}-x_{i}-x_{j}^{2}/\sigma^{2}\Bigr{)} \tag{8}\]  
where \(\sigma\) is the width parameter of the Gaussian radial basis kernel function, which controls the range of radial action. Therefore, the regression model is  
\[f(x)=\sum_{l}^{i=1}(\beta_{i}-\beta_{i}^{*})K\big{(}x_{i},x_{j}\big{)}+a \tag{9}\]