CS 188: Artificial Intelligence Spring 2006

Slides:



Advertisements
Similar presentations
Classification Classification Examples
Advertisements

Imbalanced data David Kauchak CS 451 – Fall 2013.
Linear Classifiers (perceptrons)
Bayes Rule How is this rule derived? Using Bayes rule for probabilistic inference: –P(Cause | Evidence): diagnostic probability –P(Evidence | Cause): causal.
CS 188: Artificial Intelligence Spring 2007 Lecture 19: Perceptrons 4/2/2007 Srini Narayanan – ICSI and UC Berkeley.
CS 188: Artificial Intelligence Fall 2009
CS 188: Artificial Intelligence Fall 2009 Lecture 23: Perceptrons 11/17/2009 Dan Klein – UC Berkeley TexPoint fonts used in EMF. Read the TexPoint manual.
Review Rong Jin. Comparison of Different Classification Models  The goal of all classifiers Predicating class label y for an input x Estimate p(y|x)
CS Bayesian Learning1 Bayesian Learning. CS Bayesian Learning2 States, causes, hypotheses. Observations, effect, data. We need to reconcile.
Crash Course on Machine Learning
Classification III Tamara Berg CS Artificial Intelligence Many slides throughout the course adapted from Svetlana Lazebnik, Dan Klein, Stuart Russell,
More Machine Learning Linear Regression Squared Error L1 and L2 Regularization Gradient Descent.
Made by: Maor Levy, Temple University  Up until now: how to reason in a give model  Machine learning: how to acquire a model on the basis of.
CS 188: Artificial Intelligence Spring 2007 Lecture 18: Classification: Part I Naïve Bayes 03/22/2007 Srini Narayanan – ICSI and UC Berkeley.
8/25/05 Cognitive Computations Software Tutorial Page 1 SNoW: Sparse Network of Winnows Presented by Nick Rizzolo.
1 CS546: Machine Learning and Natural Language Discriminative vs Generative Classifiers This lecture is based on (Ng & Jordan, 02) paper and some slides.
CSE 446 Perceptron Learning Winter 2012 Dan Weld Some slides from Carlos Guestrin, Luke Zettlemoyer.
Classification: Feature Vectors
LOGISTIC REGRESSION David Kauchak CS451 – Fall 2013.
CS 188: Artificial Intelligence Spring 2006 Lecture 9: Naïve Bayes 2/14/2006 Dan Klein – UC Berkeley Many slides from either Stuart Russell or Andrew Moore.
Empirical Research Methods in Computer Science Lecture 7 November 30, 2005 Noah Smith.
Naïve Bayes Classifier Ke Chen Modified and extended by Longin Jan Latecki
CSE 473: Artificial Intelligence Spring 2012 Bayesian Networks - Learning Dan Weld Slides adapted from Jack Breese, Dan Klein, Daphne Koller, Stuart Russell,
Machine Learning CUNY Graduate Center Lecture 4: Logistic Regression.
Machine Learning  Up until now: how to reason in a model and how to make optimal decisions  Machine learning: how to acquire a model on the basis of.
CHAPTER 6 Naive Bayes Models for Classification. QUESTION????
CSE 473: Artificial Intelligence Autumn 2010 Machine Learning: Naive Bayes and Perceptron Luke Zettlemoyer Many slides over the course adapted from Dan.
Announcements  Project 5  Due Friday 4/10 at 5pm  Homework 9  Released soon, due Monday 4/13 at 11:59pm.
CS 188: Artificial Intelligence Spring 2006 Lecture 12: Learning Theory 2/23/2006 Dan Klein – UC Berkeley Many slides from either Stuart Russell or Andrew.
Recap: General Naïve Bayes  A general naïve Bayes model:  Y: label to be predicted  F 1, …, F n : features of each instance Y F1F1 FnFn F2F2 This slide.
CS 188: Artificial Intelligence Fall 2007 Lecture 25: Kernels 11/27/2007 Dan Klein – UC Berkeley.
CSE 446 Logistic Regression Perceptron Learning Winter 2012 Dan Weld Some slides from Carlos Guestrin, Luke Zettlemoyer.
CS 188: Artificial Intelligence Fall 2008 Lecture 24: Perceptrons II 11/24/2008 Dan Klein – UC Berkeley 1.
Naïve Bayes Classification Recitation, 1/25/07 Jonathan Huang.
LEARNING FROM EXAMPLES AIMA CHAPTER 18 (4-5) CSE 537 Spring 2014 Instructor: Sael Lee Slides are mostly made from AIMA resources, Andrew W. Moore’s tutorials:
CAP 5636 – Advanced Artificial Intelligence
Evaluating Classifiers
Probability David Kauchak CS158 – Fall 2013.
Fun with Hyperplanes: Perceptrons, SVMs, and Friends
Artificial Intelligence
Naïve Bayes Classifiers
MIRA, SVM, k-NN Lirong Xia. MIRA, SVM, k-NN Lirong Xia.
CS 188: Artificial Intelligence Fall 2006
Artificial Intelligence
Perceptrons Lirong Xia.
ECE 5424: Introduction to Machine Learning
CS 188: Artificial Intelligence Fall 2008
CS 188: Artificial Intelligence Fall 2008
CS 188: Artificial Intelligence
CS 4/527: Artificial Intelligence
CS 188: Artificial Intelligence
CHAPTER 7 BAYESIAN NETWORK INDEPENDENCE BAYESIAN NETWORK INFERENCE MACHINE LEARNING ISSUES.
CS 188: Artificial Intelligence Fall 2007
Naïve Bayes Classifiers
CS 188: Artificial Intelligence Fall 2008
Speech recognition, machine learning
Artificial Intelligence 9. Perceptron
CS 188: Artificial Intelligence
CS 188: Artificial Intelligence Spring 2006
CS 188: Artificial Intelligence Fall 2007
Evaluating Classifiers
CS 188: Artificial Intelligence Spring 2006
Naïve Bayes Classifiers
MIRA, SVM, k-NN Lirong Xia. MIRA, SVM, k-NN Lirong Xia.
Perceptrons Lirong Xia.
Support Vector Machines 2
Speech recognition, machine learning
Naïve Bayes Classifier
Evaluation David Kauchak CS 158 – Fall 2019.
Presentation transcript:

CS 188: Artificial Intelligence Spring 2006 Lecture 10: Perceptrons 2/16/2006 Dan Klein – UC Berkeley Many slides from either Stuart Russell or Andrew Moore

Announcements Office hours: Project 2: Out now Dan’s W 3-5 office hours moved to F 3-5 (just this week) Project 2: Out now Written 1 back (check in front) Fill in your final exam time surveys! (in front)

Today Naïve Bayes models Perceptrons Smoothing Real world issues Mistake-driven learning Data separation, margins, and convergence

General Naïve Bayes This is an example of a naive Bayes model: Total number of parameters is linear in n! C E1 E2 En

Example: Spam Filtering Model: Parameters: ham : 0.66 spam: 0.33 the : 0.016 to : 0.015 and : 0.012 ... free : 0.001 click : 0.001 morally : 0.001 nicely : 0.001 the : 0.021 to : 0.013 and : 0.011 ... free : 0.005 click : 0.004 screens : 0.000 minute : 0.000

Estimation: Laplace Smoothing Laplace’s estimate: Pretend you saw every outcome once more than you actually did Can derive this as a maximum a posteriori estimate using Dirichlet priors (see cs281a) H H T

Estimation: Laplace Smoothing Laplace’s estimate (extended): Pretend you saw every outcome k extra times What’s Laplace with k = 0? k is the strength of the prior Laplace for conditionals: Smooth each condition independently: H H T

Estimation: Linear Interpolation In practice, Laplace often performs poorly for P(X|Y): When |X| is very large When |Y| is very large Another option: linear interpolation Get unconditional P(X) from the data Make sure the estimate of P(X|Y) isn’t too different from P(X) What if  is 0? 1? For even better ways to estimate parameters, as well as details of the math see cs281a, cs294-5

Real NB: Smoothing For real classification problems, smoothing is critical … and usually done badly, even in big commercial systems New odds ratios: helvetica : 11.4 seems : 10.8 group : 10.2 ago : 8.4 areas : 8.3 ... verdana : 28.8 credit : 28.4 order : 27.2 <font> : 26.9 money : 26.5 ... Do these make more sense?

Tuning on Held-Out Data Now we’ve got two kinds of unknowns Parameters: the probabilities P(Y|X), P(Y) Hyper-parameters, like the amount of smoothing to do: k,  Where to learn? Learn parameters from training data Must tune hyper-parameters on different data Why? For each value of the hyper-parameters, train and test on the held-out data Choose the best value and do a final test on the test data

Spam Example P(spam | w) = 0.989 Word P(w|spam) P(w|ham) Tot Spam Tot Ham (prior) 0.33333 0.66666 -1.1 -0.4 Gary 0.00002 0.00021 -11.8 -8.9 would 0.00069 0.00084 -19.1 -16.0 you 0.00881 0.00304 -23.8 -21.8 like 0.00086 0.00083 -30.9 -28.9 to 0.01517 0.01339 -35.1 -33.2 lose 0.00008 -44.5 -44.0 weight 0.00016 -53.3 -55.0 while 0.00027 -61.5 -63.2 -66.2 -69.0 sleep 0.00006 0.00001 -76.0 -80.5 P(spam | w) = 0.989

Confidences from a Classifier The confidence of a probabilistic classifier: Posterior over the top label Represents how sure the classifier is of the classification Any probabilistic model will have confidences No guarantee confidence is correct Calibration Weak calibration: higher confidences mean higher accuracy Strong calibration: confidence predicts accuracy rate What’s the value of calibration?

Precision vs. Recall - Let’s say we want to classify web pages as homepages or not In a test set of 1K pages, there are 3 homepages Our classifier says they are all non-homepages 99.7 accuracy! Need new measures for rare positive events Precision: fraction of guessed positives which were actually positive Recall: fraction of actual positives which were guessed as positive Say we guess 5 homepages, of which 2 were actually homepages Precision: 2 correct / 5 guessed = 0.4 Recall: 2 correct / 3 true = 0.67 Which is more important in customer support email automation? Which is more important in airport face recognition? actual + guessed +

Precision vs. Recall Precision/recall tradeoff Often, you can trade off precision and recall Only works well with weakly calibrated classifiers To summarize the tradeoff: Break-even point: precision value when p = r F-measure: harmonic mean of p and r:

Errors, and What to Do Examples of errors 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 . . .

What to Do About Errors? Need more features– words aren’t enough! 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? Naïve Bayes models can incorporate a variety of features, but tend to do best in homogeneous cases (e.g. all features are word occurrences)

Features A feature is a function which signals a property of the input Examples: ALL_CAPS: value is 1 iff email in all caps HAS_URL: value is 1 iff email has a URL NUM_URLS: number of URLs in email VERY_LONG: 1 iff email is longer than 1K SUSPICIOUS_SENDER: 1 iff reply-to domain doesn’t match originating server Features are anything you can think of code to evaluate on an input Some cheap, some very very expensive to calculate Can even be the output of another classifier Domain knowledge goes here! In naïve Bayes, how did we encode features?

Feature Extractors A feature extractor maps inputs to feature vectors Many classifiers take feature vectors as inputs Feature vectors usually very sparse, use sparse encodings (i.e. only represent non-zero keys) 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. … W=dear : 1 W=sir : 1 W=this : 2 ... W=wish : 0 MISSPELLED : 2 NAMELESS : 1 ALL_CAPS : 0 NUM_URLS : 0

Generative vs. Discriminative Generative classifiers: E.g. naïve Bayes We build a causal model of the variables We then query that model for causes, given evidence Discriminative classifiers: E.g. perceptron (next) No causal model, no Bayes rule, often no probabilities Try to predict output directly Loosely: mistake driven rather than model driven

Some (Vague) Biology Very loose inspiration: human neurons

The Binary Perceptron  Inputs are features Each feature has a weight Sum is the activation If the activation is: Positive, output 1 Negative, output 0 w1  f1 w2 >0? f2 w3 f3

Example: Spam Imagine 4 features: Free (number of occurrences of “free”) Money (occurrences of “money”) BIAS (always has value 1) BIAS : 1 free : 1 money : 1 the : 0 ... BIAS : -3 free : 4 money : 2 the : 0 ... “free money”

Binary Decision Rule In the space of feature vectors Any weight vector is a hyperplane One side will be class 1 Other will be class 0 money 2 1 = SPAM 1 BIAS : -3 free : 4 money : 2 the : 0 ... 0 = HAM 1 free

The Multiclass Perceptron If we have more than two classes: Have a weight vector for each class Calculate an activation for each class Highest activation wins

Example “win the vote” BIAS : 1 win : 1 game : 0 vote : 1 the : 1 ...

The Perceptron Update Rule Start with zero weights Pick up training instances one by one Try to classify If correct, no change! If wrong: lower score of wrong answer, raise score of right answer

Example “win the vote” “win the election” “win the game” BIAS : win : ... BIAS : win : game : vote : the : ... BIAS : win : game : vote : the : ...

Mistake-Driven Classification In naïve Bayes, parameters: From data statistics Have a causal interpretation One pass through the data For the perceptron parameters: From reactions to mistakes Have a discriminative interpretation Go through the data until held-out accuracy maxes out Training Data Held-Out Data Test Data

Properties of Perceptrons Separable Separability: some parameters get the training set perfectly correct Convergence: if the training is separable, perceptron will eventually converge (binary case) Mistake Bound: the maximum number of mistakes (binary case) related to the margin or degree of separability Non-Separable

Issues with Perceptrons Overtraining: test / held-out accuracy usually rises, then falls Overtraining isn’t quite as bad as overfitting, but is similar Regularization: if the data isn’t separable, weights might thrash around Averaging weight vectors over time can help (averaged perceptron) Mediocre generalization: finds a “barely” separating solution

Summary Naïve Bayes Perceptrons: Build classifiers using model of training data Smoothing estimates is important in real systems Classifier confidences are useful, when you can get them Perceptrons: Make less assumptions about data Mistake-driven learning Multiple passes through data