# SVM - 优化问题的导出

svm的想法其实非常朴素：

• 寻找一个超平面来将所有样本正确分开 (条件1)
• 并且保证超平面到两类样本的边界到超平面的距离和最大且相等 (条件2)

$y(w^Tx+b) > 0 \tag{1}$

$\gamma=|w^Tx_1+b| \tag{2}$

$\frac{\gamma w}{||w||} = x_1 - x_0 \tag{3}$

$\frac{\gamma w^Tw}{||w||} = w^T(x_1 - x_0) + b - b = w^Tx_1 + b - (w^Tx_0 + b) \tag{4}$

$\gamma = \frac{|w^Tx_1+b|}{||w||}$

$\gamma_+ + \gamma_- = \frac{w^T(x_+ - x_-)}{||w||} \tag{5}$

$\begin{cases} \quad w^T(x_+-x_-)=2 \\ \quad w^Tx_+ + b = 1 \\ \quad w^Tx_- + b = -1 \end{cases}$

$\gamma_+ + \gamma_- = \frac{2}{||w||} \tag{6}$

$y(w^Tx+b) \ge 1 \tag{7}$

$\begin{cases} \quad \underset{w,b}{\arg \min} \frac{||w||^2}{2} \\ \quad s.t. \quad y_i(w^Tx_i + b) \ge 1, \quad i = (1, 2, 3, ...m) \end{cases} \tag{8}$

$\underset{w,b}{\arg \min} \frac{||w||^2}{2} + C\sum_{i=1}^m{max(0, 1-y_i(w^Tx_i+b))} \tag{9}$

\begin{aligned} & \underset{w,b,\xi_i}{\arg \min} \frac{||w||^2}{2} + C\sum_{i=0}^m\xi_i \\ s.t. & \begin{cases} y_i(w^Tx_i + b) \ge 1-\xi_i, \quad i = (1, 2, 3...,m) \\ \xi_i \ge 0, \quad i = (i, 2, 3...,m) \end{cases} \end{aligned} \tag{10}