# Wheat Quantity Monitoring Methods Based on Inventory Measurement and SVR Prediction Model
## 3 Principle of SVR Prediction Model  
### Principle of Algorithm Design  
The SVR prediction model is an SVM based on the introduction of the insensitive loss error function \(\varepsilon\). By finding an optimal classification surface, the error of all training samples from the optimal classification surface is minimized to solve the regression fitting problem of the SVM [33; 34]. The principle of the SVR prediction model is as follows:  
Assume that the given sample is \(\{\left(x_{1},y_{i}\right)\), \(i=1,2,\ldots,m\}\), \(x_{i}\in R^{n}\), \(y_{i}\in R^{n}\), where \(m\) is the number of samples and \(n\) is the sample dimension. Correspondingly, the regression function constructed in the high-dimensional feature space is as follows:  
\[f(x)=w\Phi(x)+b \tag{9}\]  
where \(\Phi(x)\) is the nonlinear mapping function from \(R^{n}\) to the higher dimensional eigenspace; \(w\) is the weight vector of the hyperplane; and \(b\) indicates bias. By definition, the linear insensitive loss error function \(\varepsilon\) is as follows:  
\[L(f(x),y,\varepsilon)=\left\{ \begin{aligned} & 0,\quad\quad\quad\quad \quad\quad|y-f(x)|\leq\varepsilon\\ &|y-f(x)|-\varepsilon,\ |y-f(x)|>\varepsilon\end{aligned} \right. \tag{10}\]  
where \(f(x)\) is the predicted value returned by the regression function, and \(y\) is the corresponding true value. If the difference between \(f(x)\) and \(y\) is less than or equal to \(\varepsilon\), the loss is judged to be 0. According to the principle of structural risk minimization [8] and the introduction of relaxation variables \(\xi_{i}\) and \(\xi_{i}^{*}\), the problem of seeking \(w\) and \(b\) is transformed into the problem of solving minimum values under constraints, and the mathematical description equation set is established as follows:  
\[\left\{ \begin{aligned} &\min\left[\frac{1}{2}\|w\|^{2}+C\Sigma_{i=1}^{m} \left(\xi_{i}+\xi_{i}^{*}\right)\right]\\ &\text{s.t.}\left\{\begin{aligned} y_{i}-\left[w\Phi(x_{ i})+b\right]\leq\varepsilon+\xi_{i}\\ \left[w\Phi(x_{i})+b\right]-y_{i}\leq\varepsilon+\xi_{i}^{*}\\ \xi_{i}\,\ \xi_{i}^{*}\ \geq 0,i=1,2,\ldots,m\end{aligned}\right.\end{aligned} \right. \tag{11}\]  
where \(C\) is the error penalty factor. The larger the value of \(C\), the larger the penalty on samples with training errors larger than \(\varepsilon\), which limits the error requirement of the regression function. A smaller value of \(C\) implies a smaller error of the regression function. In order to solve Formula (11), the Lagrange Function is introduced and transformed into a solution problem in its dual form, which is as follows:  
\[\left\{\begin{aligned} &\max\left\{-\frac{1}{2}\sum_{i=1}^{m}\sum_{j=1}^{m} \left(a_{i}-a_{i}^{*}\right)\left(a_{j}-a_{j}^{*}\right)K\left(x_{i},x_{j} \right)-\varepsilon\sum_{i=1}^{m}\left(a_{i}+a_{i}^{*}\right)+\sum_{i=1}^{m}y_ {i}\left(a_{i}-a_{i}^{*}\right)\right\}\\ &\text{s.t. }\left\{ \begin{aligned} &\sum_{i=1}^{m}\left(a_{i}-a_{i}^{*}\right) =0\\ & 0\leq a_{i}\leq C\\ & 0\leq a_{i}^{*}\leq C\end{aligned} \right. \tag{12}\]  
\[K\left(x_{i},x_{j}\right)=\Phi(x_{i})\Phi\left(x_{j}\right) \tag{13}\]  
where, \(a_{i}\), \(a_{i}^{*}\), \(a_{j}\), and \(a_{j}^{*}\) are Lagrange multipliers, and \(K\left(x_{i},x_{j}\right)\) is the kernel function. Since Formula (12) is a complex function optimization problem with linear constraints, its solution has global optimality and uniqueness. Suppose that the optimal solution obtained from Formula (12) is \(a=\left[a_{1},a_{2},\ldots,a_{m}\right]\), \(a^{*}=\left[a_{1}^{*},a_{2}^{*},\ldots,a_{m}^{*}\right]\); the solutions \(w^{*}\) and \(b^{*}\) can be obtained as follows:  
\[w^{*}=\sum_{i=1}^{m}(a_{i}-a_{i}^{*})\Phi(x_{i}) \tag{14}\]\[b^{*}=\frac{1}{N_{nsv}}\bigg{\{}\sum_{0<a_{i}<C}\Big{[}y_{i}-\sum_{x_{i}\in SV} \big{(}a_{i}-a_{i}^{*}\big{)}K\big{(}x_{i},x_{j}\big{)}-\varepsilon\Big{]}+\sum_ {0<a_{i}<C}\bigg{[}y_{i}-\sum_{x_{j}\in SV}\Big{(}a_{j}-a_{j}^{*}\Big{)}K\big{(} x_{i},x_{j}\big{)}+\varepsilon\bigg{]}\bigg{\}} \tag{15}\]  
where \(N_{nsv}\) is the number of SVM.