• 数据挖掘:支持向量机SVM数学推导


    Support Vector Machines

    在这里插入图片描述
    在这里插入图片描述

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    SVM数学推导

    max ⁡ w , b 2 ∣ ∣ w ∣ ∣ 2 s . t . : y ( i ) ( w T x ( i ) + b ) ≥ 1 , i = 1 , 2 , … , m \max_{w,b} \frac{2}{||w||_2}\\ s.t. :y^{(i)}(w^Tx^{(i)}+b)\geq 1,i=1,2,…,m w,bmax∣∣w22s.t.:y(i)(wTx(i)+b)1,i=1,2,,m

    优化问题等价于,
    min ⁡ w , b ∣ ∣ w ∣ ∣ 2 2 2 s . t . : y ( i ) ( w T x ( i ) + b ) ≥ 1 , i = 1 , 2 , … , m \min_{w,b} \frac{||w||_2^2}{2}\\ s.t.:y^{(i)}(w^Tx^{(i)}+b)\geq 1,i=1,2,…,m w,bmin2∣∣w22s.t.:y(i)(wTx(i)+b)1,i=1,2,,m
    转化问题形式为:
    J ( w ) = ∣ ∣ w ∣ ∣ 2 2 2 s . t . : 1 − y ( i ) ( w T x ( i ) + b ) ≤ 0 , i = 1 , 2 , … , m J(w) =\frac{||w||_2^2}{2}\\ s.t.:1-y^{(i)}(w^Tx^{(i)}+b)\leq 0,i=1,2,…,m J(w)=2∣∣w22s.t.:1y(i)(wTx(i)+b)0,i=1,2,,m
    使用拉格朗日乘子法,
    L ( w , b , β ) = ∣ ∣ w ∣ ∣ 2 2 2 + ∑ i = 1 m β i [ 1 − y ( i ) ( w T x ( i ) + b ) ] , β i ≥ 0 L(w,b,\beta) =\frac{||w||_2^2}{2}+\sum_{i=1}^m \beta_i [1-y^{(i)}(w^Tx^{(i)}+b)],\beta_i \geq 0 L(w,b,β)=2∣∣w22+i=1mβi[1y(i)(wTx(i)+b)],βi0
    最优解应为 min ⁡ w , b max ⁡ β ≥ 0 L ( w , b , β ) \min_{w,b} \max_{\beta \geq 0} L(w,b,\beta) minw,bmaxβ0L(w,b,β)

    转化为对偶问题 max ⁡ β ≥ 0 min ⁡ w , b L ( w , b , β ) \max_{\beta \geq 0} \min_{w,b} L(w,b,\beta) maxβ0minw,bL(w,b,β)
    ∂ L ∂ w = 0 ⇒ w − ∑ i = 1 m β i y ( i ) x ( i ) = 0 ⇒ w = ∑ i = 1 m β i y ( i ) x ( i ) ∂ L ∂ b = 0 ⇒ − ∑ i = 1 m β i y ( i ) = 0 ⇒ ∑ i = 1 m β i y ( i ) = 0 \frac{\partial L}{\partial w} = 0 \Rightarrow w - \sum_{i=1}^m \beta_i y^{(i)}x^{(i)} = 0 \Rightarrow w =\sum_{i=1}^m \beta_i y^{(i)}x^{(i)}\\ \frac{\partial L}{\partial b} = 0 \Rightarrow -\sum_{i=1}^m \beta_i y^{(i)} = 0 \Rightarrow \sum_{i=1}^m \beta_i y^{(i)} = 0 wL=0wi=1mβiy(i)x(i)=0w=i=1mβiy(i)x(i)bL=0i=1mβiy(i)=0i=1mβiy(i)=0
    现在求解 β \beta β
    L ( β ) = ∣ ∣ w ∣ ∣ 2 2 2 + ∑ i = 1 m β i [ 1 − y ( i ) ( w T x ( i ) + b ) ] = ∣ ∣ w ∣ ∣ 2 2 2 − ∑ i = 1 m β i [ y ( i ) ( w T x ( i ) + b ) − 1 ] = 1 2 w T w − ∑ i = 1 m β i y ( i ) w T x ( i ) − ∑ i = 1 m β i y ( i ) b + ∑ i = 1 m β i = 1 2 w T ∑ i = 1 m β i y ( i ) x ( i ) − w T ∑ i = 1 m β i y ( i ) x ( i ) − b ∑ i = 1 m β i y ( i ) + ∑ i = 1 m β i = − 1 2 w T ∑ i = 1 m β i y ( i ) x ( i ) − b ∑ i = 1 m β i y ( i ) + ∑ i = 1 m β i = − 1 2 ( ∑ i = 1 m β i y ( i ) x ( i ) ) T ∑ i = 1 m β i y ( i ) x ( i )   + ∑ i = 1 m β i = − 1 2 ( ∑ i = 1 m β i y ( i ) x ( i ) T ) ∑ i = 1 m β i y ( i ) x ( i )   + ∑ i = 1 m β i = ∑ i = 1 m β i − 1 2 ∑ i = 1 m ∑ j = 1 m β i β j y ( i ) y ( j ) x ( i ) x ( j ) L(\beta) =\frac{||w||_2^2}{2}+\sum_{i=1}^m \beta_i [1-y^{(i)}(w^Tx^{(i)}+b)]\\ = \frac{||w||_2^2}{2}-\sum_{i=1}^m \beta_i [y^{(i)}(w^Tx^{(i)}+b)-1]\\ = \frac{1}{2}w^Tw - \sum_{i=1}^m \beta_i y^{(i)}w^Tx^{(i)} - \sum_{i=1}^m \beta_i y^{(i)}b + \sum_{i=1}^m \beta_i\\ = \frac{1}{2}w^T\sum_{i=1}^m \beta_i y^{(i)}x^{(i)} - w^T\sum_{i=1}^m \beta_i y^{(i)}x^{(i)} - b\sum_{i=1}^m \beta_i y^{(i)} + \sum_{i=1}^m \beta_i\\ = -\frac{1}{2}w^T\sum_{i=1}^m \beta_i y^{(i)}x^{(i)} - b\sum_{i=1}^m \beta_i y^{(i)} + \sum_{i=1}^m \beta_i\\ = -\frac{1}{2}{(\sum_{i=1}^m \beta_i y^{(i)}x^{(i)})} ^T \sum_{i=1}^m \beta_i y^{(i)}x^{(i)}\ + \sum_{i=1}^m \beta_i\\ = -\frac{1}{2}{(\sum_{i=1}^m \beta_i y^{(i)}x^{(i)T})} \sum_{i=1}^m \beta_i y^{(i)}x^{(i)}\ + \sum_{i=1}^m \beta_i\\ = \sum_{i=1}^m \beta_i- \frac{1}{2}{\sum_{i=1}^m \sum_{j=1}^m \beta_i \beta_j y^{(i)}y^{(j)}x^{(i)}x^{(j)}} L(β)=2∣∣w22+i=1mβi[1y(i)(wTx(i)+b)]=2∣∣w22i=1mβi[y(i)(wTx(i)+b)1]=21wTwi=1mβiy(i)wTx(i)i=1mβiy(i)b+i=1mβi=21wTi=1mβiy(i)x(i)wTi=1mβiy(i)x(i)bi=1mβiy(i)+i=1mβi=21wTi=1mβiy(i)x(i)bi=1mβiy(i)+i=1mβi=21(i=1mβiy(i)x(i))Ti=1mβiy(i)x(i) +i=1mβi=21(i=1mβiy(i)x(i)T)i=1mβiy(i)x(i) +i=1mβi=i=1mβi21i=1mj=1mβiβjy(i)y(j)x(i)x(j)
    To solve β value, we need an Sequential Minimal Optimization algorithm.

    Paper: Sequential Minimal Optimization A Fast Algorithm for Training Support Vector Machines

    如何求 w ∗ : w ∗ = ∑ i = 1 m β i ∗ y ( i ) x ( i ) w^*:w^* = \sum_{i=1}^m \beta_i^* y^{(i)}x^{(i)} w:w=i=1mβiy(i)x(i)

    如何求 b ∗ b^* b
    y s ( w T x s + b ) = y s ( ∑ i = 1 β i s y ( i ) x ( i ) T x s + b ) = 1 ⇒ b ∗ = y s − ∑ i = 1 m β i ∗ y ( i ) x ( i ) T x s y^s(w^Tx^s+b) = y^s(\sum_{i=1}\beta_i^s y^{(i)}x^{(i)T}x^s+b) = 1\Rightarrow b^* = y^s - \sum_{i=1}^m \beta_i^* y^{(i)}x^{(i)T}x^s ys(wTxs+b)=ys(i=1βisy(i)x(i)Txs+b)=1b=ysi=1mβiy(i)x(i)Txs
    y s , x s y^s,x^s ys,xs是已知的样本点

    非线性分类—核函数

    Polynomial (homogeneous): k ( x , x ′ ) = ( x ⋅ x ′ ) k(x,x') = (x·x') k(x,x)=(xx)

    Polynomial (inhomogeneous): k ( x , x ′ ) = ( x ⋅ x ′ + 1 ) k(x,x') = (x·x'+1) k(x,x)=(xx+1)

    Radial basis function: k ( x , x ′ ) = e x p ( − γ ∣ ∣ x − x ′ ∣ ∣ 2 ) , γ > 0 k(x,x') = exp(-\gamma ||x-x'||^2), \gamma >0 k(x,x)=exp(γ∣∣xx2),γ>0

    Gaussian radial basis function: k ( x , x ′ ) = e x p ( − ∣ ∣ x − x ′ ∣ ∣ 2 2 σ 2 ) k(x,x') = exp(-\frac{||x-x'||^2}{2\sigma^2}) k(x,x)=exp(2σ2∣∣xx2)

    Sigmoid: k ( x , x ′ ) = tan ⁡ h ( k x ⋅ x ′ + c ) , k > 0 a n d c < 0 k(x,x') = \tan h(kx·x'+c),k>0 \quad and\quad c<0 k(x,x)=tanh(kxx+c),k>0andc<0

  • 相关阅读:
    通过 SingleFlight 模式学习 Go 并发编程
    局域网内其他主机无法ip访问我的django网页
    迅为3A5000_7A2000开发板龙芯国产处理器LoongArch架构
    线程是如何在 6 种状态之间转换的?
    PowerBuilder用ODBC方式连接数据库时,不用注册数据源
    关于python中正则表达式的一些笔记
    UVM实战——01基本概念_2 什么是UVM?
    jmeter性能测试,各个指标的预估/测试出来/计算出来,各种关系
    七周成为数据分析师 | 数据库
    计算机毕业设计SSM毕业设计管理系统【附源码数据库】
  • 原文地址:https://blog.csdn.net/weixin_46530492/article/details/126367261