Skip to content

Commit 6d88be6

Browse files
committed
距离
1 parent 5a4f44c commit 6d88be6

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

2-Supervised/2.6-SVM.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,48 @@
22

33
支持向量机(Support Vector Machine, SVM)是一种二分类模型,其基本模型是定义在特征空间上的间隔最大的线性分类器,其学习策略便是间隔最大化。SVM 通过间隔最大化,可以使得模型对噪声更加鲁棒,从而提高模型的泛化能力。
44

5+
## 点到平面的距离
6+
7+
在一切开始前,我需要先介绍一下点到(超)平面的距离。
8+
9+
我们定义(超)平面 $H$ 为 $\mathbf{w}^T\mathbf{x}+b=0$。
10+
并定义点 $Q$ $(q_1, q_2, q_3,..., q_N)$ 到平面 $H$ 的距禽为 $\text{dist}(Q, H)$。
11+
12+
我们想要知道怎么计算点 $Q$ 到(超)平面 $H$ 的距离。
13+
14+
取平面任意一点 $P$ $(p_1, p_2, p_3,..., p_N)$,且因为平面上的点满足 $\mathbf{w}^T\mathbf{x}+b=0$,因此有 $\mathbf{w}^T\mathbf{p}+b=0$。
15+
16+
向量 $\overrightarrow{PQ} = \mathbf{q} - \mathbf{p}$,其相对于平面法向量的投影为 $| \overrightarrow{PQ}|\cos \theta$,其中 $\theta$ 为 $\overrightarrow{PQ}$ 和 $\mathbf{w}$ 的夹角。考虑其投影的几何性质,我们可以得到 $\text{dist}(Q, H) = | \overrightarrow{PQ}|\cos \theta$。
17+
18+
令法向量 $\mathbf{n}\perp H: (w_1, w_2, ..., w_n)$,有
19+
20+
21+
22+
$$
23+
\begin{align}
24+
\overrightarrow{PQ}\cdot \mathbf{n} &= |\overrightarrow{PQ}||\mathbf{n}|\cos \theta\\
25+
26+
|\overrightarrow{PQ}|\cos \theta &= \frac{\mathbf{n}}{|\mathbf{n}|} \cdot \overrightarrow{PQ} \\
27+
\end{align}
28+
$$
29+
30+
因此则有:
31+
32+
$$
33+
\begin{align}
34+
\text{dist}(Q, H) &= \frac{\mathbf{n}}{|\mathbf{n}|} \cdot \overrightarrow{PQ} \\
35+
&= \frac{\mathbf{w}}{||\mathbf{w}||} \cdot (\mathbf{q} - \mathbf{p})\\
36+
&= \frac{1}{||\mathbf{w}||} \cdot (\mathbf{w}^T\mathbf{q} - \mathbf{w}^T\mathbf{p})\\
37+
&= \frac{1}{||\mathbf{w}||} \cdot (\mathbf{w}^T\mathbf{q} + b - (\mathbf{w}^T\mathbf{p}+b))\\
38+
\because \quad& \mathbf{w}^T\mathbf{p}+b=0\\
39+
\therefore \quad \text{dist}(Q, H) &= \frac{1}{||\mathbf{w}||} \cdot (\mathbf{w}^T\mathbf{q} + b)\\
40+
&= \frac{\mathbf{w}^T\mathbf{q} + b}{||\mathbf{w}||}
41+
42+
\end{align}
43+
44+
$$
45+
46+
547
## 定义间隔(Margin)
648

749
$$
@@ -270,5 +312,10 @@ s.t.\quad
270312
\end{align}
271313
$$
272314

315+
## 软间隔 Soft Margin
316+
317+
## SMO 算法
318+
319+
## 核函数 Kernel Function
320+
273321

274-
## SMO 算法

0 commit comments

Comments
 (0)