MLE, MAP, AND NAIVE BAYES 10-601 RECITATION MARY MCGLOHON MLE The - - PowerPoint PPT Presentation

mle map and naive bayes
SMART_READER_LITE
LIVE PREVIEW

MLE, MAP, AND NAIVE BAYES 10-601 RECITATION MARY MCGLOHON MLE The - - PowerPoint PPT Presentation

MLE, MAP, AND NAIVE BAYES 10-601 RECITATION MARY MCGLOHON MLE The usual representation we come across is a P ( X = x | ) probability density function: x 1 , x 2 , ..., x n N ( , 2 ) But what if we know that


slide-1
SLIDE 1

MLE, MAP, AND NAIVE BAYES

10-601 RECITATION MARY MCGLOHON

slide-2
SLIDE 2

MLE

The usual representation we come across is a probability density function: But what if we know that , but we don’t know ? We can set up a likelihood equation: , and find the value of that maximizes it. P(X = x|θ) x1, x2, ..., xn ∼ N(µ, σ2) µ µ P(x|µ, σ)

slide-3
SLIDE 3

MLE OF MU

Since x’s are independent and from the same distribution, Taking the log likelihood (we get to do this since log is monotonic) and removing some constants: p(x|µ, σ2) =

n

  • i=1

p(xi|µ, σ2) L(x) =

n

  • i=1

p(xi|µ, σ2) = 1 √ 2πσ2

n

  • i=1

exp((xi − µ)2 2σ2 ) log(L(x)) = l(x) ∝

n

  • i=1

−(xi − µ)

  • 2
slide-4
SLIDE 4

CALCULUS!

We can take the derivative of this value and set it equal to zero, to maximize. dl(x) dx = d dx(−

n

  • i=1

x2

i − xiµ + µ2) = − n

  • i=1

xi − µ −

n

  • i=1

xi − µ = 0 → nµ =

n

  • i=1

xi → µ = n

i=1 xi

n

slide-5
SLIDE 5

ABOUT THE MLE

We can’t always do this analytically, but there are all sorts of tricks. (See homework). This is the traditional statistical approach to finding parameters. (The Unbiased M.L.E.)

slide-6
SLIDE 6

ABOUT THE MLE

We can’t always do this analytically, but there are all sorts of tricks. (See homework). This is the traditional statistical approach to finding parameters. (The Unbiased M.L.E.)

slide-7
SLIDE 7

MAP

What if you have some ideas about your parameter? In the Bayesian school of thought (or “cult”, depending

  • n who you ask)...

We can use Bayes’ Rule: P(θ|x) = P(x|θ)P(θ) P(x) = P(x|θ)P(θ)

  • Θ P(θ, x) =

P(x|θ)P(θ)

  • Θ P(x|θ)P(θ)
slide-8
SLIDE 8

MAP

This is just maximizing the numerator, since the denominator is a normalizing constant. This assumes a prior distribution, . Old-school statisticians hate that. But if you get a good estimate of the prior, you’ll probably be ok.

(This is why we don’t have old-school statisticians writing spam filters.)

argmaxθP(θ|x) = argmaxθ P(x|θ)P(θ)

  • Θ P(x|θ)P(θ)

(Emcee M.C.) P(θ)

slide-9
SLIDE 9

MAP

This is just maximizing the numerator, since the denominator is a normalizing constant. This assumes a prior distribution, . Old-school statisticians hate that. But if you get a good estimate of the prior, you’ll probably be ok.

(This is why we don’t have old-school statisticians writing spam filters.)

argmaxθP(θ|x) = argmaxθ P(x|θ)P(θ)

  • Θ P(x|θ)P(θ)

(Emcee M.C.) P(θ)

slide-10
SLIDE 10

WHAT WE CAN DO NOW

MAP is the foundation for Naive Bayes classifiers. Here, we’re assuming our data are drawn from two “classes”. We have a bunch of data where we know the class, and want to be able to predict P(class|data-point). So, we use empirical probabilities In NB, we also make the assumption that the features are conditionally independent.

prediction = argmaxCP(C = c|X = x) ∝ argmaxC ˆ P(X = x|C = c) ˆ P(C = c)

slide-11
SLIDE 11

SPAM FILTERING

Suppose we wanted to build a spam filter. To use the “bag of words” approach, assuming that n words in an email are conditionally independent, we’d get: Whichever one’s bigger wins! P(spam|w) ∝

n

  • i=1

P(wi|spam)P(spam) P(¬spam|w) ∝

n

  • i=1

P(wi|¬spam)P(¬spam) ^ ^ ^ ^

slide-12
SLIDE 12

THE IMPORTANCE OF THE SAMPLE

What happens if you train on a set of data that’s mostly spam, and test on a set that’s mostly good emails? Also, just choosing one test set “wastes data”. What can we do? P(spam|w) ∝

n

  • i=1

P(wi|spam)P(spam) ^ ^

slide-13
SLIDE 13

CROSS-VALIDATION

Cross-validation involves training several times. LOOCV (Leave-one-out cross validation): For each data point, train classifier on -- that is, all data points besides , and classify . Error is the average accuracy. What’s wrong with this? x−i xi

xi

slide-14
SLIDE 14

K-FOLDS CV

A cheaper way of doing cross-validation is to divide (“fold”) the dataset into k pieces. For each piece i, Train on all data not in set i, classify set i. Report mean error. This is a “happy medium” between straight-up training/ testing and LOOCV.

slide-15
SLIDE 15

LESS-NAIVE BAYES

How would we modify NB to use two dependent attributes? Hint: -- you’re estimating the joint conditional distribution of the attributes. P(xi|c) = P(xi,1, xi,2, ..., xi,A|c)

slide-16
SLIDE 16

CONTINUOUSLY NAIVE BAYES

How could we modify NB for continuous attributes? For instance, classify whether you like basketball given your age (real), height (real), whether you like football (binary), and type of shoes you wear (categorical).

slide-17
SLIDE 17

TOPOLOGY OF NAIVE BAYES

What’s the decision surface for Naive Bayes? Hint: P(c|word) = P(word|c)I(word) + P(¬word|c)I(¬word)