Docsity

Bayesian Learning in Artificial Intelligence Programming - Prof. Christopher H. Brooks, Study notes of Computer Science

Partial preview of the text

Download Bayesian Learning in Artificial Intelligence Programming - Prof. Christopher H. Brooks and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence Programming

Bayesian Learning

Chris Brooks Department of Computer ScienceUniversity of San Francisco

Department of Computer Science — University of San Francisco – p. 1/

19-2: Learning and Classification^ •^

An important sort of learning problem is the

classification

problem. • This involves placing examples into one of two or more classes.^ ◦^

Should/shouldn’t get credit ◦ Categories of documents. ◦ Golf-playing/non-golf-playing days

-^ This requires access to a set of

labeled

training examples,

which allow us to induce a hypothesis that describes how todecide what class an example should be in.

Department of Computer Science — University of San Francisco – p. 2/

19-4: MAP Hypothesis^ •^

Usually, we won’t be so interested in the particular probabilitiesfor each hypothesis. • Instead, we want to know: Which hypothesis is most likely,given the data?^ ◦^

Which classification is the most probable? ◦ Is^ P layT ennis

or^

¬P layT ennis

more likely?

-^ We call this the

maximum a posteriori hypothesis

(MAP

hypothesis). • In this case, we can ignore the denominator in Bayes’ Theorem,since it will be the same for all

h.

-^ h

M AP

=^

argmax

h∈H

P^ (D

|h)P

(h)

-^ Advantages:

◦^ Simpler calculation ◦^ No need to have a prior for

P^ (

D)

Department of Computer Science — University of San Francisco – p. 4/

19-5: ML Hypothesis^ •^

In some cases, we can simplify things even further. • What are the priors

P^ (

h)^ for each hypothesis?

-^ Without any other information, we’ll often assume that they’reequally possible.

◦^ Each has probability

(^1) H

-^ In this case, we can just consider the conditional probability^ P

(D

|h).

-^ We call the hypothesis that maximizes this conditionalprobability the

maximum likelihood

hypothesis.

-^ h

M L

=^

argmax

h∈H

P^ (D

|h)

Department of Computer Science — University of San Francisco – p. 5/

19-7: Example^ •^

Let’s assume our priors for the different hypotheses are: • (0.^1

,^0.^2

,^0.^4

,^0.^2

,^0 .1)

-^ Also, we assume that the observations are i.i.d.

◦^ This means that each choice is independent of the others.(order doesn’t matter)

-^ In that case, we can multiply probabilities. •^ P

(D

|h) = Πi

P^ (j d|hj^

)i

-^ Suppose we draw 10 limes in a row.

P^ (

D|h

)^ is 3

10 , since the

probability of drawing a lime under

h^3

(^1) is 2

. Department of Computer Science — University of San Francisco – p. 7/

19-8: Example^ •^

How do the hypotheses change as data is observed? • Initially, we start with the priors:

1 ,^0

.^2 ,^0

.^4 ,^0

.^2 ,^0

-^ Then we draw a lime.

◦^ P

(h^1

|lime

αP

(lime

|h)^1

P^ (h

◦^ P

(h^2

|lime

αP

(lime

|h)^2

P^ (h

(^1) α 4

∗^0

α^0

.^05.

◦^ P

(h^3

|lime

αP

(lime

|h)^3

P^ (h

(^1) α 2

∗^0

α^0

.^2

◦^ P

(h^4

|lime

αP

(lime

|h)^4

P^ (h

(^3) α 4

∗^0

α^0

.^15.

◦^ P

(h^5

|lime

αP

(lime

|h)^5

P^ (h

α^1

∗^0

α^0

.^1.

◦^ α

Department of Computer Science — University of San Francisco – p. 8/

19-10: Bayesian Learning^ •^

Eventually, the true hypothesis will dominate all others.^ ◦^

Caveat: assuming the data is noise-free, or noise isuniformly distributed.

-^ Notice that we can use Bayesian learning (in this case) eitheras a batch algorithm or as an incremental algorithm. •^ We can always easily update our hypotheses to incorporatenew evidence.

◦^ This depends on the assumption that our observations areindependent.

Department of Computer Science — University of San Francisco – p. 10/

19-11: Learning bias^ •^

What sort of bias does Bayesian Learning use? • Typically, simpler hypotheses will have larger priors. • More complex hypotheses will fit data more exactly (but there’smany more of them).^ ◦^

Under these assumptions,

hM AP

will be the simplest

hypothesis that fits the data. ◦ This is Occam’s razor, again. ◦ Think about the deterministic case, where

P^ (

h|Di

)^ is either

1 or 0.

Department of Computer Science — University of San Francisco – p. 11/

19-13: Bayesian Optimal Classifiers^ •^

There’s one other problem with the formulation as we have it. • Usually, we’re not so interested in the hypothesis that fits thedata. • Instead, we want to classify some unseen data, given the datawe’ve seen so far. • One approach would be to just return the MAP hypothesis. • We can do better, though.

Department of Computer Science — University of San Francisco – p. 13/

19-14: Bayesian Optimal Classifiers^ •^

Suppose we have three hypotheses and posteriors: h= 0^1

.^4 , h

.^3 , h

.^3.

-^ We get a new piece of data -

h^1

says it’s positive,

h^2

and

h^3

negative. • his the MAP hypothesis, yet there’s a 0.6 chance that the data^1 is negative. • By combining weighted hypotheses, we improve ourperformance.

Department of Computer Science — University of San Francisco – p. 14/

19-16: Problems with the Bayes Optimal classifier^ •^

However, the Bayes optimal classifier is mostly interesting as atheoretical benchmark. • In practice, computing the posterior probabilities isexponentially hard. • This problem arises when instances or data are conditionallydependent upon each other. • Can we get around this?

Department of Computer Science — University of San Francisco – p. 16/

19-17: Naive Bayes classifier^ •^

The Naive Bayes classifer makes a strong assumption thatmakes the algorithm practical:^ ◦^

Each attribute of an example is independent of the others. ◦ P^ (a

∧^ b

P^ (

a)P

(b) for all a and b.

-^ This makes it straightforward to compute posteriors.

Department of Computer Science — University of San Francisco – p. 17/

19-19: Naive Bayes assumption^ •^

Naive Bayes assumes that all attributes are conditionallyindependent of each other. • In this case,

P^ (

a, a^1

, ..., a 2

|vn ) = Πi

P^ (i a|vi

).i

-^ This can be estimated from the training data. •^ The classifier then picks the class with the highest probabilityaccording to this equation. •^ Interestingly, Naive Bayes performs well even in cases wherethe conditional independence assumption fails.

Department of Computer Science — University of San Francisco – p. 19/

19-20: Example^ •^

Recall your tennis-playing problem from the decision treehomework. • We want to use the training data and a Naive Bayes classifier toclassify the following instance: • Outlook = Sunny, Temperature = Cool, Humidity = high, Wind =Strong.

Department of Computer Science — University of San Francisco – p. 20/