# 3. SVM support vector machine

Time：2020-10-24

Idea: find a curve so that the minimum distance between all sample points and this curve is the maximum

Distance from point x to line:

$$l = \frac{1}{{\left\| w \right\|}}({w^T}x + b)$$

For two categories, Y values are only – 1 and 1, then the same sign indicates that the classification is correct, and the different sign indicates that the classification is wrong. In the perceptual algorithm, there will be more than one such hyperplane to find the best one.

Geometric interval: $\ widehat {{y_ i}} = {y_ i}({w^T}{x_ i} + b)$
Function interval: $\ widehat {{y_ i}} = {y_ i}\frac{1}{{\left\| w \right\|}}({w^T}{x_ i} + b)$
It can be seen that the simultaneous expansion of hyperplanes by W and B is invariant

$$\mathop {\max }\limits_{w,b} \widehat y\& \& {y_i}({w^T}{x_i} + b) \ge \widehat y,i = 1,2,…,m$$

Since the value of $\ \ widehat y$does not affect W, B, therefore, $/ widehat y = 1$, the relaxation variable is introduced

$$\begin{array}{l} \mathop {\min }\limits_{w,b,\xi } \left\| w \right\| + c\sum\limits_{i = 1}^m {{\xi _i}} \\ s.t.{y_i}({w^T}{x_i} + b) \ge 1 – {\xi _i},i = 1,2,…,m \end{array}$$

Then, Lagrange multiplier method is used to transform it into unconstrained problem and SMO is used to solve it.

## Summary of recent use of gin

Recently, a new project is developed by using gin. Some problems are encountered in the process. To sum up, as a note, I hope it can help you. Cross domain problems Middleware: func Cors() gin.HandlerFunc { return func(c *gin.Context) { //Here you can use * or the domain name you specify c.Header(“Access-Control-Allow-Origin”, “*”) //Allow header […]