













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
All CS188 materials are available at http://ai.berkeley.edu.] Machine Learning. ▫ Up until now: how use a model to make optimal decisions.
Typology: Lecture notes
1 / 21
This page cannot be seen from the preview
Don't miss anything!














[These slides were created by Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188 materials are available at http://ai.berkeley.edu.]
Get a large collection of example emails, each labeled “spam” or “ham” Note: someone has to hand label all this data! Want to learn to predict labels of new, future emails
Words: FREE! Text Patterns: $dd, CAPS Non-text: SenderInContacts, WidelyBroadcast … Dear 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 ADDRESSES FOR ONLY $ Ok, 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.
One feature (variable) Fij for each grid position <i,j> Feature values are on / off, based on whether intensity is more or less than 0.5 in underlying image Each input maps to a feature vector, e.g. Here: lots of features, each is binary valued
Y F 1 F 2 Fn
Y F 1 F 2 Fn |Y| parameters n x |F| x |Y| parameters |Y| x |F|n^ values
1 0. 2 0. 3 0. 4 0. 5 0. 6 0. 7 0. 8 0. 9 0. 0 0. 1 0. 2 0. 3 0. 4 0. 5 0. 6 0. 7 0. 8 0. 9 0. 0 0. 1 0. 2 0. 3 0. 4 0. 5 0. 6 0. 7 0. 8 0. 9 0. 0 0.
Features: Wi is the word at position i As before: predict label conditioned on feature variables (spam vs. ham) As before: assume features are conditionally independent given label New: each Wi is identically distributed
Usually, each variable gets its own conditional probability distribution P(F|Y) In a bag-of-words model Each position is identically distributed All positions share the same conditional probs P(W|Y) Why make this assumption? Called “bag-of-words” because model is insensitive to word order or reordering Word at position i, not ith^ word in the dictionary!
Model: What are the parameters?
- the : 0. Where do these tables come from? - to : 0. - and : 0. - of : 0. - you : 0. - a : 0. - with: 0. - from: 0. - the : 0. - to : 0. - of : 0. - 2002: 0. - with: 0. - from: 0. - and : 0. - a : 0. Data: labeled instances (e.g. emails marked spam/ham) Training set Held out set Test set Features: attribute-value pairs which characterize each x Experimentation cycle Learn parameters (e.g. model probabilities) on training set (Tune hyperparameters on held-out set) Compute accuracy of test set Very important: never “peek” at the test set! Evaluation (many metrics possible, e.g. accuracy) 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 lectures Training Data Held-Out Data Test Data
E.g.: for each outcome x, look at the empirical rate of that value: This is the estimate that maximizes the likelihood of the data r r b r b b b r b b b^ r r (^) b b r b b
Pretend you saw every outcome k extra times What’s Laplace with k = 0? k is the strength of the prior
Smooth each condition independently:
When |X| is very large When |Y| is very large
Also get the empirical P(X) from the data Make sure the estimate of P(X|Y) isn’t too different from the empirical P(X)
helvetica : 11. seems : 10. group : 10. ago : 8. areas : 8. ... verdana : 28. Credit : 28. ORDER : 27. : 26. money : 26. ...
Dear GlobalSCAPE Customer, GlobalSCAPE has partnered with ScanSoft to offer you the latest version of OmniPage Pro, for just $99.99* - the regular list price is $499! The most common question we've received about this offer is - Is this genuine? We would like to assure you that this offer is authorized by ScanSoft, is genuine and valid. You can get the...
... To receive your $30 Amazon.com promotional certificate, click through to http://www.amazon.com/apparel and see the prominent link for the $30 offer. All details are there. We hope you enjoyed receiving this message. However, if you'd rather not receive future e-mails announcing new store launches, please click...
Have you emailed the sender before? Have 1K other people just gotten the same email? Is the sending information consistent? Is the email in ALL CAPS? Do inline URLs point where they say they point? Does the email address you by (your) name?
Baselines are very simple “straw man” procedures Help determine how hard the task is Help know what a “good” accuracy is
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 E.g. calling everything “ham” gets 66%, so a classifier that gets 70% isn’t very good…
Posterior probability of the top label Represents how sure the classifier is of the classification Any probabilistic model will have confidences No guarantee confidence is correct
Weak calibration: higher confidences mean higher accuracy Strong calibration: confidence predicts accuracy rate What’s the value of calibration?