博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
机器学习基石 之 非线性转换(Nonlinear Transformation)
阅读量:757 次
发布时间:2019-03-23

本文共 5190 字,大约阅读时间需要 17 分钟。

非线性转换(Nonlinear Transformation)

前面讲了许多线性模型,但是假如数据并不是线性可分的,该如何处理呢?基本思路是将数据样本(特征)空间 X \mathcal{X} X 映射 Z \mathcal{Z} Z 空间后,在 Z \mathcal{Z} Z 空间数据是线性可分的话,便可以在 Z \mathcal{Z} Z 空间上使用线性模型对数据分析。

那么该映射叫做非线性特征转换 Φ \Phi Φ((nonlinear) feature transform )实现的是:

x ∈ X ⟼ Φ z ∈ Z \mathbf { x } \in \mathcal { X } {\mathop \longmapsto ^ \mathbf { \Phi }} \mathbf { z } \in \mathcal { Z } xXΦzZ
学习的基本步骤如下:

  • transform original data { ( x n , y n ) } \left\{ \left( \mathbf { x } _ { n } , y _ { n } \right) \right\} {
    (xn,yn)}
    to { ( z n = Φ ( x n ) , y n ) } \left\{ \left( \mathbf { z } _ { n } = \mathbf { \Phi } \left( \mathbf { x } _ { n } \right) , y _ { n } \right) \right\} {
    (zn=Φ(xn),yn)}
  • get a good perceptron w ~ \tilde { \mathbf { w } } w~ using { ( z n = Φ ( x n ) , y n ) } \left\{ \left( \mathbf { z } _ { n } = \mathbf { \Phi } \left( \mathbf { x } _ { n } \right) , y _ { n } \right) \right\} {
    (zn=Φ(xn),yn)}
    and your favorite linear classification algorithm A \mathcal{A} A
  • return g ( x ) = sign ⁡ ( w ~ T Φ ( x ) ) g ( \mathbf { x } ) = \operatorname { sign } \left( \tilde { \mathbf { w } } ^ { T } \mathbf { \Phi } ( \mathbf { x } ) \right) g(x)=sign(w~TΦ(x))

常用的非线性转换 (General Nonlinear Transform)

General Quadratic Hypothesis Set

基本形式为:

Φ 2 ( x ) = ( 1 , x 1 , x 2 , x 1 2 , x 1 x 2 , x 2 2 ) \Phi _ { 2 } ( \mathbf { x } ) = \left( 1 , x _ { 1 } , x _ { 2 } , x _ { 1 } ^ { 2 } , x _ { 1 } x _ { 2 } , x _ { 2 } ^ { 2 } \right) Φ2(x)=(1,x1,x2,x12,x1x2,x22)
其具有的特性是

  • can implement all possible quadratic curve boundaries: circle, ellipse, rotated ellipse, hyperbola, parabola, …
    适用于各种二次曲线边界:圆,椭圆,旋转椭圆,双曲线,抛物线…
  • include lines and constants as degenerate cases
    也包括直线型和常数型

General PolynomialHypothesis Set

基本形式为:

Φ 0 ( x ) = ( 1 ) , Φ 1 ( x ) = ( Φ 0 ( x ) , x 1 , x 2 , … , x d ) Φ 2 ( x ) = ( Φ 1 ( x ) , x 1 2 , x 1 x 2 , … , x d 2 ) Φ 3 ( x ) = ( Φ 2 ( x ) , x 1 3 , x 1 2 x 2 , … , x d 3 ) Φ Q ( x ) = ( Φ Q − 1 ( x ) , x 1 Q , x 1 Q − 1 x 2 , … , x d Q ) \begin{aligned} \Phi _ { 0 } ( \mathbf { x } ) = ( 1 ) , \Phi _ { 1 } ( \mathbf { x } ) & = \left( \Phi _ { 0 } ( \mathbf { x } ) , \quad x _ { 1 } , x _ { 2 } , \ldots , x _ { d } \right) \\ \Phi _ { 2 } ( \mathbf { x } ) & = \left( \Phi _ { 1 } ( \mathbf { x } ) , \quad x _ { 1 } ^ { 2 } , x _ { 1 } x _ { 2 } , \ldots , x _ { d } ^ { 2 } \right) \\ \Phi _ { 3 } ( \mathbf { x } ) & = \left( \Phi _ { 2 } ( \mathbf { x } ) , \quad x _ { 1 } ^ { 3 } , x _ { 1 } ^ { 2 } x _ { 2 } , \ldots , x _ { d } ^ { 3 } \right)\\ \Phi _ { Q } ( \mathbf { x } ) &= \left( \begin{array} { c c } \Phi _ { Q - 1 } ( \mathbf { x } ) , & \left. x _ { 1 } ^ { Q } , x _ { 1 } ^ { Q - 1 } x _ { 2 } , \ldots , x _ { d } ^ { Q } \right) \end{array} \right.\end{aligned} Φ0(x)=(1),Φ1(x)Φ2(x)Φ3(x)ΦQ(x)=(Φ0(x),x1,x2,,xd)=(Φ1(x),x12,x1x2,,xd2)=(Φ2(x),x13,x12x2,,xd3)=(ΦQ1(x),x1Q,x1Q1x2,,xdQ)
那么在经过特征转换后的 hypothesis set 可以表示为
H Φ 0 ⊂ H Φ 1 ⊂ H Φ 2 ⊂ H Φ 3 ⊂ … ⊂ H Φ Q ∥ ∥ ∥ ∥ ∥ H 0 H 1 H 2 H 3 … H Q \begin{array} { c c c c c c c c c } \mathcal { H } _ { \Phi _ { 0 } } & \subset & \mathcal { H } _ { \Phi _ { 1 } } & \subset & \mathcal { H } _ { \Phi _ { 2 } } & \subset & \mathcal { H } _ { \Phi _ { 3 } } & \subset & \ldots & \subset & \mathcal { H } _ { \Phi _ { Q } } \\ \| & & \| & & \| & & \| & & & &\| \\ \mathcal { H } _ { 0 } & & \mathcal { H } _ { 1 } & & \mathcal { H } _ { 2 } & & \mathcal { H } _ { 3 } & & \ldots & & \mathcal { H } _ { Q } \end{array} HΦ0H0HΦ1H1HΦ2H2HΦ3H3HΦQHQ
可以绘制出结构图:

image-20200415224250868.png

所以其结构叫做嵌套(nested) H i \mathcal { H } _ { i } Hi

非线性转换代价(Price)

对于多项式非线性转换来说,求取 g i = argmin ⁡ h ∈ H i E i n ( h ) g _ { i } = \operatorname { argmin } _ { h \in \mathcal { H } _ { i } } E _ { \mathrm { in } } ( h ) gi=argminhHiEin(h),可以获得以下结果:

H 0 ⊂ H 1 ⊂ H 2 ⊂ H 3 ⊂ ⋯ d V C ( H 0 ) ≤ d V C ( H 1 ) ≤ d V C ( H 2 ) ≤ d V C ( H 3 ) ≤ ⋯ E i n ( g 0 ) ≥ E i n ( g 1 ) ≥ E i n ( g 2 ) ≥ E i n ( g 3 ) ≥ ⋯ \begin{array} { c c c c c c c c c} \mathcal { H } _ { 0 } & \subset & \mathcal { H } _ { 1 } & \subset & \mathcal { H } _ { 2 } & \subset & \mathcal { H } _ { 3 } & \subset & \cdots \\ d _ { \mathrm { VC } } \left( \mathcal { H } _ { 0 } \right) & \leq & d _ { \mathrm { VC } } \left( \mathcal { H } _ { 1 } \right) & \leq & d _ { \mathrm { VC } } \left( \mathcal { H } _ { 2 } \right) & \leq & d _ { \mathrm { VC } } \left( \mathcal { H } _ { 3 } \right) & \leq & \cdots \\ E _ { \mathrm { in } } \left( g _ { 0 } \right) & \geq & E _ { \mathrm { in } } \left( g _ { 1 } \right) & \geq & E _ { \mathrm { in } } \left( g _ { 2 } \right) & \geq & E _ { \mathrm { in } } \left( g _ { 3 } \right) & \geq & \cdots \end{array} H0dVC(H0)Ein(g0)H1dVC(H1)Ein(g1)H2dVC(H2)Ein(g2)H3dVC(H3)Ein(g3)

根据之前推导的公式可知: 1 ⏟ W 0 + d ~ ⏟ others   dimensions  = O ( Q d ) \underbrace { 1 } _ { W _ { 0 } } + \underbrace { \tilde { d } } _ { \text {others } } \text { dimensions } = O \left( Q ^ { d } \right) W0 1+others  d~ dimensions =O(Qd),所以 Q Q Q large 意味着 large d v c d_{\mathbf{vc}} dvc。即能力越来越大,复杂度会随之不断增加。

而在分析 VC Dimension 时得出了下面关于 E in E_{\text {in}} Ein E out E_{\text {out}} Eout以及模型复杂度随 d v c d_{\mathbf{vc}} dvc 的变化曲线图:

所以说能力越大,不一定越适用,在实际运用时,线性先行,从最简单的试起。许多情况下线性模型:简单(simple), 有效(efficient), 安全(safe), 且可行(workable)!

转载地址:http://dlqzk.baihongyu.com/

你可能感兴趣的文章