• 検索結果がありません。

カーネルサポートベクトルマシン

N/A
N/A
Protected

Academic year: 2021

シェア "カーネルサポートベクトルマシン"

Copied!
42
0
0

読み込み中.... (全文を見る)

全文

(1)

機械学習論 Lec06

カーネルサポートベクトルマシン

(2)

Part1

カーネルを用いた双対表現

(3)

線形モデルとカーネルモデル

特徴ベースモデル:モデルの主表現(Primal Representation)

f (x; w) = w 1 x 1 + w 2 x 2 + . . . + w d x d

事例ベースモデル:モデルの双対表現(Dual Representation)

f (x; α) = α 1 k(x, x 1 ) + α 2 k(x, x 2 ) + . . . + α n k(x, x n )

(4)

双対表現とカーネル関数

事例ベースモデル:モデルの双対表現(Dual Representation)

f (x; α) = α 1 k(x, x 1 ) + α 2 k(x, x 2 ) + . . . + α n k(x, x n )

カーネル関数:2つの事例

x i

x i

の類似度を表す関数

k(x i , x i

)

(5)

カーネル行列とカーネルベクトル

カーネル行列

K R n × n

K =

 

 

k(x 1 , x 1 ) k(x 1 , x 2 ) · · · k(x 1 , x n ) k(x 2 , x 1 ) k(x 2 , x 2 ) · · · k(x 2 , x n )

.. . .. . . . . .. . k(x n , x 1 ) k(x n , x 2 ) · · · k(x n , x n )

 

  R n × n

任意の

x R n

に対するカーネルベクトル

k(x) R n

k(x) =

 

 

k(x, x 1 ) k(x, x 2 )

.. . k(x, x n )

 

  R n

(6)

内積カーネル

最も基本的なカーネル関数:内積カーネル関数

k(x i , x i

) = x i x i

内積カーネルの場合のカーネル行列

K = XX

内積カーネルの場合のカーネルベクトル

k(x) = X x

(7)

リッジ回帰分析の双対表現

リッジ回帰分析

E(w) = 1

2 (y Xw) (y Xw) + λ 2 w w

双対変数

α R n

の導入

α = 1

λ (y X w)

最適性条件

∂E(w)

∂w = 0 ⇔ − X (y Xw) + λw = 0

w = X 1

λ (y X w) = X α

(8)

目的関数の双対表現

リッジ回帰分析の目的関数

E(w) = 1

2 (y Xw) (y Xw) + λ 2 w w

は,双対変数

α

と内積カーネル行列

K

を用いて以下のように表さ れる

E(α) = 1

2 α (KK + λK)α (Ky) α + 1 2 y y

メモ1

(9)

モデルの双対表現

線形モデル

f (x; w) = w 1 x 1 + . . . + w d x d

は,双対変数

α

と内積カーネルベクトル

k(x)

を用いて以下のよ うに表される

f (x; α) = α k(x) = α 1 k(x, x 1 ) + . . . + α n k(x, x n )

メモ2

(10)

カーネルを用いた線形モデルの拡張

カーネル関数を内積カーネルから他のものへ換えることにより線 形モデルを拡張でき,これをカーネル法(

kernel method

)と呼ぶ

他の一般的なカーネルの例

▶ (q次)多項式カーネル

k(x, x ) = (x x + 1) q

▶ ガウシアンカーネル

k(x, x ) = exp (

x x 2 2

2s 2 )

文字列カーネル,グラフカーネルなど,ベクトル表現できない構 造データに対するカーネルも多数あり

(11)

演習問題1

以下のような特徴変換を考える

[ x 1 x 2

] 7→ ϕ

 

 

 

1 2x 1

2x 2

x 2 1 x 2 2

2x 1 x 2

 

 

 

2次の多項式カーネルが以下のように表されることを示せ.

k(x, x ) = (x x + 1) 2 = ϕ(x) ϕ(x )

#

多項式カーネルは特徴空間

ϕ(x)

における内積を表すものと解釈できる

(12)

演習問題1の解答

ϕ(x) ϕ(x ) = 1 + 2x 1 x 1 + 2x 2 x 2 + x 2 1 + x 1 2 + x 2 2 + x 2 2 + 2x 1 x 1 x 2 x 2 .

(1 + x 1 x 1 + x 2 x 2 ) 2 = 1 + 2x 1 x 1 + 2x 2 x 2 + x 2 1 + x 1 2 + x 2 2 + x 2 2 + 2x 1 x 1 x 2 x 2 .

(13)

Part2

カーネル

SVM

(14)

サポートベクトルマシン( SVM

ハードマージン

SVM min

w

0

∈R ,w ∈R

d

w w

s.t. y i (w 0 + w x i ) 1 i ∈ { 1, . . . , n } .

ソフトマージン

SVM min

w

0

∈R ,w ∈R

d

, { ξ

i

∈R}

ni=1

1

2 w w + C

n i=1

ξ i

s.t. y i (w 0 + w x i ) 1 ξ i , ξ i 0 i.

(15)

SVM 問題

SVM

モデル

f (x) = w 0 + w x

SVM

モデルの学習

min

w

0

∈R ,w ∈R

d

, { ξ

i

∈R}

ni=1

1

2 w w + C

n i=1

ξ i

s.t. y i (w 0 + w x i ) 1 ξ i , ξ i 0 i.

(16)

双対 SVM 問題

双対

SVM

モデル

f (x) = α 0 +

n i=1

α i y i x x i

双対

SVM

モデルの学習

min

α ∈R

n

1 2

n i=1

n j=1

α i α j y i y j x i x j

n i=1

α i

s.t.

n i=1

α i y i = 0, 0 α i C, i.

(17)

カーネル SVM

双対

SVM

モデル

f (x) = α 0 +

n i=1

α i y i k(x, x i )

双対

SVM

モデルの学習

min

α ∈R

n

1 2

n i=1

n i

=1

α i α i

y i y i

k(x i , x i

)

n i=1

α i

s.t.

n i=1

α i y i = 0, 0 α i C, i.

(18)

双対変数 α i とマージンの関係

(19)

双対変数 α i とマージンの関係

(20)

双対変数 α i とマージンの関係

(21)

双対変数 α i とマージンの関係

(22)

双対変数 α i とマージンの関係

(23)

双対変数 α i とマージンの関係

(24)

SVM の最適性条件

双対変数

α i

とマージンの関係

マージンの外側

y i f (x i ) > 1 α i = 0

マージン上

y i f (x i ) = 1 0 α i C

マージンの内側

y i f (x i ) < 1 α i = C

サポートベクトルと非サポートベクトル

▶ 双対モデル

f (x) = α 0 +

n i=1

α i y i k(x i , x)

▶ マージンの外側にあるデータは

α i = 0

なので分類境界

f

に 影響を与えない.

SVM

は事例に対するスパース性を持つ(一部の事例のみを 保持しておけばよい)

(25)

(余談)研究紹介

-2 -1 0 1 2

-3 -2 -1 0 1 2

x2

x1

Before safe screening

Toy Data (n = 1000 and d = 2)

(26)

(余談)研究紹介

[

[

Before safe screening

Toy Data (n = 1000 and d = 2)

(27)

(余談)研究紹介

-2 -1 0 1 2

-3 -2 -1 0 1 2

x2

x1

[

[

Before safe screening After safe screening

Toy Data (n = 1000 and d = 2)

(28)

(余談)研究紹介

[

[

[

[

Before safe screening After safe screening

Toy Data (n = 1000 and d = 2)

(29)

(余談)研究紹介

[

[

[

[

Before safe screening After safe screening

Toy Data (n = 1000 and d = 2)

(30)

(余談)研究紹介

[

[

[

[

Before safe screening After safe screening Toy Data (n = 1000 and d = 2)

Optimality is guaranteed even if we remove some samples.

(31)

演習問題2

▶ SVM

はマージン

y i f (x i )

1

より大きい事例は分類境界に影響を 与えない事例スパース性を有している.一方,ロジスティック回帰 分析はそのような性質を有していない.両者の損失関数の違いに 基づいてこのような違いが生じるのか説明せよ.

0 0.5 1 1.5 2 2.5 3 3.5 4

-3 -2 -1 0 1 2 3

los s

Logistic Hinge Loss

Logistic Loss

(32)

演習問題2の解答

(33)

Part2

SVM

の学習(SMOアルゴリズム)

(34)

カーネル SVM の双対問題

y i , y i

もまとめ,以下の行列

Q

を導入する

Q

n × n

:=

 

y 1 y 1 k(x 1 , x 1 ) · · · y 1 y n k(x 1 , x n ) .. . . . . .. . y n y 1 k(x n , x 1 ) · · · y n y n k(x n , x n )

 

▶ SVM

双対最適化問題

α min ∈R

n

1 2

n i=1

n i

=1

α i α i

Q ii

n i=1

α i

s.t.

n i=1

α i y i = 0, 0 α i C, i.

(35)

SMO アルゴリズム

▶ Sequential Minimal Optimization (SMO) Algorithm 1: while optimality conditions are NOT satisfied do 2: for h = 1, . . . , n do

3: update α h with the other variables { α i } i ̸ =h fixed 4: end for

5: end while

▶ LASSO

Shooting

アルゴリズム同様,1変数の最適化を繰り返す

(36)

SVM の1変数の最適化

▶ 1

個の双対変数

α h

に関する最適化問題

min

α

h

∈R

1 2

n i=1

n j=1

α i α j Q ij

n i=1

α i

s.t. 0 α i C, i.

が以下のように整理できる:

min

α

h

∈R

1

2 Q hh α 2 h

1

i ̸ =h

Q hi α i

α h

s.t. 0 α h C.

(37)

演習問題3

▶ SMO

アルゴリズムのステップ3の

α h

の更新式が

α h =

 

C if C < (1

i ̸ =h Q hi α i )/Q hh

0 if 0 > (1

i ̸ =h Q hi α i )/Q hh

(1

i ̸ =h Q hi α i )/Q hh otherwise

と表されることを示せ

.

(38)

演習問題3のヒント

(39)

演習問題3の解答

(40)

まとめ

(41)

まとめ

カーネル化は線形モデルから非線形モデルへ拡張する際の有用

多くの機械学習モデルが主表現と双対表現を持つ

カーネル

SVM

は学習も早く性能もよく,デフォルト的な手法

(42)

本日のまとめ

スパースモデリングとサポートベクトルマシンは「前深層学習時 代」のデフォルト機械学習手法

多くのツールが揃い,学習も早く,性能もそこそこよいので手軽 に試すべきオプション

深層学習と違い凸最適化問題として定式化されるため,最適性の 保証や理論的な理解が容易

参照

関連したドキュメント

The conditions of Theorem 10 are often satisfied in so-called Greechie logics when one takes for a and b atoms lying in different maximal Boolean sub- algebras.. (Greechie logics

The time span from the slot where an initial collision occurs up to and including the slot from which all transmitters recognize that all packets involved in the above initial

We formulate Wolfe-type dual and Mond-Weir- type dual problems for our nonsmooth multiobjective problems and establish duality theorems for weak Pareto-optimal solutions

Zaltus SX, applied as part of a burndown program, may be used for residual weed control, as well as to assist in postemergence burndown of many weeds where field corn will be

• To limit the potential for development of disease resistance to these fungicide classes, do not make more than 2 sequential applications of LUNA EXPERIENCE or any Group 7 or Group

Where a rate range is given, the higher rates should be used (a) in fields with a history of severe weed pressure, (b) when the time between early preplant tank-mix and

To limit the potential for development of disease resistance to these fungicide classes, do not make more than 2 sequential applications of LUNA SENSATION or any

Resistance Management: Do not make more than two (2) sequential applications of EviTO 480 SC Fungicide before alternating to a labeled fungicide with a different mode of action