129
Parameter Learning

Parameter Learning

  • Upload
    judson

  • View
    37

  • Download
    1

Embed Size (px)

DESCRIPTION

Parameter Learning. Announcements. Midterm 24 th 7-9pm, NVIDIA. Midterm review in class next Tuesday. Extra study material for midterm (after class). Homework back. Regrade process. Looking into reflex agent on pacman. Some changes to the schedule. - PowerPoint PPT Presentation

Citation preview

Page 1: Parameter Learning

Parameter Learning

Page 2: Parameter Learning

Announcements

• Midterm 24th 7-9pm, NVIDIA

• Midterm review in class next Tuesday

• Homework back

• Regrade process

• Looking into reflex agent on pacman

• Extra study material for midterm (after class).

• Some changes to the schedule

• Want to hear your song before class?

Page 3: Parameter Learning

Happy with how you did

Page 4: Parameter Learning

A lot of class left

>= 17 / 20>= 15 / 20>= 12 / 20>= 9 / 20>= 2 / 20

> 20 / 20> 23 / 20

Pac Man Grades

CS221 Grade Book16%

Page 5: Parameter Learning

A lot of class left

GoodGoodOk?TalkTalk

GoodYay

How we see it

CS221 Grade Book16%

Page 6: Parameter Learning

A lot of class left

GoodGoodOk?TalkTalk

GoodYay

Good job!

CS221 Grade Book16%

Page 7: Parameter Learning

A lot of class left

GoodGoodOk?TalkTalk

GoodYay

Alright

CS221 Grade Book16%

Page 8: Parameter Learning

A lot of class left

GoodGoodOk?TalkTalk

GoodYay

Rethink

CS221 Grade Book16%

Page 9: Parameter Learning

Theory on Grades

Page 10: Parameter Learning

Real World Problem

Formal Problem

Solution

Model the problem

Apply an Algorithm

Evaluate

Common Error: Formalize a problem

Page 11: Parameter Learning

: what makes a state

: possible actions from state s

Succ: states that could result from taking action a from state s

: reward for taking action a from state s

: starting state

: whether to stop

: the value of reaching a given stopping point

Modeling Discrete Search

Page 12: Parameter Learning

: what makes a state

: possible actions from state s

: probability distribution of states that could result from taking action a from state s

: reward for taking action a from state s

: starting state

: whether to stop

: the value of reaching a given stopping point

Modeling Markov Decision

Page 13: Parameter Learning

Definition: Bayes Net = DAGDAG: directed acyclic graph (BN’s structure)

• Nodes: random variables (typically discrete, but methods also exist to handle continuous variables)

• Arcs: indicate probabilistic dependencies between nodes. Go from cause to effect.

• CPDs: conditional probability distribution (BN’s parameters) Conditional probabilities at each node, usually stored as a table (conditional probability table, or CPT)

Root nodes are a special case – no parents, so just use priors in CPD:

iiii xxP of nodesparent all ofset theis where)|(

)()|( so , iiii xPxP

Modeling Bayes Net

Page 14: Parameter Learning

Formally:(1) State variables and their domains(2) Evidence variables and their domains(3) Probability of states at time 0(4) Transition probability(5) Emission probability

Modeling Hidden Markov Model

X5X2

E1

X1 X3 X4

E2 E3 E4 E5

Page 15: Parameter Learning

Formally, we want to get our model inside the python

Page 16: Parameter Learning

Scary?

Page 17: Parameter Learning

Theory on Grades

Page 18: Parameter Learning

Previously on CS221

In Class Research

Page 19: Parameter Learning

Previously on CS221

In Class Research

Page 20: Parameter Learning

Previously on CS221

Page 21: Parameter Learning

Formally:(1) State variables and their domains(2) Evidence variables and their domains(3) Probability of states at time 0(4) Transition probability(5) Emission probability

Hidden Markov ModelX5X2

E1

X1 X3 X4

E2 E3 E4 E5

Page 22: Parameter Learning

E1

X1 X2X1

Filtering

Page 23: Parameter Learning

Tracking Other Cars

Page 24: Parameter Learning

Track a Car!

Pos2

Dist1

Pos1

Dist2

Page 25: Parameter Learning

Track a Robot!

Dist1

Pos1

Value of d

Prob

abili

ty D

ensit

y

Page 26: Parameter Learning

μ = True distance from x to your car

Track a Robot!

Dist1

Pos1

Value of d

Prob

abili

ty D

ensit

y

Page 27: Parameter Learning

μ = True distance from x to your car

Track a Robot!

Dist1

Pos1

Value of d

Prob

abili

ty D

ensit

yσ = Const.SONAR_STD

Page 28: Parameter Learning

Track a Robot!

Pos2Pos1

Page 29: Parameter Learning

Particle Filters

A particle is a hypothetical instantiation of a variable.

Store a large number of particles.

Elapse time by moving each particle given transition probabilities.

When we get new evidence we weight each particle and create a new generation.

The density of particles for any given value is an approximation of the probability that our variable equals that value

Page 30: Parameter Learning

Sometimes |X| is too big to use exact inference

– |X| may be too big to even store B(X)– E.g. X is continuous– E.g. X is a real world map

Solution: approximate inference– Track samples of X, not all values– Samples are called particles– Time per step is linear in the number of

samples– But: number needed may be large– In memory: list of particles, not states

This is how robot localization works in practice

0.0 0.1

0.0 0.0

0.0

0.2

0.0 0.2 0.5

Particle Filtering

Page 31: Parameter Learning

Each particle is moved by sampling its next position from the transition model

– Reflect the transition probs– Here, most samples move clockwise, but

some move in another direction or stay in place

This captures the passage of time– If we have enough samples, close to the

exact values before and after (consistent)

Elapse Time

Page 32: Parameter Learning

Slightly trickier:– We downweight our samples based on

the evidence

– Note that, as before, the probabilities don’t sum to one, since most have been downweighted (in fact they sum to an approximation of P(e))

Observe Step

Page 33: Parameter Learning

Rather than tracking weighted samples, we resample

N times, we choose from our weighted sample distribution (i.e. draw with replacement)

This is analogous to renormalizing the distribution

Now the update is complete for this time step, continue with the next one

Old Particles: (3,3) w=0.1 (2,1) w=0.9 (2,1) w=0.9 (3,1) w=0.4 (3,2) w=0.3 (2,2) w=0.4 (1,1) w=0.4 (3,1) w=0.4 (2,1) w=0.9 (3,2) w=0.3

New Particles: (2,1) w=1 (2,1) w=1 (2,1) w=1 (3,2) w=1 (2,2) w=1 (2,1) w=1 (1,1) w=1 (3,1) w=1 (2,1) w=1 (1,1) w=1

Resample

Page 34: Parameter Learning

Track a Robot!

Pos2

Walls1

Pos1

Walls2

Sometimes sensors are

wrong

Sometimes motors don’t

work

Page 35: Parameter Learning

Start

Transition Prob

Page 36: Parameter Learning

Laser sensor Sense walls

Emission Prob

Page 37: Parameter Learning

37

Original Particles

Page 38: Parameter Learning

38

Observation

Page 39: Parameter Learning

39

Reweight…

Page 40: Parameter Learning

40

Resample + Pass Time

Page 41: Parameter Learning

41

Observation

Page 42: Parameter Learning

42

Reweight…

Page 43: Parameter Learning

43

Resample

Page 44: Parameter Learning

44

Pass Time

Page 45: Parameter Learning

45

Observation

Page 46: Parameter Learning

46

Reweight…

Page 47: Parameter Learning

47

Resample

Page 48: Parameter Learning

48

Pass Time

Page 49: Parameter Learning

49

Observation

Page 50: Parameter Learning

50

Reweight…

Page 51: Parameter Learning

51

Resample

Page 52: Parameter Learning

52

Pass Time

Page 53: Parameter Learning

53

Awesome Pants!

Page 54: Parameter Learning

Analogy One

Page 55: Parameter Learning

55

Analogy Two

Page 56: Parameter Learning

Particle Filters

A particle is a hypothetical instantiation of a variable.

Store a large number of particles.

Elapse time by moving each particle given transition probabilities.

When we get new evidence we weight each particle and create a new generation.

The density of particles for any given value is an approximation of the probability that our variable equals that value

Page 57: Parameter Learning

Previously on CS221

In Class Research

Page 58: Parameter Learning

Previously on CS221

In Class Research

Page 59: Parameter Learning

Particle Filter

Expectation Maximization

Motivating Example

Page 60: Parameter Learning

Particle Filter

Why Care?

Page 61: Parameter Learning

Live Research

Page 62: Parameter Learning

Some Education Theory

Grit,Tenacity,

Perseverance

Mindset

Gender,Ethnicity

Page 63: Parameter Learning

Some Education Theory

Grit,Tenacity,

Perseverance

Mindset

Gender,Ethnicity

Affect Grades

Page 64: Parameter Learning

Some Education Theory

Grit,Tenacity,

Perseverance

Mindset

Gender,Ethnicity

Affect Grades

Does Not Affect Grades

Page 65: Parameter Learning

Story

Page 66: Parameter Learning

Research Project

g3

t1 t2 t3

e1 e2 e3

g1 g2 b

i

?

Page 67: Parameter Learning

Research Project

g3

t1 t2 t3

e1 e2 e3

g1 g2 b

i

?

Page 68: Parameter Learning

Basic Idea

1. Chose the model that most accurately predicts our grades.

2. See where that model predicts a higher grade than was given.

Page 69: Parameter Learning

What is the best model?for s in students:

# Pretend s is not in the class.

TotalError +=

Compute grade of s given

Learn parameters p given

# Pretend we don’t know the grade of s

# See how well we did

Leave one out cross validation

Page 70: Parameter Learning

Predict Misgradesfor s in students:

# Pretend s is not in the class.

Misgrade =

Compute grade of s given

Learn parameters p given

# Pretend we don’t know the grade of s

# Did we under-grade?

Leave one out cross validation

Page 71: Parameter Learning

Novel Science

Page 72: Parameter Learning

On worst pset question+

Contest

Page 73: Parameter Learning

And?

Page 74: Parameter Learning

[suspense]

Page 75: Parameter Learning

[more suspense]

Page 76: Parameter Learning

[how…]

Page 77: Parameter Learning

[many…]

Page 78: Parameter Learning

[slides…]

Page 79: Parameter Learning

[can…]

Page 80: Parameter Learning

[he…]

Page 81: Parameter Learning

[go…]

Page 82: Parameter Learning

Simple Model

gi

ei

ti

si

Grades produce simple, observable features

Description

gi Grade on assn i

si Submit time

ti Time taken

ei Enjoyment

Page 83: Parameter Learning

My Model

Students have grit, assignments have difficulty

gi

diei grit

ti

Description

gi Grade on assn i

di Submit time

ti Time taken

ei Enjoyment

grit Overcoming ability

Page 84: Parameter Learning

My Model

Students have grit, assignments have difficulty

Page 85: Parameter Learning

Creative Model

We can predict grades based on the grades of collaborators

Page 86: Parameter Learning

Collaborators?

gb gg

Page 87: Parameter Learning

Collaborators?

gb gg

Error: cycle in bayes net!

Page 88: Parameter Learning

Collaborators?

gb gg

cbg

Warning: Large tables!

Page 89: Parameter Learning

Creative Model

We can predict grades based on the grades of collaborators

gi

ci

mi

eio si

ti

Description

gi Grade on assn i

si First submit time

ci Partner score

ei Enjoyment

ti Time

o Did optional?

mi Motivation

Page 90: Parameter Learning

Real World Problem

Formal Problem

Parameterized Model

Model the problem

Learning Algorithm

SMILE Solver

Inference Algorithm

Solution

Evaluate

Page 91: Parameter Learning

http://vimeo.com/42073764

Intermission

Page 92: Parameter Learning

Simple Model

gi

ei

ti

si

Grades produce simple, observable features

Description

gi Grade on assn i

si Submit time

ti Time taken

ei Enjoyment

Page 93: Parameter Learning

My Model

Students have grit, assignments have difficulty

gi

diei grit

ti

Description

gi Grade on assn i

di Submit time

ti Time taken

ei Enjoyment

grit Overcoming ability

Page 94: Parameter Learning

Creative Model

We can predict grades based on the grades of collaborators

gi

ci

mi

eio si

ti

Description

gi Grade on assn i

si First submit time

ci Partner score

ei Enjoyment

ti Time

o Did optional?

mi Motivation

Page 95: Parameter Learning

Real World Problem

Formal Problem

Parameterized Model

Model the problem

Learning Algorithm

SMILE Solver

Inference Algorithm

Solution

Evaluate

Page 96: Parameter Learning

SMILE Solver

Structural Modeling, Inference, and Learning Engine

Page 97: Parameter Learning

Real World Problem

Formal Problem

Parameterized Model

Model the problem

Learning Algorithm

SMILE Solver

Inference Algorithm

Solution

Evaluate

Page 98: Parameter Learning

Simple Model

gi

ei

ti

si

Grades produce simple, observable features

Description

gi Grade on assn i

si Submit time

ti Time taken

ei Enjoyment

Page 99: Parameter Learning

Lets Program!

Page 100: Parameter Learning

Learn with Hidden Vars

Page 101: Parameter Learning

Learn with Hidden Vars

Conditionalprobability

tablesValue of hidden

variables

Page 102: Parameter Learning

Learn with Hidden Vars

Conditionalprobability

tablesValue of hidden

variables

Page 103: Parameter Learning

Learn with Hidden Vars

Conditionalprobability

tablesValue of hidden

variables

Page 104: Parameter Learning

Learn with Hidden Vars

Conditionalprobability

tablesValue of hidden

variables

Page 105: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

Expectation Maximization

Page 106: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

Random Initialization

Page 107: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

EM Loop

Page 108: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

Convergence

Page 109: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

Expectation Step

Page 110: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

Maximization Step

Page 111: Parameter Learning

# Expectation Maximization# ------------------------# Solve the chicken and egg problem of guessing# model params and assignments to unobserved varsdef expectationMaximization(observed):

# Start with a random assignment params = getRandomParams()

# Until your params stop changing while not hasConverged():

# Estimate unobserved variables, given params unobserved = getBestAssn(observed, params)

# Estimate params, given unobserved params = getParams(observed, unobserved)

# You have calculated unobserved and params return params

Return

Page 112: Parameter Learning

Experimental Bias?

Blind grading.Other motivations.

Page 113: Parameter Learning

Results

Algorithm Grade Fixes

Random 0 / 10

Naïve Bayes 3 / 10

Mine 3 / 10

Creative 4 / 10

Note: The fixed grades were not mutually exclusive. Overall 6 homeworks had grading errors alleviated!

Page 114: Parameter Learning

Results

Algorithm Grade Fixes

Random 0 / 10

Naïve Bayes 3 / 10

Mine 3 / 10

Creative 4 / 10

Note: The fixed grades were not mutually exclusive. Overall 6 homeworks had grading errors alleviated!

Page 115: Parameter Learning

Creative Model

We can predict grades based on the grades of collaborators

gi

ci

mi

eio si

ti

Description

gi Grade on assn i

si First submit time

ci Partner score

ei Enjoyment

ti Time

o Did optional?

mi Motivation

Page 116: Parameter Learning

What does it mean?

Page 117: Parameter Learning

Sharma Algorithm?

Page 118: Parameter Learning

First Step

Page 119: Parameter Learning

Bette

r mod

els

Better features

Birth of a Research Problem

Page 120: Parameter Learning

Bette

r mod

els

Better features

Birth of a Research Problem

Algorithms from part 3 of

the class

Page 121: Parameter Learning

Game Theoretic?

Page 122: Parameter Learning

Ethical?

Page 123: Parameter Learning

Machine Learning

Search

Variable Based

Where We Are

Page 124: Parameter Learning

Machine Learning

Search

Variable Based

Where We Are

Page 125: Parameter Learning

Variable Based

Machine Learning

Search

Where We Are

Page 126: Parameter Learning

Search

Variable Based

Machine Learning

Where We Are

Page 127: Parameter Learning

Midpoint

Page 128: Parameter Learning

What you should know• CSP

• Formalization• Probability

• Joint distribution• Bayes Nets

• Formalization• Exact Inference• Temporal Models

• Formalization• Particle Filters

• Parameter Learning• Fully observed

Page 129: Parameter Learning

Clarify exactly what you need to know