Machine learning algorithms --SVM

table of Contents

Gradient descent method, Lagrange multipliers, the KKT conditions recalled
perceptual model recalled
SVM linearly separable
SVM linearly inseparable
core function
SMO

SVM linearly separable, SVM linearly inseparable, kernel function, will be required to derive

————————————————————————————

 

 

 

 

 

Learning rate (step) can be any number, if it is a second order partial derivatives, it was Newton's method

 

 

 

 Optimization:

  Given a target function, given some of the constraints, it constitutes an optimization model. Iteration must be unconstrained objective function before iteration.

 

 

 

 

 

 

 Examples dual problem : 1, and then selecting the maximum value for the minimum, maximum and then converted to seek for the minimum. . 2, find a conversion opposite to the maximum number of the minimum number for the sake of this number

 

 Three kinds of proof KKT conditions for optimization problems of great benefit to look up, look at this extension

 

 In order not to change the original constraints, only beta]> = 0, because if the beta] is greater than 0, then, g (x) may <0 = not come.

And L is the minimum required, then the objective function, the following things if f (x) are equal to zero, then the minimization of f (x) is the minimum value of L is required. , It is clear that things are not equal to 0 back, since the range, we find a way to prove under what circumstances equal to zero.

Accordingly, to prove a way: βg = 0

  Below, if a start is not considered g (x) <= 0 This constraint, but only the minimum value f (x), find the minimum derivative is equal to zero, we will be able to obtain an optimal solution x *,

  ① If x * is substituted into the constraint g (x) <= 0 (i.e. the FIG are g (x) <= 0 confinement region composed), is just less than zero, then that already in the constraint region, since there is no starting role of the original function f (x) is not behind what is useless? 0 nature is slightly useless, g (x) <0, then β = 0 only slightly

  ②如果x*代入约束条件g(x)<=0后,x*没在约束区域内,它是在区域外(>0)或者在区域边缘(=0)上,大于0不满足咱们的g(x)<=0的约束条件,pass掉,那只能找咱们等于0的时候了,在圆上,那就是g(x*)=0,那完了,g(x)=0了,βg也等于0 了。

  证明完毕。

 

 

 证明方式二:

  如下图,转化为了从最大值里面挑一个最小值的问题。引入了上界的概念,比如cosx,1,2,3,所有1的倍数都是它的上界,但是1是最小的上界。

 

 

 最终目的是求x与β的,求β最大值可不好求啊,无数个啊朋友们,所以这里用到对偶了,先求最小再 求最大值

 

 

 

 最后βg=0.

证明方式三:

  求minf(x),在约束条件g(x)<=0下,加入松弛变量a2,使得g(x)+a2=0,本来是加a的,为了保证它是正的,所以平方了一下。

原函数成了这样:L=f(x)+λ(g(x)+a2);为了不改变原来的约束条件,λ>=0

 

接下来求导就可以了

 

 

可知 

 

 因此,λg=0

三种证明条件的方法完毕。

所有求不等式的条件

 

 感知器模型:

  感知器算法是最古老的分类算法之一,原理比较简单,不过模型的分类泛化能力比较弱,不过感知器模型是SVM、神经网络、深度学习等算法的基础。
感知器的思想很简单:比如班级有很多的同学,分为男同学和女同学,感知器模型就是试图找到一条直线,能够把所有的男同学和女同学分隔开,
如果是高维空间中,感知器模型寻找的就是一个超平面,能够把所有的二元类别分割开。
感知器模型的前提是:数据是线性可分的

 

 

 

 

 

SVM

 SVM硬间隔

前提:所有样本均分类正确

目的:在该前提下,搭建一个(让离超平面比较近的点离超平面尽可能的远(也就是最大化硬间隔))的分类器

 

 

 

 

 

 wtx+b=0是超平面,假设所有样本都分类正确,设xs为距离较近的那些点,那么分类正确的离超平面比较近的点要尽可能的离超平面远。wTxs+b/w的二范数为最近的点到超平面的距离,假设wTxs+b的绝对值为1,得到上式

如果所有样本点都分类正确,那么最近的那些点yiwTxs+b>=0(感知器知识)分对的时候,自然同号。

 

而y是±1,wTxs+b也是±1,所以,yiwTxs+b=1,既然最近的那些点=1,那么其他远的点,就是大于1了.

所以其他的远的点就是yiwTxi+b>=1

 

 

 

 

m个约束条件,引入的超参也就有m个,每个样本都有对应的参数βi

 

 

 求J(w)的最小值,找L和J(w)的关系,这部分是<=0的,所以J(w)是L关于β的最大值(只有关于β,其他都是我们要求的参数),求J(w)最小,再套个min就好。

 

 求最小值,就是求偏导咯

 

算到这里是用β表示w和b,把这两个表达式代入目标函数L中去,此时还有一个未知参数β

 

那么到这一步最小值求完了,外面还套着一层max,接着求max值

来源于,于是把此带进去作为约束条件

 

 该问题通过一系列转化:

 这里要求的未知参数是m个β值,非常麻烦,所以后续会有SMO算法收拾它

 

 

 

 

 

 

 

 

 

 

 SVM软间隔

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 非线性可分SVM模型

 

升维后再内积的话维度实在太多太多。我们设法使一个函数来代替升维后的内积,此类函数即为核函数,共三个参数可调,除了图中框起来的,还有相关的系数可调,如下图

 

 例子:0.8476即为相关的系数,也是第三个可调的参数

 

 

 

 

 

 

 SMO算法

核心原理:迭代与优化原理:θnew=f(θold),用自己,表示自己

             θnewold=Δθ

作用:求下列约束优化问题的最优解β*

等价于

 

 

 分离超平面为g(x)=wTx+b

推导过程太复杂,不再作多阐述,这里给出结果与算法的实现

 

 

SMO不适合大批量数据,参数太多,计算太复杂

 

 SVR算法其实就是线性回归的对偶问题,本质还是线性回归问题罢了

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/qianchaomoon/p/12130129.html