10-701 Machine Learning Recita2on 2: Probability / Sta2s2cs - - PowerPoint PPT Presentation

10 701 machine learning recita2on 2 probability sta2s2cs
SMART_READER_LITE
LIVE PREVIEW

10-701 Machine Learning Recita2on 2: Probability / Sta2s2cs - - PowerPoint PPT Presentation

10-701 Machine Learning Recita2on 2: Probability / Sta2s2cs Dougal Sutherland 9/24/2013 Sample spaces Start with a sample space for an


slide-1
SLIDE 1

10-­‑701 ¡Machine ¡Learning ¡ Recita2on ¡2: ¡Probability ¡/ ¡Sta2s2cs ¡

Dougal ¡Sutherland ¡ 9/24/2013 ¡

slide-2
SLIDE 2

Sample ¡spaces ¡

  • Start ¡with ¡a ¡sample ¡space ¡Ω ¡for ¡an ¡“experiment” ¡

– The ¡set ¡of ¡all ¡possible ¡outcomes ¡ – Flipping ¡a ¡coin: ¡{H, ¡T} ¡ – Flipping ¡a ¡coin ¡three ¡2mes: ¡ {HHH, ¡HHT, ¡HTH, ¡HTT, ¡THH, ¡THT, ¡TTH, ¡TTT} ¡ – A ¡person’s ¡age: ¡the ¡posi2ve ¡integers ¡ – A ¡person’s ¡height: ¡the ¡posi2ve ¡reals ¡

slide-3
SLIDE 3

Events ¡

  • An ¡event ¡E ¡is ¡a ¡subset ¡of ¡Ω ¡

– Can ¡do ¡normal ¡set ¡opera2ons ¡

  • Don’t ¡need ¡to ¡allow ¡for ¡any ¡arbitrary ¡subset ¡
  • Just ¡need ¡a ¡𝜏-­‑algebra, ¡which ¡is ¡a ¡set ¡B ¡that ¡

– Contains ¡∅ ¡ – Is ¡closed ¡under ¡complements ¡ – Is ¡closed ¡under ¡countable ¡unions ¡

  • In ¡prac2ce, ¡usually ¡don’t ¡need ¡to ¡worry ¡about ¡it ¡
slide-4
SLIDE 4

Probability ¡axioms ¡

P(E) ≥ 0

  • 1. ¡Nonnega2vity: ¡ ¡

P(Ω) = 1

  • 2. ¡Unit ¡measure: ¡

P(E1 ∪ E2 ∪ . . . ) =

X

i=1

P(Ei)

if ¡the ¡Ei ¡are ¡mutually ¡exclusive: ¡Ei ¡∩ ¡Ej ¡= ¡∅ ¡for ¡i ¡≠ ¡j ¡

  • 3. ¡σ-­‑addi2vity: ¡ ¡

A ¡probability ¡func2on ¡P ¡is ¡a ¡func2on ¡from ¡events ¡ in ¡our ¡𝜏-­‑algebra ¡to ¡real ¡numbers ¡sa2sfying: ¡

slide-5
SLIDE 5

Consequences ¡of ¡axioms ¡

P(Ac) = 1 − P(A)

P(A ∪ Ac) = P(Ω) = 1 = P(A) + P(Ac) (ax. ¡2) ¡ since ¡A, ¡Ac ¡are ¡disjoint ¡(ax. ¡3) ¡

P(A) ≤ 1

since ¡P(Ac) ¡= ¡1 ¡– ¡P(A) ¡≥ ¡0 ¡

P(∅) = 0

P(∅) = P(Ωc) = 1 − P(Ω) = 1 − 1 = 0

slide-6
SLIDE 6

Possible ¡probability ¡func2ons ¡

  • For ¡Ω ¡ ¡= ¡{H, ¡T}: ¡

– We ¡know ¡P(∅) ¡= ¡0, ¡P(Ω) ¡= ¡1 ¡always ¡ – {∅, ¡Ω} ¡is ¡a ¡valid ¡𝜏-­‑algebra ¡so ¡we ¡could ¡be ¡done ¡ – But ¡we ¡can ¡probably ¡observe ¡H ¡vs ¡T: ¡

  • P(H) ¡= ¡p ¡can ¡be ¡anything ¡in ¡[0, ¡1] ¡
  • P(T) ¡= ¡P({H}c) ¡= ¡1 ¡– ¡p ¡
slide-7
SLIDE 7

More ¡consequences ¡of ¡axioms ¡

P(B ∩ Ac) = P(B) − P(A ∩ B) P(A ∪ B) = P(A) + P(B) − P(A ∩ B) P(A ∩ B) ≥ P(A) + P(B) − 1 Corollary: ¡ A ⊆ B implies P(A) ≤ P(B)

slide-8
SLIDE 8

Interpreta2on ¡of ¡probabili2es ¡

  • Frequen2st: ¡

– long-­‑run ¡por2on ¡of ¡2mes ¡the ¡event ¡happens ¡

  • Bayesian: ¡

– Quan2fica2on ¡of ¡beliefs ¡ – Can ¡derive ¡axioms ¡from ¡a ¡certain ¡set ¡of ¡“common ¡ sense” ¡descrip2ons ¡of ¡how ¡beliefs ¡should ¡work ¡ (Cox’s ¡Theorem) ¡ P(E) = lim

n→∞

1 n

n

X

i=1

(Xi ∈ E)

slide-9
SLIDE 9

Defining ¡probabili2es ¡

  • Don’t ¡want ¡to ¡have ¡to ¡check ¡the ¡axioms ¡for ¡every ¡

probability ¡func2on ¡

P(E) = X

i:ωi∈E

pi

  • One ¡general ¡palern: ¡

– Let ¡{ω1, ¡ω2, ¡…} ¡be ¡a ¡countable ¡set ¡of ¡“atomic ¡events” ¡ (mutually ¡exclusive, ¡cover ¡all ¡of ¡Ω) ¡ – Define ¡corresponding ¡nonnega2ve ¡pi ¡that ¡sum ¡to ¡1 ¡ – Then ¡a ¡valid ¡probability ¡func2on ¡is ¡

slide-10
SLIDE 10

Condi2oning ¡

  • Basically, ¡just ¡change ¡the ¡sample ¡space ¡

– P(E1 ¡| ¡E2) ¡changes ¡P(E1) ¡with ¡sample ¡space ¡Ω ¡to ¡ have ¡sample ¡space ¡E2: ¡P(E1∩E2) ¡/ ¡P(E2). ¡

  • If ¡E2 ¡is ¡empty ¡this ¡isn’t ¡well-­‑defined. ¡
  • If ¡E1∩E2= ¡∅, ¡P(E1|E2) ¡= ¡0. ¡

Ω ¡ E2 ¡ E1 ¡

slide-11
SLIDE 11

Bayes’ ¡Rule ¡

P(A, ¡B) ¡= ¡P(A|B) ¡P(B) ¡ ¡ ¡ ¡ ¡ ¡= ¡P(B|A) ¡P(A) ¡ ¡ so ¡P(A|B) ¡= ¡P(B|A) ¡P(A) ¡/ ¡P(B) ¡ P(model|data) ¡= ¡P(data|model) ¡P(model) ¡/ ¡P(data) ¡

P(English|French) ¡= ¡P(French|English) ¡P(English) ¡/ ¡P(French) ¡

slide-12
SLIDE 12

Independence ¡

  • Events ¡A ¡and ¡B ¡are ¡independent ¡(A⟂B) ¡if ¡

¡ ¡P(A∩B) ¡= ¡P(A) ¡P(B) ¡ ¡

  • Equivalently, ¡P(A|B) ¡= ¡P(A), ¡P(B|A) ¡= ¡P(B) ¡

¡

  • If ¡A⟂B, ¡then ¡Ac⟂B, ¡A⟂Bc, ¡Ac⟂Bc ¡

¡

slide-13
SLIDE 13

Condi2onal ¡independence ¡

  • P(A∩B|C) ¡= ¡P(A|C) ¡P(B|C) ¡ ¡or ¡ ¡P(A|B,C) ¡= ¡P(A|C) ¡

¡

  • WARNING: ¡A⟂B ¡doesn’t ¡imply ¡A⟂B|Z! ¡

– Let ¡A ¡and ¡B ¡be ¡coin ¡flips ¡and ¡Z ¡be ¡A ¡xor ¡B. ¡ – Then ¡A⟂B, ¡A⟂Z, ¡B⟂Z ¡but ¡(B|A,Z) ¡is ¡fully ¡known. ¡

slide-14
SLIDE 14

Independence ¡of ¡several ¡events ¡

  • The ¡last ¡example ¡had ¡A⟂B, ¡B⟂Z, ¡A⟂Z ¡

(pairwise ¡independent), ¡but ¡we ¡don’t ¡have ¡A, ¡ B, ¡Z ¡all ¡“mutually ¡independent.” ¡ ¡

  • P(A∩B∩Z) ¡= ¡P(A) ¡P(B) ¡P(Z) ¡also ¡isn’t ¡enough. ¡

¡

  • The ¡defini2on: ¡for ¡any ¡subcollec2on ¡i1, ¡…, ¡ik, ¡

P @

k

\

j=1

Aij 1 A =

k

Y

j=1

P

  • Aij
slide-15
SLIDE 15

Random ¡variables ¡

  • So ¡far ¡we’ve ¡been ¡talking ¡only ¡about ¡events ¡
  • Usually ¡we ¡work ¡with ¡random ¡variables ¡
  • Technically: ¡a ¡func2on ¡on ¡the ¡sample ¡space ¡

– Whether ¡a ¡coin ¡flip ¡was ¡heads: ¡ X(ω) ¡= ¡1 ¡if ¡ω ¡= ¡H, ¡0 ¡if ¡ω ¡= ¡T ¡ – Number ¡of ¡heads ¡in ¡a ¡sequence: ¡ a ¡func2on ¡from ¡Ω ¡= ¡{H, ¡T}n ¡to ¡{0, ¡1, ¡…, ¡n} ¡

  • Normally, ¡func2on ¡is ¡into ¡Rd ¡or ¡Zd ¡

– Though ¡it ¡can ¡be ¡anything ¡

slide-16
SLIDE 16

Probability ¡mass ¡func2on ¡

  • Discrete ¡(not ¡“discreet”) ¡RVs: ¡domain ¡is ¡a ¡countable ¡

subset ¡of ¡the ¡reals ¡

– e.g. ¡X ¡= ¡number ¡of ¡heads ¡in ¡a ¡sequence ¡of ¡coin ¡flips ¡

  • Naturally ¡defines ¡atomic ¡events ¡for ¡each ¡value ¡

– e.g. ¡{X ¡= ¡0}, ¡{X ¡= ¡1}, ¡…, ¡{X ¡= ¡n} ¡

  • Probability ¡mass ¡func2on: ¡func2on ¡from ¡values ¡

to ¡probability ¡of ¡that ¡value ¡(basically ¡a ¡table) ¡

– e.g. ¡PX(k) ¡= ¡P({X ¡= ¡k}) ¡

  • Nonnega2ve, ¡sums ¡to ¡1 ¡
slide-17
SLIDE 17

Jointly ¡distributed ¡random ¡variables ¡

  • If ¡X ¡and ¡Y ¡have ¡a ¡joint ¡distribu2on, ¡then ¡

they’re ¡components ¡of ¡the ¡random ¡vector ¡ concat(X, ¡Y) ¡

  • Joint ¡PMF ¡is ¡just ¡a ¡mul2dimensional ¡table ¡

P(X) = X

Y

P(X, Y )

  • Marginal ¡of ¡X ¡is ¡the ¡distribu2on ¡of ¡X ¡ignoring ¡Y ¡
slide-18
SLIDE 18

Condi2oning, ¡independence ¡of ¡RVs ¡

  • Condi2oning, ¡independence ¡for ¡RVs ¡are ¡basically ¡

the ¡same ¡as ¡for ¡events: ¡

– P(A|B) ¡= ¡P(A, ¡B) ¡/ ¡P(B) ¡

  • but ¡now ¡talking ¡about ¡funcDons ¡rather ¡than ¡scalars ¡

– P(A|B) ¡= ¡P(B|A) ¡P(A) ¡/ ¡P(B) ¡ – A⟂B ¡if ¡P(A, ¡B) ¡= ¡P(A) ¡P(B) ¡

  • also ¡as ¡func2ons, ¡i.e. ¡true ¡for ¡any ¡value ¡for ¡A ¡and ¡B ¡
  • i.i.d.: ¡“independent ¡and ¡iden2cally ¡distributed” ¡
slide-19
SLIDE 19

Cumula2ve ¡distribu2on ¡func2ons ¡

  • The ¡cdf ¡is ¡FX(x) ¡= ¡P(X ¡≤ ¡x) ¡

P ✓ max

1≤i≤n Xi ≤ x

◆ = P ((X1 ≤ x) ∩ · · · ∩ (Xn ≤ x)) = P (X1 ≤ x) · · · P (Xn ≤ x) = (P (X1 ≤ x))n

  • Useful ¡for ¡a ¡lot ¡of ¡theore2cal ¡things: ¡

– e.g. ¡ F(−∞) = 0 F(∞) = 1

F ¡is ¡nondecreasing ¡

slide-20
SLIDE 20

CDFs ¡for ¡con2nuous ¡RVs ¡

  • Can’t ¡do ¡a ¡mass ¡func2on: ¡P(X=x) ¡= ¡0 ¡for ¡any ¡x ¡
  • S2ll ¡can ¡do ¡FX(x) ¡= ¡P(X ¡≤ ¡x) ¡the ¡same ¡way ¡
  • F ¡is ¡con2nuous ¡if ¡a ¡con2nuous ¡RV; ¡ ¡

right-­‑con2nuous ¡if ¡mixed ¡

  • Joint ¡CDF: ¡

¡P(X ¡≤ ¡x, ¡Y ¡≤ ¡y) ¡

slide-21
SLIDE 21

Probability ¡density ¡func2ons ¡

  • Deriva2ve ¡of ¡the ¡CDF: ¡
  • Nonnega2ve, ¡but ¡can ¡be ¡> ¡1 ¡
  • Integrates ¡to ¡1 ¡

P(X ≤ x) = Z x

−∞

f(x) dx

slide-22
SLIDE 22

Important ¡distribu2ons ¡

  • Discrete: ¡

– Bernoulli ¡(coin ¡flip) ¡ – Binomial ¡(# ¡of ¡heads ¡in ¡a ¡series ¡of ¡coin ¡flips) ¡ – Categorical ¡(dice ¡roll) ¡ – Mul2nomial ¡(# ¡of ¡each ¡result ¡in ¡a ¡series ¡of ¡dice ¡rolls) ¡ – Poisson ¡(# ¡of ¡events ¡with ¡a ¡certain ¡rate) ¡ – Hypergeometric ¡(sampling ¡without ¡replacement) ¡ – Geometric ¡(# ¡of ¡flips ¡un2l ¡heads) ¡ – Nega2ve ¡binomial ¡(# ¡of ¡flips ¡un2l ¡n ¡heads) ¡

slide-23
SLIDE 23

Important ¡distribu2ons ¡

  • Con2nuous: ¡

– Normal/Gaussian ¡ – Uniform ¡ ¡ – Beta ¡ – Chi-­‑squared ¡ – Exponen2al ¡ – Gamma ¡ – Laplace ¡

slide-24
SLIDE 24

Func2ons ¡of ¡an ¡RV ¡

  • If ¡X ¡is ¡a ¡random ¡variable, ¡so ¡is ¡X2 ¡

P (g(X) ∈ A) = P ({x : g(x) ∈ A}) = P

  • X ∈ g−1(A)
  • We ¡can ¡get ¡a ¡distribu2on ¡for ¡Y ¡= ¡g(X): ¡
slide-25
SLIDE 25

Expecta2on ¡

  • The ¡mean ¡of ¡a ¡random ¡variable: ¡

E [X] = lim

n→∞

1 n

n

X

i=1

Xi

slide-26
SLIDE 26

Expecta2on ¡

  • The ¡mean ¡of ¡a ¡random ¡variable: ¡

EX [g(X)] = Z g(x) dP(X = x)

EX [g(X)] = X g(x) P(X = x) EX [g(X)] = Z g(x) p(X = x) dx EX [αg(X) + h(x)] = Z (αg(x) + h(x)) dP(X = x) = α Z g(x) dP(X = x) + Z h(x) dP(X = x) = αEX[g(X)] + EX[h(X)]

Linear: ¡

slide-27
SLIDE 27

Variance ¡

  • A ¡measure ¡of ¡the ¡spread ¡of ¡a ¡distribu2on: ¡

Var(X) = E ⇥ (X − E[X])2⇤

  • Standard ¡devia2on: ¡ ¡

p Var(X) Var(X) = E ⇥ (X − µ)2⇤ = E ⇥ X2 − 2µX + µ2⇤ = E[X2] − 2µ E[X] + µ2 = E[X2] − µ2

slide-28
SLIDE 28

Law ¡of ¡large ¡numbers ¡

  • Actually, ¡I ¡just ¡lied ¡to ¡you: ¡the ¡defini2on ¡of ¡

expecta2on ¡is ¡the ¡integral, ¡not ¡the ¡limit ¡

P lim

n→∞

1 n

n

X

i=1

Xi = E[X] ! = 1

  • But ¡it’s ¡okay, ¡because ¡of ¡the ¡law ¡of ¡large ¡

numbers: ¡

  • Always ¡true ¡as ¡long ¡as ¡the ¡expecta2on ¡exists ¡

– though ¡the ¡proof ¡is ¡harder ¡and ¡convergence ¡is ¡ slower ¡if ¡E[X2] ¡doesn’t ¡exist ¡

slide-29
SLIDE 29

Central ¡limit ¡theorem ¡

If ¡X1, ¡…, ¡Xn ¡are ¡iid ¡and ¡have ¡finite ¡mean/variance: ¡

1 n

n

X

i=1

Xi ∼ N ✓ µ, σ2 n ◆

slide-30
SLIDE 30

Covariance ¡

  • Covariance: ¡ ¡
  • Measure ¡of ¡linear ¡rela2onship ¡between ¡X, ¡Y ¡
  • Note ¡Var(X) ¡= ¡Cov(X, ¡X) ¡

Cov(X, Y ) = E [(X − E[X])(Y − E[Y ])] Cov(X, Y ) = E [(X − E[X])(Y − E[Y ])] = E [XY − X E[Y ] − E[X]Y + E[X] E[Y ]] = E [XY ] − E[X] E[Y ] − E[X] E[Y ] + E[X] E[Y ] = E [XY ] − E[X] E[Y ]

slide-31
SLIDE 31

Correla2on ¡

ρX,Y = Cov(X, Y ) σXσY

slide-32
SLIDE 32

Covariance ¡matrix ¡

  • If ¡we ¡have ¡a ¡random ¡n-­‑vector ¡X: ¡

Cov(X) = E ⇥ (X − E[X])(X − E[X])T ⇤ = E[XXT ] − E[X] E[X]T = 2 6 6 6 4 Cov(X1, X1) Cov(X1, X2) . . . Cov(X1, Xn) Cov(X2, X1) Cov(X2, X2) . . . Cov(X2, Xn) . . . . . . ... . . . Cov(Xn, X1) Cov(Xn, X2) . . . Cov(Xn, Xn) 3 7 7 7 5

  • Symmetric, ¡posi2ve ¡semi-­‑definite ¡
  • Cov(A ¡X ¡+ ¡a) ¡= ¡A ¡Cov(X) ¡AT ¡
  • Cov(X, ¡Y) ¡= ¡Cov(Y, ¡X)T ¡
  • Cov(X ¡+ ¡Y, ¡Z) ¡= ¡Cov(X, ¡Z) ¡+ ¡Cov(Y, ¡Z) ¡
slide-33
SLIDE 33

Maximum ¡likelihood ¡es2mate ¡(MLE) ¡

  • If ¡you ¡think ¡your ¡data ¡is ¡e.g. ¡normally ¡

distributed, ¡you ¡s2ll ¡need ¡to ¡find ¡the ¡mean ¡ and ¡the ¡variance. ¡

  • Most ¡common ¡way: ¡maximize ¡the ¡likelihood ¡
  • f ¡the ¡data ¡under ¡the ¡model. ¡

arg max

θ

P(X; θ) = arg max

θ n

Y

i=1

P(Xi; θ)

slide-34
SLIDE 34

Maximum ¡a ¡posteriori ¡(MAP) ¡

  • The ¡MLE ¡is ¡prone ¡to ¡overfi}ng, ¡as ¡we ¡just ¡saw ¡
  • Par2al ¡solu2on: ¡add ¡a ¡prior ¡

arg max

θ

P(θ | X) = arg max

θ

P(X | θ)P(θ) R

ϑ P(X | ϑ)P(ϑ) dϑ

= arg max

θ

P(X | θ)P(θ)

slide-35
SLIDE 35

Posterior ¡mean ¡

  • Another ¡choice ¡for ¡a ¡Bayesian ¡es2mate ¡

– Minimizes ¡L2 ¡risk ¡ – Posterior ¡mode, ¡aka ¡MAP, ¡minimizes ¡L0 ¡risk ¡ – Posterior ¡median ¡minimizes ¡L1 ¡risk ¡

  • In ¡general, ¡harder ¡to ¡compute ¡than ¡MAP ¡

– In ¡“easy” ¡parametric ¡cases, ¡might ¡be ¡known ¡ – Can ¡es2mate ¡from ¡posterior ¡samples ¡

  • Markov ¡chain ¡Monte ¡Carlo ¡
slide-36
SLIDE 36

Posterior ¡distribu2on ¡

  • The ¡“best” ¡answer: ¡don’t ¡use ¡a ¡point ¡es2mate! ¡

P(θ | X) = P(X | θ)P(θ) R

ϑ P(X | ϑ)P(ϑ) dϑ

  • Problem: ¡it’s ¡hard ¡to ¡compute ¡

– Can ¡find ¡the ¡“best” ¡approxima2on ¡in ¡some ¡simpler ¡ family ¡(Varia2onal ¡Bayes, ¡expecta2on ¡propaga2on) ¡ – Can ¡get ¡approximate ¡samples ¡from ¡the ¡posterior ¡ (Markov ¡chain ¡Monte ¡Carlo) ¡

slide-37
SLIDE 37

Nonparametric ¡sta2s2cs ¡

  • Problem: ¡real ¡data ¡rarely ¡follows ¡idealized ¡

distribu2ons ¡

– Mul2modal ¡ – Heavier ¡tails ¡

  • If ¡you ¡blindly ¡use ¡it, ¡you ¡might ¡get ¡tricked ¡
  • Instead: ¡

– Histograms ¡ – Kernel ¡density ¡es2ma2on ¡ – kNN ¡density ¡es2ma2on ¡

slide-38
SLIDE 38

Classifica2on ¡

  • Now ¡that ¡we ¡know ¡how ¡to ¡talk ¡about ¡probability ¡

distribu2ons, ¡how ¡do ¡we ¡use ¡them? ¡

  • Start ¡with ¡two-­‑class ¡classifica2on: ¡

– Posi2ve/nega2ve ¡generated ¡by ¡different ¡distribu2ons ¡

P(+ | x) = P(x | +)P(+) P(x) P(− | x) = P(x | −)P(−) P(x) P(+ | x) P(− | x) = P(x | +)P(+) P(x | −)P(−)

slide-39
SLIDE 39

Classifica2on ¡

  • P(+), ¡P(-­‑) ¡are ¡class ¡prior ¡probabili2es ¡

– Can ¡just ¡es2mate ¡with ¡counts ¡in ¡training ¡data ¡

  • P(x ¡| ¡+), ¡P(x ¡| ¡-­‑) ¡are ¡the ¡core ¡of ¡the ¡classifier: ¡

– Watson-­‑Nadaraya: ¡use ¡kernel ¡density ¡es2mate ¡ – K-­‑nearest-­‑neighbor: ¡use ¡kNN ¡density ¡es2mate ¡ – Naïve ¡Bayes: ¡ ¡

  • assume ¡P(x ¡| ¡class) ¡= ¡P(x1 ¡| ¡class) ¡… ¡P(xn ¡| ¡class) ¡
  • model ¡each ¡of ¡those ¡parametrically ¡

P(+ | x) P(− | x) = P(x | +)P(+) P(x | −)P(−)