近来,了解了一下SVM(支持向量机 support vector machine)的原理。顺便把自己理解的内容整理一下。

不讲背景啦,直接切入主题。

    一、什么是支持向量机

好比说,我们现在在一个平面上有许多的圈圈和叉叉,如图1.1所示。

图1.1 

现在需要一条直线将圈圈和叉叉分开,可以想象,会有很多条可能的直线,但是会有一条最佳的分割线L,如图1.2所示。

图1.2 

绿色的叉叉到L的最短距离为d1,红色圈圈到L的最短距离为d2,保证d1=d2,并且使d1+d2的值最大,那么这条直线就是最佳的分割线。具体的表示如图1.3所示

图1.3

图1.3中,蓝色的虚线分别为H1和H2,每一个圈圈和叉叉都可以看成一个向量,落在蓝色虚线上的叉叉和圈圈就称为“支持向量”,那么没有在边缘上的向量就是“非支持向量”。

另外,在SVM中,我们经常听到“超平面”的概念。什么是超平面呢?当图中的圈圈和叉叉是二维的时候,那么L就是一条直线;当图中的圈圈和叉叉是三维的时候,那么L就是一个平面;当图中圈圈和叉叉是三维以上的时候,那么L就是一个超平面。

图中的每个圈圈和叉叉都是一个样本,圈圈和叉叉的维数表示样本的特征数量。

二、怎么用数学描述超平面

如图2.1所示,设超平面L的法向量为$\overset{\scriptscriptstyle\rightharpoonup}{w}$ ,某一样本向量为$\overset{\scriptscriptstyle\rightharpoonup}{u}$,则$\overset{\scriptscriptstyle\rightharpoonup}{u}$在$\overset{\scriptscriptstyle\rightharpoonup}{w}$上的投影为$\frac{\overset{\scriptscriptstyle\rightharpoonup}{u}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}}{||\overset{\scriptscriptstyle\rightharpoonup}{w}||}$。

对于所有的圈圈样本(正样本),有:

$\frac{{{{\overset{\scriptscriptstyle\rightharpoonup}{x}}}_{+}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}}{||\overset{\scriptscriptstyle\rightharpoonup}{w}||}>c$,其中${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{+}}$为正样本向量

对于所有的叉叉样本(负样本),有:

$\frac{{{{\overset{\scriptscriptstyle\rightharpoonup}{x}}}_{-}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}}{||\overset{\scriptscriptstyle\rightharpoonup}{w}||}<c$,其中${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{-}}$为负样本向量

图2.1

令$b=-c||\overset{\scriptscriptstyle\rightharpoonup}{w}||$ ,可得:

${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{+}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b>0$    ,           ${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{-}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b<0$        ①

因为$\overset{\scriptscriptstyle\rightharpoonup}{w}$和$b$都是未知量,同时缩放$\overset{\scriptscriptstyle\rightharpoonup}{w}$和$b$对结果无影响,不妨令:

${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{+}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b\ge 1$   ,          ${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{-}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b\le 1$        ②

令${{y}_{i}}$ 表示第i个样本的分类结果。

对于负样本,令${{y}_{i}}=-1$,对于正样本,令${{y}_{i}}=+1$,结合②中的不等式,可以得到:

${{y}_{i}}({{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{i}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b)-1\ge 0,\forall i$

好了,目前推到了那么多公式,我们来总结一下,如图2.2所示,

在平面L上的点x满足:${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{{}}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b=0$

在平面H1上的点x满足:${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{{}}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b=1$

在平面H2上的点x满足:${{\overset{\scriptscriptstyle\rightharpoonup}{x}}_{{}}}\centerdot \overset{\scriptscriptstyle\rightharpoonup}{w}+b=-1$

图2.2

至此,我们了解了什么是支持向量机,并且完成对超平面的数学描述,下面就是怎样找到这样的一个超平面的问题啦,请见下一篇博文:SVM入门(二)。

SVM入门(一)的更多相关文章

  1. 【转】SVM入门(一)SVM的八股简介

    (一)SVM的八股简介 支持向量机(Support Vector Machine)是Cortes和Vapnik于1995年首先提出的,它在解决小样本.非线性及高维模式识别中表现出许多特有的优势,并能够 ...

  2. 支持向量机(SVM)入门

    一.简介 支持向量机,一种监督学习方法,因其英文名为support vector machine,故一般简称SVM. 通俗来讲,它是一种二类分类模型,其基本模型定义为特征空间上的间隔最大的线性分类器, ...

  3. SVM入门

    前言: 又有很长的一段时间没有更新博客了,距离上次更新已经有两个月的时间了.其中一个很大的原因是,不知道写什么好-_-,最近一段时间看了看关于SVM(Support Vector Machine)的文 ...

  4. SVM入门(十)将SVM用于多类分类

    源地址:http://www.blogjava.net/zhenandaci/archive/2009/03/26/262113.html 从 SVM的那几张图可以看出来,SVM是一种典型的两类分类器 ...

  5. 文本分类学习 (八)SVM 入门之线性分类器

    SVM 和线性分类器是分不开的.因为SVM的核心:高维空间中,在线性可分(如果线性不可分那么就使用核函数转换为更高维从而变的线性可分)的数据集中寻找一个最优的超平面将数据集分隔开来. 所以要理解SVM ...

  6. 文本分类学习 (九)SVM入门之拉格朗日和KKT条件

    上一篇说到SVM需要求出一个最小的||w|| 以得到最大的几何间隔. 求一个最小的||w|| 我们通常使用 来代替||w||,我们去求解 ||w||2 的最小值.然后在这里我们还忽略了一个条件,那就是 ...

  7. SVM入门——线性分类器的求解,核函数

    一.问题的描述 从最一般的定义上说,一个求最小值的问题就是一个优化问题(也叫寻优问题,更文绉绉的叫法是规划——Programming),它同样由两部分组成,目标函数和约束条件,可以用下面的式子表示: ...

  8. 【转】 SVM算法入门

    课程文本分类project SVM算法入门 转自:http://www.blogjava.net/zhenandaci/category/31868.html (一)SVM的简介 支持向量机(Supp ...

  9. SVM算法入门

    转自:http://blog.csdn.net/yangliuy/article/details/7316496SVM入门(一)至(三)Refresh 按:之前的文章重新汇编一下,修改了一些错误和不当 ...

随机推荐

  1. Android线程之Thread 、Runnable 的两个例子

    Thread例子: package fy.test; import android.app.Activity; import android.os.Bundle; import android.os. ...

  2. innodb引擎redo文件维护

    如果要对innodb的redo日志文件的大小与个数进行调整可以采用如下步骤: 1.关闭mysql mysqladmin -h127. -P3306 -uroot -p shutdown 2.修改配置文 ...

  3. matlab取模与取余

    mod函数采用floor,rem函数采用fix函数.那么什么是floor和fix? fix(x):截尾取整.如: >> fix([3.4 , -3.4]) ans = 3 -3 floor ...

  4. 结合实际项目分析pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  5. EasyUI--datebox设置默认时间

    1. html代码: <input id="txtBeginTime" class="easyui-datebox" data-options=" ...

  6. RabbitMQ消息队列(四):分发到多Consumer(Publish/Subscribe)

    上篇文章中,我们把每个Message都是deliver到某个Consumer.在这篇文章中,我们将会将同一个Message deliver到多个Consumer中.这个模式也被成为 "pub ...

  7. CCF 201612-1 中间数

    试题编号:201612-1 试题名称:中间数 时间限制:1.0s 内存限制:256.0MB 问题描述 在一个整数序列a1, a2, -, an中,如果存在某个数,大于它的整数数量等于小于它的整数数量, ...

  8. 用JAVASCRIPT获得当前页的来路地址URL的五种方法

    var rUrl;rUrl = document.referrer; //获得当前页的来路地址URL rUrl = window.parent.location; //获得父窗口的地址URL rUrl ...

  9. Java数据结构整理(一)

    ava数据结构内容整理关键字: 数据结构 Collection:List.SetMap:HashMap.HashTable如何在它们之间选择一.Array , ArraysJava所有“存储及随机访问 ...

  10. 写了一个复杂的sql语句

    $sp_sql = "select sp_ProductNo, sp_ProductName,sp_Standard,sp_Unit,sum(sp_Amount) as amount fro ...