26
統計数理 講義ノート:ガイダンス・確率の復習 担当:金森 敬文 (e-mail: [email protected]) http://www.kana-lab.c.titech.ac.jp/ (日本語ページに講義情報を掲載) 講義資料・成績評価 * 講義中にレポート課題を出題する.講義 4,5 回に 1 回程度の頻度の予定. * 成績:レポートの結果を総合して評価する. 講義の予定:講義の順番をシラバスから変更します.講義サイトを参照のこと. * 確率論の復習,確率不等式 * 機械学習の基礎: 問題設定:損失,最適な判別器,モデル選択 * 回帰分析:最小 2 乗法,正則化,交差検証法,カーネル回帰分析 * カーネル法 正定値カーネルによる学習,再生核ヒルベルト空間 スプライン平滑化とカーネル法 * 判別 統計的学習:PAC 学習,No-Free Lunch 定理, VC 次元,Rademacher 複雑度,代替損失. サポートベクトルマシン 1/26

統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

統計数理 講義ノート:ガイダンス・確率の復習

• 担当:金森 敬文 (e-mail: [email protected])

http://www.kana-lab.c.titech.ac.jp/

(日本語ページに講義情報を掲載)

• 講義資料・成績評価∗ 講義中にレポート課題を出題する.講義4,5回に1回程度の頻度の予定.∗ 成績:レポートの結果を総合して評価する.

• 講義の予定:講義の順番をシラバスから変更します.講義サイトを参照のこと.∗ 確率論の復習,確率不等式∗ 機械学習の基礎: 問題設定:損失,最適な判別器,モデル選択∗ 回帰分析:最小2乗法,正則化,交差検証法,カーネル回帰分析∗ カーネル法・ 正定値カーネルによる学習,再生核ヒルベルト空間・ スプライン平滑化とカーネル法

∗ 判別・ 統計的学習:PAC学習,No-Free Lunch 定理, VC次元,Rademacher複雑度,代替損失.・ サポートベクトルマシン

1/26

Page 2: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• 参考文献 (論文はgoogleなどでタイトルを検索すればpdfを入手可)

∗ 講義全般:・ [書籍] Shai Shalev-Shwartz, et al., Understanding Machine Learning: From Theory to Algorithms,

Cambridge University Press, 2014. (ウェブからDL可能)

・ [サーベイ論文] O. Bousquet, S. Boucheron, G. Lugosi, “Introduction to Statistical Learning

Theory”, 2004.

・ [書籍] Mohri, et al., Foundations of Machine Learning, MIT Press, 2012.∗ カーネル法の書籍・ 赤穂昭太郎,カーネル多変量解析,岩波書店・ 福水健次,カーネル法入門,朝倉書店

2/26

Page 3: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• その他,参考になりそうな文献

∗ カーネル法:サポートベクターマシンなど・ [サーベイ論文] T. Hofmann, B. Scholkopf, A. J. Smola, Kernel Methods in Machine Learning,

The Annals of Statistics, vol. 36, no. 3, pp. 1171–1220, 2008.

・ [書籍] B. Scholkopf, A. J. Smola, Learning with Kernels: Support Vector Machines, Regularization,

Optimization, and Beyond (Adaptive Computation and Machine Learning), The MIT Press, 1st

edition, 2001.

・ [書籍]

· 金森,統計的学習理論 (機械学習プロフェッショナルシリーズ),講談社,2015.· 金森,鈴木,竹内,佐藤,機械学習のための連続最適化 (機械学習プロフェッショナルシリーズ),講談社,2016.

3/26

Page 4: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

— 機械学習の枠組—

4/26

Page 5: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

観測されたデータ =⇒ 有用な情報を取り出す

• 講義では主に回帰分析・判別分析を扱う:データ (x1, y1), . . . , (xn, yn) から x と y の間の関係を推定する.

• その他の問題設定

∗ 次元削減:高次元データを,情報量を保ちつつ低次元に圧縮.∗ クラスタリング:データをいくつかのグループに分ける.

5/26

Page 6: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

統計的データ解析と確率論

• 観測データは複雑 (ノイズの影響など)

• 確率的なモデリングが有効

モデリング = [確定した構造] + [ランダムな構造]

• 確率論を基礎にして,データを解析する

∗ ただし本講義では,厳密な測度論的な取り扱いはしない

6/26

Page 7: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

問題設定x を入力すると y が出力される:

例: x −→ ?? −→ y

• データ (x1, y1), . . . , (xn, yn) が観測されている.

• 新たな入力 x に対する出力 y を予測

判別 (classification): y が有限集合に値をとる.

回帰 (regression): y は実数値をとる.

7/26

Page 8: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

4 2 0 2 4

42

02

4

C=1

X1

X2

• 2値判別

∗ xi ∈ Rd, yi ∈ +1,−1∗ データから+1 と −1 の境界を推定.∗ 境界にもとづいて,新たな入力 x に対する y の値を予測

8/26

Page 9: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

— 機械学習の応用例 —

9/26

Page 10: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

機械学習:データからパターンを発見,将来の予測などに役立てる.

例:文字認識,画像認識,音声認識など.

• スパム(spam:迷惑メール)フィルター

∗ x:メール(テキストデータ),y ∈ spam, non-spam

∗ サンプル:沢山の(過去の)スパムメールと普通のメール

∗ 将来のメールがスパムメールかどうかを判定して,仕分けする

10/26

Page 11: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• 文字認識:画像から文字を識別する.例:x ∈ R64, y ∈ 0, 1, 2, . . . , 9.

2 4 6 8

24

68

→ 0,

2 4 6 8

24

68

→ 3,

2 4 6 8

24

68

→ 7 or 9?

郵便番号の読み取りなどに実用化されている.

• 顔検出:顔がある位置を検出.デジカメなどに搭載.

148 Viola and Jones

5. Results

This section describes the final face detection system.The discussion includes details on the structure andtraining of the cascaded detector as well as results ona large real-world testing set.

5.1. Training Dataset

The face training set consisted of 4916 hand labeledfaces scaled and aligned to a base resolution of 24 by24 pixels. The faces were extracted from images down-loaded during a random crawl of the World Wide Web.Some typical face examples are shown in Fig. 8. Thetraining faces are only roughly aligned. This was doneby having a person place a bounding box around eachface just above the eyebrows and about half-way be-tween the mouth and the chin. This bounding box wasthen enlarged by 50% and then cropped and scaled to24 by 24 pixels. No further alignment was done (i.e.the eyes are not aligned). Notice that these examplescontain more of the head than the examples used by

Figure 8. Example of frontal upright face images used for training.

Rowley et al. (1998) or Sung and Poggio (1998). Ini-tial experiments also used 16 by 16 pixel training im-ages in which the faces were more tightly cropped,but got slightly worse results. Presumably the 24 by24 examples include extra visual information such asthe contours of the chin and cheeks and the hair linewhich help to improve accuracy. Because of the natureof the features used, the larger sized sub-windows donot slow performance. In fact, the additional informa-tion contained in the larger sub-windows can be usedto reject non-faces earlier in the detection cascade.

5.2. Structure of the Detector Cascade

The final detector is a 38 layer cascade of classifierswhich included a total of 6060 features.

The first classifier in the cascade is constructed us-ing two features and rejects about 50% of non-faceswhile correctly detecting close to 100% of faces. Thenext classifier has ten features and rejects 80% of non-faces while detecting almost 100% of faces. The nexttwo layers are 25-feature classifiers followed by three50-feature classifiers followed by classifiers with a

152 Viola and Jones

Figure 10. Output of our face detector on a number of test images from the MIT + CMU test set.

6. Conclusions

We have presented an approach for face detectionwhich minimizes computation time while achievinghigh detection accuracy. The approach was used to con-struct a face detection system which is approximately15 times faster than any previous approach. Preliminaryexperiments, which will be described elsewhere, showthat highly efficient detectors for other objects, such aspedestrians or automobiles, can also be constructed inthis way.

This paper brings together new algorithms, represen-tations, and insights which are quite generic and maywell have broader application in computer vision andimage processing.

The first contribution is a new a technique for com-puting a rich set of image features using the integralimage. In order to achieve true scale invariance, almostall face detection systems must operate on multipleimage scales. The integral image, by eliminating theneed to compute a multi-scale image pyramid, reducesthe initial image processing required for face detection

学習データ(正例) 検出結果P. Viola & M. J. Jones, Robust Real-Time Face Detection Journal International Journal of Computer Vision, 2004

11/26

Page 12: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

— 確率論の復習 —

12/26

Page 13: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• 確率変数 (r.v.):ランダムな値をとる変数 X(通常は大文字で書く)• 標本空間 Ω に値をとる確率変数 X に関する確率 Pr( · ) の定義:

1. 事象 A ⊂ Ω に対して 0 ≤ Pr(X ∈ A) ≤ 1.2. 全事象 Ω の確率は 1.Pr(X ∈ Ω) = 1

3. 互いに排反な事象 Ai, i = 1, 2, 3, . . .

に対して

Pr(X ∈ ∪iAi) =∑i

Pr(X ∈ Ai).

(互いに排反: i = j に対して Ai ∩ Aj = ϕ)

Ω

A1 A2

( 簡単のため Pr(X ∈ A) を Pr(A), P (A) と表すこともある )

Example 1 (サイコロの例). Ω = 1, 2, 3, 4, 5, 6, X = サイコロの目.A = 2, 4, 6とすると Pr(X ∈ A) はサイコロを振って偶数の目がでる確率. 公平なサイコロならPr(X ∈ A) = 1/2.

13/26

Page 14: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

確率の計算公理(だけ)から確認できる

• Pr(A) + Pr(Ac) = 1, Ac : Aの補集合

• 単調性: A ⊂ B ⊂ Ω =⇒ Pr(A) ≤ Pr(B).A ⊂ B のとき B = A ∪ (B ∩Ac) (互いに排反).∴ Pr(B) = Pr(A) + Pr(B ∩Ac) ≥ Pr(A).

• 加法定理:Pr(A ∪B) = Pr(A) + Pr(B)− Pr(A ∩B),

Pr(∪iAi) ≤∑

iPr(Ai).

14/26

Page 15: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

連続値をとる確率変数 (例:正規分布)

確率変数 X が 1次元正規分布にしたがう:

Pr(a ≤ X ≤ b) =

∫ b

a

1√2πσ2

e−(x−µ)2

2σ2 dx, (Ω = R)

このとき X ∼ N(µ, σ2) と表す.

−3 −2 −1 0 1 2 3

0.0

0.1

0.2

0.3

0.4

density

−4 −2 0 2 4 6 8

0.0

0.1

0.2

0.3

0.4

normal density

x

p(x)

N(0,1)

N(2,4)

の面積 = Pr(1 ≤ X ≤ 2)

15/26

Page 16: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

確率密度関数n個の確率変数:X1, X2, . . . , Xn.集合 A ⊂ Rn.X = (X1, X2, . . . , Xn) が集合 A に含まれる確率が次式で定まるとする:

Pr(X ∈ A) =

∫A

p(x1, . . . , xn)dx1 · · · dxn

• (同時)確率密度関数:p(x) = p(x1, . . . , xn) ≥ 0,∫

Rnp(x)dx = 1. (略して確率密度,密度)

• 周辺密度:p1(x1) =

∫Rn−1

p(x1, . . . , xn)dx2 · · · dxn など.

離散確率変数 (Aが加算集合)のとき∫A

· · · dx を∑x∈A

· · · に置き換える.

16/26

Page 17: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

確率変数の期待値・分散X = (X1, . . . , Xn) の密度を p(x1, . . . , xn) とする.

• Xi の期待値:「散らばりの中心」を表す.

E[Xi] =

∫Rd

xi p(x1, . . . , xd)dx1 · · · dxd =

∫Rd

xi p(x)dx ∈ R

• X = (X1, . . . , Xd)T の期待値:

E[X] =

E[X1]...

E[Xd]

∈ Rd

• 1次元確率変数 Xi の分散:「散らばりの大きさ」を表す.

V[Xi]定義= E[(Xi − E[Xi])

2] = E[X2i ]− E[Xi]

2

17/26

Page 18: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

独立性,独立同一分布n個の確率変数:X1, X2, . . . , Xn.

• X1, . . . , Xnが 独立⇐⇒ 同時密度関数が積に分解

p(x1, . . . , xn) = p1(x1)p2(x2) · · · pn(xn)

• X1, . . . , Xnが 独立に同一の分布 にしたがう:

p(x1, . . . , xn) = q(x1)q(x2) · · · q(xn), (q = p1 = · · · = pn)

X,Y は独立のとき 以下の等式が成立:

E[XY ] = E[X]E[Y ],

V[X + Y ] = V[X] + V[Y ] note: E[X + Y ] = E[X] + E[Y ] は常に成立.

18/26

Page 19: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• X1, . . . , Xn が独立に同一の分布 P にしたがうとき:

X1, . . . , Xn ∼i.i.d. P または (X1, . . . , Xn) ∼ Pn と書く.

(例えば X1, . . . , Xn ∼ N(0, 1) と書く)

このとき.X1, . . . , Xn の期待値や分散は全て等しい:

E[X1] = · · · = E[Xn], V[X1] = · · · = V[Xn].

• X1, . . . , Xn ∼i.i.d. P,µ = E[Xi], σ2 = V [Xi] のとき

Y =1

n

n∑i=1

Xi =⇒ E[Y ] = µ, V[Y ] =σ2

n

note: E[aX + b] = aE[X] + b, V[aX + b] = a2V[X]

19/26

Page 20: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

条件付き確率・条件付き確率密度

• X,Y に関する確率 Pr(X ∈ A, Y ∈ B) が与えられているとき「X ∈ A の条件のもとで Y ∈ B」となる確率:

Pr(Y ∈ B | X ∈ A) =Pr(X ∈ A, Y ∈ B)

Pr(X ∈ A)

X ∈ A

Y ∈ B

20/26

Page 21: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• 密度 p(x, y) のもとで,x が与えられたときの y の条件付き密度

p(y|x) := p(x, y)∫p(x, y)dy

=p(x, y)

pX(x). (pX(x):x の周辺密度)

性質: ∀x, y, p(y|x) ≥ 0,

∫p(y|x)dy = 1.

「X ∈ [x, x+ dx] の条件下で Y ∈ [y, y + dy] となる確率」

=Pr(X ∈ [x, x+ dx], Y ∈ [y, y + dy])

Pr(X ∈ [x, x+ dx])

=p(x, y)dxdy

pX(x)dx= p(y|x)dy

21/26

Page 22: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

ベイズの定理

Pr(X ∈ A|Y ∈ B) =Pr(Y ∈ B|X ∈ A)Pr(X ∈ A)

Pr(Y ∈ B) 証明:

Pr(X ∈ A|Y ∈ B)Pr(Y ∈ B) = Pr(X ∈ A, Y ∈ B)

= Pr(Y ∈ B|X ∈ A)Pr(X ∈ A).

解釈:X を原因,Y を結果と考えると・・・

• Pr(Y |X): 原因 X から結果 Y への関係

• Pr(X|Y ): 結果 Y を見て,原因 X について推論

22/26

Page 23: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

混合分布:条件付き確率密度の例X は R 上の確率変数,Y は 0, 1 上の確率変数.

Pr(Y = 0) = q, Pr(Y = 1) = 1− q

Xの条件付き密度 : p(x|Y = 0) = p0(x), p(x|Y = 1) = p1(x)

このとき X の周辺密度 p(x) は

p(x) = q · p0(x) + (1− q) · p1(x). (p0とp1の混合分布)

note: p(x) =

∫p(x|y)p(y)dy.この例ではY は離散なので

積分が和になる.

23/26

Page 24: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

ベイズの定理より

Pr(Y = 1|X ∈ [x, x+ dx]) =p(X ∈ [x, x+ dx] |Y = 1)Pr(Y = 1)

p(X ∈ [x, x+ dx])

=(1− q)p1(x)dx

qp0(x) + (1− q)p1(x)dx

=1

q

1− q· p0(x)p1(x)

+ 1

簡単のため Pr(Y = 1|X ∈ [x, x+ dx]) を p(1|x) と書く.

r(x) =q

1− q· p0(x)p1(x)

とおくと

p(1 |x) = 1

r(x) + 1, p(0 |x) = r(x)

r(x) + 1

24/26

Page 25: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

漸近理論:大数の法則X1, . . . , Xn ∼i.i.d . P として E(Xi) = µ とおく.

• 大数の法則:Xn定義=

1

n

n∑i=1

Xi とすると

∀ε > 0, limn→∞

Pr(|Xn − µ| > ε) = 0

∗ nが十分大きいと,高い確率で Xn は µ にほぼ等しい.

定義:確率変数列 Znn∈N が a ∈ R に確率収束する

∀ε > 0, Pr(|Zn − a| > ε) → 0 (n → ∞)

25/26

Page 26: 統計数理講義ノート:ガイダンス・確率の復習 · 2018. 4. 10. · 統計的データ解析と確率論 観測データは複雑(ノイズの影響など) 確率的なモデリングが有効

• 大数の法則より Xnp−→ µ.

• f(x) を連続関数とするとき,普通の極限と類似の関係が成立.

Xnp−→ µ ならば f(Xn)

p−→ f(µ)

Example 2 (大数の法則の例).表の確率が0.7のコイン.n回振って表が出た割合をプロット

0 200 400 600 800

0.5

0.6

0.7

0.8

0.9

1.0

Law of Large Numbers

n

average

26/26