





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















Artificial Intelligence Programming
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
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
|h)P
(h)
-^ Advantages:
◦^ Simpler calculation ◦^ No need to have a prior for
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
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
|h).
-^ We call the hypothesis that maximizes this conditionalprobability the
maximum likelihood
hypothesis.
-^ h
M L
argmax
h∈H
|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
-^ 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
|h) = Πi
P^ (j d|hj^
)i
-^ Suppose we draw 10 limes in a row.
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:
-^ Then we draw a lime.
(h^1
|lime
αP
(lime
|h)^1
P^ (h
(h^2
|lime
αP
(lime
|h)^2
P^ (h
(^1) α 4
α^0
(h^3
|lime
αP
(lime
|h)^3
P^ (h
(^1) α 2
α^0
(h^4
|lime
αP
(lime
|h)^4
P^ (h
(^3) α 4
α^0
(h^5
|lime
αP
(lime
|h)^5
P^ (h
α^1
α^0
◦^ α
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
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
-^ 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
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,
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/