31
ECE 6504: Advanced Topics in Machine Learning Probabilistic Graphical Models and Large-Scale Learning Dhruv Batra Virginia Tech Topics BN / MRFs Learning from hidden data – EM Readings: KF 19.1-3, Barber 11.1-2

ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

ECE 6504: Advanced Topics in Machine Learning

Probabilistic Graphical Models and Large-Scale Learning

Dhruv Batra Virginia Tech

Topics –  BN / MRFs

–  Learning from hidden data –  EM

Readings: KF 19.1-3, Barber 11.1-2

Page 2: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Administrativia •  (Mini-)HW4

–  Out now –  Due: May 7, 11:55pm –  Implementation:

•  Parameter Learning with Structured SVMs and Cutting-Plane

•  Final Project Webpage –  Due: May 7, 11:55pm –  Can use late days –  1-3 paragraphs

•  Goal •  Illustrative figure •  Approach •  Results (with figures or tables)

•  Take Home Final –  Out: May 8 –  Due: May 13, 11:55pm –  No late days –  Open book, open notes, open internet. Cite your sources. –  No discussions!

(C) Dhruv Batra 2

Page 3: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Recap of Last Time

(C) Dhruv Batra 3

Page 4: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Main Issues in PGMs •  Representation

–  How do we store P(X1, X2, …, Xn) –  What does my model mean/imply/assume? (Semantics)

•  Inference –  How do I answer questions/queries with my model? such as –  Marginal Estimation: P(X5 | X1, X4) –  Most Probable Explanation: argmax P(X1, X2, …, Xn)

•  Learning –  How do we learn parameters and structure of

P(X1, X2, …, Xn) from data? –  What model is the right for my data?

(C) Dhruv Batra 4

Page 5: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Learning Bayes Nets

Known structure Unknown structure

Fully observable data Missing data

x(1)

x(m)

Data

structure parameters

CPTs – P(Xi| PaXi)

(C) Dhruv Batra 5 Slide Credit: Carlos Guestrin

Very easy

Somewhat easy (EM)

Hard

Very very hard

Page 6: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Learning the CPTs

x(1)

x(m)

Data For each discrete variable Xi

P̂MLE(Xi = a | PaXi = b) =Count(Xi = a,PaXi = b)

Count(PaXi = b)

(C) Dhruv Batra 6 Slide Credit: Carlos Guestrin

Page 7: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Learning Markov Nets

Known structure Unknown structure

Fully observable data Missing data

x(1)

x(m)

Data

structure parameters

Factors – Ψc(xc)

(C) Dhruv Batra 7 Slide Credit: Carlos Guestrin

NP-Hard (but doable)

Harder (EM)

Harder

Don’t try this at home

Page 8: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Learning Parameters of a BN •  Log likelihood decomposes:

•  Learn each CPT independently

•  Use counts

Flu Allergy

Sinus

Nose

(C) Dhruv Batra 8 Slide Credit: Carlos Guestrin

Page 9: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Log Likelihood for MN •  Log likelihood decomposes:

•  Doesn’t decompose! –  logZ couples all parameters together

Flu Allergy

Sinus

Nose

(C) Dhruv Batra 9 Slide Credit: Carlos Guestrin

Page 10: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Plan for today •  BN Parameter Learning with Missing Data

–  Why model latent variables? –  Expectation Maximization (EM)

(C) Dhruv Batra 10

Page 11: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Learning Bayes Nets

Known structure Unknown structure

Fully observable data Missing data

x(1)

x(m)

Data

structure parameters

CPTs – P(Xi| PaXi)

(C) Dhruv Batra 11 Slide Credit: Carlos Guestrin

Very easy

Somewhat easy (EM)

Hard

Very very hard

Page 12: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

When is data missing? •  Fully Observed Data

•  Some hidden variables –  Never observed

•  General hidden pattern –  Arbitrary entries missing in the data matrix

(C) Dhruv Batra 12

Page 13: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Why missing data? •  Sometimes no choice

–  sensor error, some data dropped –  Data collection error, we forgot to ask this question

(C) Dhruv Batra 13

Page 14: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Why introduce hidden variables? •  Model Sparsity!

–  Modeling hidden/latent variables can simplify interactions –  Reduction in #parameters to be learnt

•  Example –  On board

(C) Dhruv Batra 14

Page 15: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Why introduce hidden variables? •  Discovering Clusters in data!

–  Modeling different P(y|x,h) for each h

(C) Dhruv Batra 15

Component #1

Average Example DPM

Component #2

Component #3

Component #4

Component #5

Component #6

Page 16: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Treating Missing Data •  Thought Experiment:

–  Coin Toss: H,T,?,?,H,H,?

•  Case 1: Missing at Random

•  Case 2: Missing with bias

•  BN illustration of the two cases –  On board –  Takeaway message: Need to model missing data

(C) Dhruv Batra 16

Page 17: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Likelihood with Complete/Missing Data •  Example on board X->Y

–  One variable X; parameter θX –  Two variables X,Y; parameters θX, θY|X

•  Takeaway Messages: –  Parameters get coupled (LL = sum-log-sum doesn’t

factorize) –  Computing LL requires marginal inference!

(C) Dhruv Batra 17

Page 18: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Data likelihood for BNs

•  Given structure, log likelihood of fully observed data:

Flu Allergy

Sinus

Headache Nose

(C) Dhruv Batra 18 Slide Credit: Carlos Guestrin

Page 19: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Marginal likelihood

•  What if S is hidden?

Flu Allergy

Sinus

Headache Nose

(C) Dhruv Batra 19 Slide Credit: Carlos Guestrin

Page 20: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

•  Marginal likelihood – O is observed, H is hidden

Log likelihood for BNs with hidden data Flu Allergy

Sinus

Headache Nose

(C) Dhruv Batra 20 Slide Credit: Carlos Guestrin

Page 21: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

EM Intuition •  Chicken & Egg problem

–  If we knew h, then learning θ would be easy –  If we knew theta, then finding P(h | o, θ) would be “easy”

•  Sum-product inference

•  EM solution –  Initialize –  Fix θ, find P(h | o, θ) –  Use these to learn θ

(C) Dhruv Batra 21

Page 22: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

E-step for BNs

•  E-step computes probability of hidden vars h given o

•  Corresponds to inference in BN

Flu Allergy

Sinus

Headache Nose

(C) Dhruv Batra 22 Slide Credit: Carlos Guestrin

Page 23: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

The M-step for BNs

•  Maximization step:

•  Use expected counts instead of counts: –  If learning requires Count(h,o) –  Use EQ(t+1)[Count(h,o)]

Flu Allergy

Sinus

Headache Nose

(C) Dhruv Batra 23 Slide Credit: Carlos Guestrin

Page 24: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

M-step for each CPT •  M-step decomposes per CPT

–  Standard MLE:

–  M-step uses expected counts:

Flu Allergy

Sinus

Headache Nose

(C) Dhruv Batra 24 Slide Credit: Carlos Guestrin

Page 25: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

•  Marginal likelihood – o is observed, h is missing:

The general learning problem with missing data

25 (C) Dhruv Batra

ll(θ : D) = logM�

j=1

P (oj | θ)

=M�

j=1

logP (oj | θ)

=M�

j=1

log�

h

P (oj ,h | θ)

Page 26: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Applying Jensen’s inequality

•  Use: log ∑h P(h) f(h) ≥ ∑h P(h) log f(h)

26 (C) Dhruv Batra

ll(θ : D) =M�

j=1

log�

h

Qj(h)P (oj ,h | θ)

Qj(h)

Page 27: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

Convergence of EM

27 (C) Dhruv Batra

•  Define potential function F(θ,Q):

•  EM corresponds to coordinate ascent on F –  Fix θ, maximize Q –  Fix Q, maximize θ –  Thus, maximizes lower bound on marginal log likelihood

ll(θ : D) ≥ F (θ, Qj) =M�

j=1

h

Qj(h) logP (oj ,h | θ)

Qj(h)

Page 28: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

EM is coordinate ascent

•  E-step: Fix θ(t), maximize F over Q: –  On board

–  “Realigns” F with likelihood:

28 (C) Dhruv Batra

F (θ(t), Q(t)) = ll(θ(t) : D)

Qj(h) = P (h | oj , θ(t))

ll(θ : D) ≥ F (θ, Qj) =M�

j=1

h

Qj(h) logP (oj ,h | θ)

Qj(h)

Page 29: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

EM is coordinate ascent

•  M-step: Fix Q(t), maximize F over θ

•  Corresponds to weighted dataset: –  <o1,h=1> with weight Q(t+1)(h=1|o1) –  <o1,h=2> with weight Q(t+1)(h=2|o1) –  <o1,h=3> with weight Q(t+1)(h=3|o1) –  <o2,h=1> with weight Q(t+1)(h=1|o2) –  <o2,h=2> with weight Q(t+1)(h=2|o2) –  <o2,h=3> with weight Q(t+1)(h=3|o2) –  … 29 (C) Dhruv Batra

ll(θ : D) ≥ F (θ, Qj) =M�

j=1

h

Qj(h) logP (oj ,h | θ)

Qj(h)

Page 30: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

EM Intuition

(C) Dhruv Batra 30

Q(!,!t)

Q(!,!t+1

)

l(!)

!t

!t+1

!t+2

Page 31: ECE 6504: Advanced Topics in Machine Learnings14ece6504/slides/L20... · • Parameter Learning with Structured SVMs and Cutting-Plane • Final Project Webpage – Due: May 7, 11:55pm

•  EM for Bayes Nets

•  E-step: inference computes expected counts –  Only need expected counts over Xi and Paxi

•  M-step: expected counts used to estimate parameters

•  Which variables are hidden can change per datapoint –  Also, use labeled and unlabeled data à some data points

are complete, some include hidden variables

What you need to know about learning BNs with missing data