DOC PREVIEW
Berkeley COMPSCI 188 - Lecture 9: Naïve Bayes

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CS 188: Artificial IntelligenceSpring 2006Lecture 9: Naïve Bayes2/14/2006Dan Klein – UC BerkeleyMany slides from either Stuart Russell or Andrew Moore Today Bayes’ rule Expectations and utilities Naïve Bayes models Classification Parameter estimation Real world issuesBayes’ Rule Two ways to factor a joint distribution over two variables: Dividing, we get: Why is this at all helpful? Lets us invert a conditional distribution Often the one conditional is tricky but the other simple Foundation of many systems we’ll see later (e.g. ASR, MT) In the running for most important AI equation!That’s my rule!More Bayes’ Rule Diagnostic probability from causal probability: Example: m is meningitis, s is stiff neck Note: posterior probability of meningitis still very small Does this mean you should ignore a stiff neck?Expectations Real valued functions of random variables: Expectation of a function a random variable according to a distribution over the same variable Example: Expected value of a fair die roll21/6211/6141/6431/631/61/6P65f65XUtilities Preview of utility theory (much more later) Utilities: A utility or reward is a function from events to real numbers E.g. using a certain airport plan and getting there on time We often talk about actions having expected utilities in a given state The rational action is the one which maximizes expected utility This depends on (1) the probability and (2) the magnitude of the outcomes2Example: Plane Plans How early to leave? Why might agents make different decisions? Different rewards Different evidence Different beliefs (different models) We’ll use the principle of maximum expected utility for classification, decision networks, reinforcement learning…Combining Evidence What if there are multiple effects? E.g. diagnosis with two symptoms Meningitis, stiff neck, feverMS Fdirect estimateBayes estimate (no assumptions)Conditional independence+General Naïve Bayes This is an example of a naive Bayes model: Total number of parameters is linear in n!CE1EnE2|C| parametersn x |E| x |C| parameters|C| x |E|nparametersInference for Naïve Bayes Getting posteriors over causes Step 1: get joint probability of causes and evidence Step 2: get probability of evidence Step 3: renormalize+General Naïve Bayes What do we need in order to use naïve Bayes? Some code to do the inference For fixed evidence, build P(C,e) Sum out C to get P(e) Divide to get P(C|e) Estimates of local conditional probability tables (CPTs) P(C), the prior over causes P(E|C) for each evidence variable These typically come from observed data These probabilities are collectively called the parameters of the model and denoted by θParameter Estimation Estimating the distribution of a random variable X or X|Y? Empirically: collect data For each value x, look at the empirical rate of that value: This estimate maximizes the likelihood of the data (see homework) Elicitation: ask a human! Usually need domain experts, and sophisticated ways of elicitingprobabilities (e.g. betting games) Trouble calibratingr g g3Classification Data: labeled instances, e.g. emails marked spam/ham Training set Held out set Test set Experimentation Learn model parameters (probabilities) on training set (Tune performance on held-out set) Run a single test on the test set Very important: never “peek” at the test set! Evaluation Accuracy: fraction of instances predicted correctly Overfitting and generalization Want a classifier which does well on test data Overfitting: fitting the training data very closely, but not generalizing well We’ll investigate overfitting and generalization formally in a few lecturesTrainingDataHeld-OutDataTestDataA Spam Filter Running example: naïve Bayes spam filter Data: Collection of emails, labeled spam or ham Note: someone has to hand label all this data! Split into training, held-out, test sets Classifiers Learn a model on the training set Tune it on the held-out set Test it on new emails in the test setDear Sir.First, I must solicit your confidence in this transaction, this is by virture of its nature as being utterly confidencial and top secret. …TO BE REMOVED FROM FUTURE MAILINGS, SIMPLY REPLY TO THIS MESSAGE AND PUT "REMOVE" IN THE SUBJECT.99 MILLION EMAIL ADDRESSESFOR ONLY $99Ok, Iknow this is blatantly OT but I'm beginning to go insane. Had an old Dell Dimension XPS sitting in the corner and decided to put it to use, I know it was working pre being stuck in the corner, but when I plugged it in, hit the power nothing happened.Baselines First task: get a baseline Baselines are very simple “straw man” procedures Help determine how hard the task is Help know what a “good” accuracy is Weak baseline: most frequent label classifier Gives all test instances whatever label was most common in the training set E.g. for spam filtering, might label everything as ham Accuracy might be very high if the problem is skewed For real research, usually use previous work as a (strong) baselineNaïve Bayes for Text Naïve Bayes: Predict unknown cause (spam vs. ham) Independent evidence from observed variables (e.g. the words) Generative model* Tied distributions and bag-of-words Usually, each variable gets its own conditional probability distribution In a bag-of-words model Each position is identically distributed All share the same distributions Why make this assumption?*Minor detail: technically we’re conditioning on the length of the document hereExample: Spam Filtering Model: What are the parameters? Where do these tables come from?the : 0.0156to : 0.0153and : 0.0115of : 0.0095you : 0.0093a : 0.0086with: 0.0080from: 0.0075...the : 0.0210to : 0.0133of : 0.01192002: 0.0110with: 0.0108from: 0.0107and : 0.0105a : 0.0100...ham : 0.63spam: 0.37Example: Spam Filtering Raw probabilities don’t affect the posteriors; relative probabilities (odds ratios) do:south-west : infnation : infmorally : infnicely : infextent : infseriously : inf...What went wrong here?screens : infminute : infguaranteed : inf$205.00 : infdelivery : infsignature : inf...4Generalization and Overfitting These parameters will overfit


View Full Document

Berkeley COMPSCI 188 - Lecture 9: Naïve Bayes

Documents in this Course
CSP

CSP

42 pages

Metrics

Metrics

4 pages

HMMs II

HMMs II

19 pages

NLP

NLP

23 pages

Midterm

Midterm

9 pages

Agents

Agents

8 pages

Lecture 4

Lecture 4

53 pages

CSPs

CSPs

16 pages

Midterm

Midterm

6 pages

MDPs

MDPs

20 pages

mdps

mdps

2 pages

Games II

Games II

18 pages

Load more
Download Lecture 9: Naïve Bayes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 9: Naïve Bayes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 9: Naïve Bayes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?