Docsity

Bayesian Learning & Classification with AI: MAP & ML Hypotheses, Study notes of Computer Science

Partial preview of the text

Download Bayesian Learning & Classification with AI: MAP & ML Hypotheses and more Study notes Computer Science in PDF only on Docsity!

Artificial Intelligence

Programming Bayesian Learning

Chris Brooks Department of Computer Science University of San Francisco

Learning and Classification

An important sort of learning problem is the classification

problem.

This involves placing examples into one of two or moreclasses.

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 thatdescribes how to decide what class an example shouldbe in.

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

MAP Hypothesis

Usually, we won’t be so interested in the particularprobabilities for each hypothesis. Instead, we want to know: Which hypothesis is mostlikely, 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

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

MAP Hypothesis

Advantages:

Simpler calculation No need to have a prior for

P

D

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

Example

Imagine that we have a large bag of candy. We want toknow the ratio of cherry to lime in the bag. We start with 5 hypotheses:1.

h 1

: 100% cherry

h 2

75% cherry, 25% lime.

h 3

50% cherry, 50% lime

h 4

25% cherry, 75% lime

h 5

100% lime

Our agent repeatedly draws pieces of candy. We want it to correctly pick the type of the next piece ofcandy.

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

Example

Let’s assume our priors for the different hypotheses are: (

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

This means that each choice is independent of theothers. (order doesn’t matter)

In that case, we can multiply probabilities. P

D

h i

j

P

d j

h i

Suppose we draw 10 limes in a row.

P

D

h 3

is

1 2

10

since the probability of drawing a lime under

h 3

is

1 2

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

Example

Then we draw a second lime.

P

h 1

lime, lime

αP

lime, lime

h 1

P

h 1

P

h 2

lime, lime

αP

lime, lime

h 2

P

h 2

α 1 4 1 4

α

P

h 3

lime, lime

αP

lime, lime

h 3

P

h 3

α 1 2 1 2

α

P

h 4

lime, lime

αP

lime, lime

h 4

P

h 4

α 3 4 3 4

α

P

h 5

lime

αP

lime

h 5

P

h 5

α

α

α

Strictly speaking, we don’t really care what

α

is.

We can just select the MAP hypothesis, since we justwant to know the most likely hypothesis.

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

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)either as a batch algorithm or as an incrementalalgorithm. We can always easily update our hypotheses toincorporate new evidence.

This depends on the assumption that ourobservations are independent.

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

Bayesian Concept Learning

Bayesian Learning involves estimating the likelihood ofeach hypothesis. In a more complex world where observations are notindependent, this could be difficult. Our first cut at doing this might be a brute forceapproach:1. For each

h

in

H

, calculate

P

h

D

P ( D |h ) P ( h ) P ( D )

2. From this, output the hypothesis

h M AP

with the

highest posterior probability.

This is what we did in the example.

Challenge - Bayes’ Theorem can be computationallyexpensive to use when observations are not i.i.d. P

h

o 1 , o 2

P ( o 1 |h,o 2 ) P ( h | o 2 ) P ( o 1 |o 2 ) Department of Computer Science — University of San Francisco – p.12/

Bayesian Optimal Classifiers

There’s one other problem with the formulation as wehave it. Usually, we’re not so interested in the hypothesis that fitsthe data. Instead, we want to classify some unseen data, giventhe data we’ve seen so far. One approach would be to just return the MAPhypothesis. We can do better, though.

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

Bayesian Optimal Classifiers

By combining the predictions of each hypothesis, we geta Bayesian optimal classifier. More formally, let’s say our unseen data belongs to oneof

v

classes.

The probability

P

v j

D

that our new instance belongs to

class

v j

is:

h i ∈ H

P

v j

h i

P

h i

D

Intuitively, each hypothesis gives its prediction, weightedby the likelihood that that hypothesis is the correct one. This classification method is provably optimal - onaverage, no other algorithm can perform better.

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

Problems with the Bayes Optimal clas

However, the Bayes optimal classifier is mostlyinteresting as a theoretical benchmark. In practice, computing the posterior probabilities isexponentially hard. This problem arises when instances or data areconditionally dependent upon each other. Can we get around this?

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

The Bayesian Learning Problem

Given: a set of labeled, multivalued examples. Find a function

F

x

that correctly classifies an unseen

example with attributes

a 1 , a 2 , ..., a n

Call the most probable category

v map

v map

argmax v i ∈ V

P

v i

a 1 , a 2 , ..., a n

We rewrite this with Bayes’ Theorem as: v

map

argmax v i ∈ V

P

a 1 , a 2 , ..., a n

v i

P

v i

Estimating

P

v i

is straightforward with a large training

set; count the fraction of the set that are of class

v i

However, estimating

P

a 1 , a 2 , ..., a n

v i

is difficult unless

our training set is

very

large. We need to see every

possible attribute combination many times.

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

Naive Bayes assumption

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

P

a 1 , a 2 , ..., a n

v i

i

P

a i

v i

This can be estimated from the training data. The classifier then picks the class with the highestprobability according to this equation. Interestingly, Naive Bayes performs well even in caseswhere the conditional independence assumption fails.

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