Classification II: Decision Trees and SVMs

Similar documents
Decision Trees. Data Science: Jordan Boyd-Graber University of Maryland MARCH 11, Data Science: Jordan Boyd-Graber UMD Decision Trees 1 / 1

Support Vector Machines

Introduction to Machine Learning

Machine Learning: Chenhao Tan University of Colorado Boulder LECTURE 9

Clustering. Introduction to Data Science. Jordan Boyd-Graber and Michael Paul SLIDES ADAPTED FROM LAUREN HANNAH

Decision Tree Learning Mitchell, Chapter 3. CptS 570 Machine Learning School of EECS Washington State University

Decision-Tree Learning. Chapter 3: Decision Tree Learning. Classification Learning. Decision Tree for PlayTennis

CS6375: Machine Learning Gautam Kunapuli. Decision Trees

Decision Trees.

Chapter 3: Decision Tree Learning

Decision Trees.

Decision Tree Learning

CS 6375 Machine Learning

Lecture 3: Decision Trees

Machine Learning 2nd Edi7on

Lecture 3: Decision Trees

Question of the Day. Machine Learning 2D1431. Decision Tree for PlayTennis. Outline. Lecture 4: Decision Tree Learning

Outline. Training Examples for EnjoySport. 2 lecture slides for textbook Machine Learning, c Tom M. Mitchell, McGraw Hill, 1997

Decision Tree Learning

Learning Decision Trees

Supervised Learning! Algorithm Implementations! Inferring Rudimentary Rules and Decision Trees!

Administration. Chapter 3: Decision Tree Learning (part 2) Measuring Entropy. Entropy Function

Lecture 24: Other (Non-linear) Classifiers: Decision Tree Learning, Boosting, and Support Vector Classification Instructor: Prof. Ganesh Ramakrishnan

Decision Trees. Tirgul 5

Introduction to ML. Two examples of Learners: Naïve Bayesian Classifiers Decision Trees

Introduction. Decision Tree Learning. Outline. Decision Tree 9/7/2017. Decision Tree Definition

CSCE 478/878 Lecture 6: Bayesian Learning

Learning Decision Trees

Learning Classification Trees. Sargur Srihari

the tree till a class assignment is reached

Decision trees. Special Course in Computer and Information Science II. Adam Gyenge Helsinki University of Technology

Introduction Association Rule Mining Decision Trees Summary. SMLO12: Data Mining. Statistical Machine Learning Overview.

Decision Tree Learning - ID3

Chapter 6: Classification

Decision Tree Learning and Inductive Inference

Classification and Regression Trees

Chapter 3: Decision Tree Learning (part 2)

M chi h n i e n L e L arni n n i g Decision Trees Mac a h c i h n i e n e L e L a e r a ni n ng

Decision Trees / NLP Introduction

Algorithms for Classification: The Basic Methods

Dan Roth 461C, 3401 Walnut

Machine Learning & Data Mining

Introduction to Machine Learning CMU-10701

DECISION TREE LEARNING. [read Chapter 3] [recommended exercises 3.1, 3.4]

Typical Supervised Learning Problem Setting

Natural Language Processing. Classification. Features. Some Definitions. Classification. Feature Vectors. Classification I. Dan Klein UC Berkeley

Machine Learning, Midterm Exam

Introduction to Machine Learning Midterm Exam

Bayesian Learning. Artificial Intelligence Programming. 15-0: Learning vs. Deduction

EECS 349:Machine Learning Bryan Pardo

Machine Learning

Notes on Machine Learning for and

Tutorial 6. By:Aashmeet Kalra

Mining Classification Knowledge

The Naïve Bayes Classifier. Machine Learning Fall 2017

Introduction to Machine Learning Midterm Exam Solutions

Universität Potsdam Institut für Informatik Lehrstuhl Maschinelles Lernen. Intelligent Data Analysis. Decision Trees

Decision Trees. CSC411/2515: Machine Learning and Data Mining, Winter 2018 Luke Zettlemoyer, Carlos Guestrin, and Andrew Moore

Classification and Prediction

Supervised Learning (contd) Decision Trees. Mausam (based on slides by UW-AI faculty)

Data Mining Classification: Basic Concepts, Decision Trees, and Model Evaluation

Decision Trees. Danushka Bollegala

Midterm: CS 6375 Spring 2015 Solutions

A Decision Stump. Decision Trees, cont. Boosting. Machine Learning 10701/15781 Carlos Guestrin Carnegie Mellon University. October 1 st, 2007

CSE 417T: Introduction to Machine Learning. Final Review. Henry Chai 12/4/18

CSCE 478/878 Lecture 6: Bayesian Learning and Graphical Models. Stephen Scott. Introduction. Outline. Bayes Theorem. Formulas

LINEAR CLASSIFICATION, PERCEPTRON, LOGISTIC REGRESSION, SVC, NAÏVE BAYES. Supervised Learning

Apprentissage automatique et fouille de données (part 2)

Stephen Scott.

Machine Learning Recitation 8 Oct 21, Oznur Tastan

Numerical Learning Algorithms

Machine Learning Lecture 7

Decision Trees. Nicholas Ruozzi University of Texas at Dallas. Based on the slides of Vibhav Gogate and David Sontag

Linear & nonlinear classifiers

Decision Tree Learning Lecture 2

Support Vector Machine. Industrial AI Lab.

Classification: Decision Trees

Decision Trees. Each internal node : an attribute Branch: Outcome of the test Leaf node or terminal node: class label.

Generative v. Discriminative classifiers Intuition

Classification CE-717: Machine Learning Sharif University of Technology. M. Soleymani Fall 2012

Decision Trees. Lewis Fishgold. (Material in these slides adapted from Ray Mooney's slides on Decision Trees)

UNIVERSITY of PENNSYLVANIA CIS 520: Machine Learning Final, Fall 2013

Mining Classification Knowledge

Decision Tree Learning

Lecture 9: Bayesian Learning

Qualifying Exam in Machine Learning

Final Exam, Fall 2002

Introduction to Information Retrieval

ECE 5984: Introduction to Machine Learning

Machine Learning

PAC-learning, VC Dimension and Margin-based Bounds

Decision Trees. Gavin Brown

Modern Information Retrieval

Gaussian and Linear Discriminant Analysis; Multiclass Classification

Logistic Regression. Introduction to Data Science Algorithms Jordan Boyd-Graber and Michael Paul SLIDES ADAPTED FROM HINRICH SCHÜTZE

Linear Classifiers: Expressiveness

CS145: INTRODUCTION TO DATA MINING

Induction on Decision Trees

VBM683 Machine Learning

Support Vector Machine. Industrial AI Lab. Prof. Seungchul Lee

Transcription:

Classification II: Decision Trees and SVMs Digging into Data: Jordan Boyd-Graber February 25, 2013 Slides adapted from Tom Mitchell, Eric Xing, and Lauren Hannah Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 1 / 48

Roadmap Classification: machines labeling data for us Last time: naïve Bayes and logistic regression This time: Decision Trees SVMs Simple, nonlinear, interpretable (another) example of linear classifier State-of-the-art classification Examples in Rattle (Logistic, SVM, Trees) Discussion: Which classifier should I use for my problem? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 2 / 48

Outline 1 Decision Trees 2 Learning Decision Trees 3 Vector space classification 4 Linear Classifiers 5 Support Vector Machines 6 Recap Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 3 / 48

Trees Suppose that we want to construct a set of rules to represent the data can represent data as a series of if-then statements here, if splits inputs into two categories then assigns value when if statements are nested, structure is called a tree X 1 > 8 True X 1 > 5 False X 2 < - 2 True True False FALSE TRUE X 3 > 0 True False TRUE TRUE FALSE Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 4 / 48

Trees Ex: data (X 1,X 2,X 3,Y) with X 1,X 2,X 3 are real, Y Boolean First, see if X 1 > 5: if TRUE, see if X 1 > 8 if TRUE, return FALSE if FALSE, return TRUE if FALSE, see if X 2 < 2 if TRUE, see if X3 > 0 if TRUE, return TRUE if FALSE, return FALSE if FALSE, return TRUE True X 1 > 8 True X 1 > 5 False X 2 < - 2 True False FALSE TRUE X 3 > 0 TRUE True False TRUE FALSE Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 5 / 48

Trees X 1 > 8 True X 1 > 5 False X 2 < - 2 True True False FALSE TRUE X 3 > 0 TRUE True False TRUE FALSE Example 1: (X 1,X 2,X 3 ) = (1,1,1) Example 2: (X 1,X 2,X 3 ) = (10, 3,0) Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 6 / 48

Trees X 1 > 8 True X 1 > 5 False X 2 < - 2 True True False FALSE TRUE X 3 > 0 TRUE True False TRUE FALSE Example 1: (X 1,X 2,X 3 ) = (1,1,1) TRUE Example 2: (X 1,X 2,X 3 ) = (10, 3,0) Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 6 / 48

Trees X 1 > 8 True X 1 > 5 False X 2 < - 2 True True False FALSE TRUE X 3 > 0 TRUE True False TRUE FALSE Example 1: (X 1,X 2,X 3 ) = (1,1,1) TRUE Example 2: (X 1,X 2,X 3 ) = (10, 3,0) FALSE Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 6 / 48

Trees Terminology: branches: one side of a split leaves: terminal nodes that return values Why trees? trees can be used for regression or classification regression: returned value is a real number classification: returned value is a class unlike linear regression, SVMs, naive Bayes, etc, trees fit local models in large spaces, global models may be hard to fit results may be hard to interpret fast, interpretable predictions Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 7 / 48

Example: Predicting Electoral Results 2008 Democratic primary: Hillary Clinton Barack Obama Given historical data, how will a count vote? can extrapolate to state level data might give regions to focus on increasing voter turnout would like to know how variables interact Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 8 / 48

Example: Predicting Electoral Results Figure 1: Classification tree for county-level outcomes in the 2008 Democratic Party primary (as of April 16), by Amanada Cox for the New York Times. 3 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 9 / 48

Example: Predicting Electoral Results Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 10 / 48

Example: Predicting Electoral Results Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 11 / 48

Example: Predicting Electoral Results igure 1: Classification tree for county-level outcomes in the 2008 Democratic P rimary (as of April 16), by Amanada Cox for the New York Times. 3 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 12 / 48

Decision Trees Decision tree representation: Each internal node tests an attribute Each branch corresponds to attribute value Each leaf node assigns a classification How would we represent as a function of X,Y : X AND Y (both must be true) X OR Y (either can be true) X XOR Y (one and only one is true) Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 13 / 48

When to Consider Decision Trees Instances describable by attribute-value pairs Target function is discrete valued Disjunctive hypothesis may be required Possibly noisy training data Examples: Equipment or medical diagnosis Credit risk analysis Modeling calendar scheduling preferences Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 14 / 48

Outline 1 Decision Trees 2 Learning Decision Trees 3 Vector space classification 4 Linear Classifiers 5 Support Vector Machines 6 Recap Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 15 / 48

Top-Down Induction of Decision Trees Main loop: 1 A the best decision attribute for next node 2 Assign A as decision attribute for node 3 For each value of A, create new descendant of node 4 Sort training examples to leaf nodes 5 If training examples perfectly classified, Then STOP, Else iterate over new leaf nodes Which attribute is best? A1=? [29+,35-] [29+,35-] A2=? t f t f [21+,5-] [8+,30-] [18+,33-] [11+,2-] Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 16 / 48

S is a sample of training examples Digging into p Data: is the Jordanproportion Boyd-Graber () of positive Classificationexamples II: Decision Trees inand SSVMs February 25, 2013 17 / 48 Entropy: Reminder 1.0 Entropy(S) 0.5 0.0 0.5 1.0 p +

Entropy How spread out is the distribution of S: p ( log 2 p ) + p ( log 2 p ) Entropy(S) p log 2 p p log 2 p Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 18 / 48

Information Gain Which feature A would be a more useful rule in our decision tree? Gain(S, A) = expected reduction in entropy due to sorting on A Gain(S, A) Entropy(S) v Values(A) S v S Entropy(S v) A1=? [29+,35-] [29+,35-] A2=? t f t f [21+,5-] [8+,30-] [18+,33-] [11+,2-] Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 19 / 48

H(S) = 29 29 54 lg 35 35 54 64 lg 64 = Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 20 / 48

H(S) = 29 29 54 lg 35 35 54 64 lg 64 = 0.96 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 20 / 48

H(S) = 29 29 54 lg 35 35 54 64 lg 64 = 0.96 Gain(S,A 1 ) = 0.96 26 5 5 64 26 lg 26 38 8 8 64 38 lg 30 38 38 lg = 21 26 lg 26 30 21 38 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 20 / 48

H(S) = 29 29 54 lg 35 35 54 64 lg 64 = 0.96 Gain(S,A 1 ) = 0.96 26 5 5 64 26 lg 26 38 8 8 64 38 lg 30 38 38 lg = 0.96 0.28 0.44 = 0.24 21 26 lg 26 30 21 38 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 20 / 48

H(S) = 29 29 54 lg 35 35 54 64 lg 64 = 0.96 Gain(S,A 1 ) = 0.96 26 5 5 64 26 lg 26 38 8 8 64 38 lg 30 38 38 lg = 0.96 0.28 0.44 = 0.24 21 26 lg 26 30 21 Gain(S,A 2 ) = 0.96 51 18 18 64 51 lg 33 33 51 51 lg 51 13 11 11 64 13 lg 2 2 13 13 lg 13 = 38 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 20 / 48

H(S) = 29 29 54 lg 35 35 54 64 lg 64 = 0.96 Gain(S,A 1 ) = 0.96 26 5 5 64 26 lg 26 38 8 8 64 38 lg 30 38 38 lg = 0.96 0.28 0.44 = 0.24 21 26 lg 26 30 21 Gain(S,A 2 ) = 0.96 51 18 18 64 51 lg 33 33 51 51 lg 51 13 11 11 64 13 lg 2 2 13 13 lg 13 = 0.96 0.75 0.13 = 0.08 38 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 20 / 48

Training Examples Day Outlook Temperature Humidity Wind PlayTennis D1 Sunny Hot High Weak No D2 Sunny Hot High Strong No D3 Overcast Hot High Weak Yes D4 Rain Mild High Weak Yes D5 Rain Cool Normal Weak Yes D6 Rain Cool Normal Strong No D7 Overcast Cool Normal Strong Yes D8 Sunny Mild High Weak No D9 Sunny Cool Normal Weak Yes D10 Rain Mild Normal Weak Yes D11 Sunny Mild Normal Strong Yes D12 Overcast Mild High Strong Yes D13 Overcast Hot Normal Weak Yes D14 Rain Mild High Strong No Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 21 / 48

Selecting the Next Attribute Which attribute is the best classifier? S: [9+,5-] S: [9+,5-] E =0.940 E =0.940 Humidity Wind High Normal Weak Strong [3+,4-] [6+,1-] [6+,2-] [3+,3-] E =0.985 E =0.592 E =0.811 E =1.00 Gain (S, Humidity ) Gain (S, Wind) =.940 - (7/14).985 - (7/14).592 =.151 =.940 - (8/14).811 - (6/14)1.0 =.048 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 22 / 48

ID3 Algorithm Start at root, look for best attribute Repeat for subtrees at each attribute outcome Stop when information gain is below a threshold Bias: prefers shorter trees (Occam s Razor) a short hyp that fits data unlikely to be coincidence a long hyp that fits data might be coincidence Prevents overfitting (more later) Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 23 / 48

Outline 1 Decision Trees 2 Learning Decision Trees 3 Vector space classification 4 Linear Classifiers 5 Support Vector Machines 6 Recap Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 24 / 48

Thinking Geometrically Suppose you have two classes: vacations and sports Suppose you have four documents Sports Doc 1 : {ball, ball, ball, travel} Doc 2 : {ball, ball} What does this look like in vector space? Vacations Doc 3 : {travel, ball, travel} Doc 4 : {travel} Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 25 / 48

Put the documents in vector space Travel 3 2 1 0 1 2 3 Ball Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 26 / 48

Vector space representation of documents Each document is a vector, one component for each term. Terms are axes. High dimensionality: 10,000s of dimensions and more How can we do classification in this space? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 27 / 48

Vector space classification As before, the training set is a set of documents, each labeled with its class. In vector space classification, this set corresponds to a labeled set of points or vectors in the vector space. Premise 1: Documents in the same class form a contiguous region. Premise 2: Documents from different classes don t overlap. We define lines, surfaces, hypersurfaces to divide regions. Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 28 / 48

Classes Classes in the vector in the space vector space UK China Kenya Digging into Data: Jordan Should Boyd-Graber () theclassification document II: Decision Trees and SVMs be assigned February to25, 2013 China, 29 / 48 x x x x

Classes Classes in the vector in the space vector space UK China Kenya Should the document be assigned to China, Should the document be assigned to China, UK or Kenya? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 29 / 48 x x x x

Classes in the vector space Classes in the vector space UK China Kenya Find separators Find between separators the classesbetween the classes Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 29 / 48 x x x x

Classes in the vector space Classes in the vector space UK China Kenya Find separators Findbetween separators the classes between the classes Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 29 / 48 x x x x

Classes Classes in thein vector thespace vector space UK China Kenya Find separators between the classes Based on these separators: should be assigned to China Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 29 / 48 x x x x

Classes Classes in thein vector thespace vector space UK China Kenya Find separators between the classes How do we find separators that do a good job at classifying new documents like? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 29 / 48 x x x x

Outline 1 Decision Trees 2 Learning Decision Trees 3 Vector space classification 4 Linear Classifiers 5 Support Vector Machines 6 Recap Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 30 / 48

Linear classifiers Definition: A linear classifier computes a linear combination or weighted sum i w ix i of the feature values. Classification decision: i w ix i > θ?... where θ (the threshold) is a parameter. (First, we only consider binary classifiers.) Geometrically, this corresponds to a line (2D), a plane (3D) or a hyperplane (higher dimensionalities). We call this the separator or decision boundary. We find the separator based on training set. Methods for finding separator: logistic regression, naïve Bayes, linear SVM Assumption: The classes are linearly separable. Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 31 / 48

Linear classifiers Definition: A linear classifier computes a linear combination or weighted sum i w ix i of the feature values. Classification decision: i w ix i > θ?... where θ (the threshold) is a parameter. (First, we only consider binary classifiers.) Geometrically, this corresponds to a line (2D), a plane (3D) or a hyperplane (higher dimensionalities). We call this the separator or decision boundary. We find the separator based on training set. Methods for finding separator: logistic regression, naïve Bayes, linear SVM Assumption: The classes are linearly separable. Before, we just talked about equations. What s the geometric intuition? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 31 / 48

A linear classifier in 1D Alinearclassifierin1Dis apointx described by the equation w 1 d 1 = θ x = θ/w 1 A linear classifier in 1D is a point x described by the equation w 1 d 1 = θ Schütze: Support vector machines 15 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 32 / 48

A linear classifier in 1D Alinearclassifierin1Dis apointx described by the equation w 1 d 1 = θ x = θ/w 1 A linear classifier in 1D is a point x described by the equation w 1 d 1 = θ x = θ /w 1 Schütze: Support vector machines 15 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 32 / 48

A linear classifier in 1D Alinearclassifierin1Dis apointx described by the equation w 1 d 1 = θ x = θ/w 1 Points (d 1 )withw 1 d 1 θ are in theaclass linear c. classifier in 1D is a point x described by the equation w 1 d 1 = θ x = θ /w 1 Points (d 1 ) with w 1 d 1 θ are in the class c. Schütze: Support vector machines 15 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 32 / 48

Alinearclassifierin1D A linear classifier in 1D Alinearclassifierin1Dis apointx described by the equation w 1 d 1 = θ x = θ/w 1 Points (da 1 )withw linear classifier 1 d 1 θ in 1D is a are in the point classxc. described by the Points (d 1 )withw 1 d 1 < θ equation w 1 d 1 = θ are in the complement class c. x = θ /w 1 Points (d 1 ) with w 1 d 1 θ are in the class c. Points (d 1 ) with w 1 d 1 < θ are in the complement class c. Schütze: Support vector machines 15 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 32 / 48

Recap Vector space classification Linear classifiers Support Vector Machines Discussion A linear classifier 2D Alinearclassifierin2D Alinearclassifierin2Dis alinedescribedbythe A linear classifier in 2D is a equation wline 1 d 1 + described w 2 d 2 = θ by the Example for equation a 2D linear w 1 d 1 + w 2 d 2 = θ classifier Schütze: Support vector machines 16 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 33 / 48

Recap Vector space classification Linear classifiers Support Vector Machines Discussion A linear classifier 2D Alinearclassifierin2D Alinearclassifierin2Dis alinedescribedbythe A linear classifier in 2D is a equation wline 1 d 1 + described w 2 d 2 = θ by the Example for equation a 2D linear w 1 d 1 + w 2 d 2 = θ classifier Example for a 2D linear classifier Schütze: Support vector machines 16 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 33 / 48

A linear Recap Vector classifier space classification Linear classifiers 2D Support Vector Machines Discussion Alinearclassifierin2D Alinearclassifierin2Dis A classifier in 2D is a alinedescribedbythe line described by the equation w 1 d 1 + w 2 d 2 = θ equation w 1 d 1 + w 2 d 2 = θ Example for a 2D linear classifier Example for a 2D linear Points (d 1 d 2 )with classifier w 1 d 1 + w 2 d 2 θ are in the class c. Points (d 1 d 2 ) with w 1 d 1 + w 2 d 2 θ are in the class c. Schütze: Support vector machines 16 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 33 / 48

Recap Vector space classification Linear classifiers A linear classifier 2D Support Vector Machines Discussion Alinearclassifierin2D Alinearclassifierin2Dis alinedescribedbythe A linear classifier in 2D is a equation wline 1 d 1 + described w 2 d 2 = θ by the Example for equation a 2D linear w 1 d 1 + w 2 d 2 = θ classifier Points (d Example 1 d 2 )with for a 2D linear w 1 d 1 + w 2 classifier d 2 θ are in the class c. Points (d 1 d 2 ) with Points (d 1 d 2 )with w 1 d 1 + w 2 wd 2 1 d< 1 θ+ are w 2 ind 2 θ are in the the complement class class c. c. Points (d 1 d 2 ) with w 1 d 1 + w 2 d 2 < θ are in the complement class c. Schütze: Support vector machines 16 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 33 / 48

A linear Recap Vector classifier space classification Linear classifiers 3D Support Vector Machines Discussion Alinearclassifierin3D Alinearclassifierin3Dis aplanedescribedbythe A linear classifier in 3D is a equation plane described by the w 1 d 1 + w 2 d 2 + w 3 d 3 = θ equation w 1 d 1 + w 2 d 2 + w 3 d 3 = θ Schütze: Support vector machines 17 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 34 / 48

Recap Vector space classification Linear classifiers A linear classifier 3D Support Vector Machines Discussion Alinearclassifierin3D Alinearclassifierin3Dis aplanedescribedbythe equation w 1 d 1 + w 2 d 2 + w 3 d 3 = θ Example for a 3D linear classifier A linear classifier in 3D is a plane described by the equation w 1 d 1 + w 2 d 2 + w 3 d 3 = θ Example for a 3D linear classifier Schütze: Support vector machines 17 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 34 / 48

A linear classifier in 3D Recap Vector space classification Linear classifiers Support Vector Machines Discussion Alinearclassifierin3D Alinearclassifierin3Dis A linear classifier in 3D is a aplanedescribedbythe described by the equation equation w 1 d 1 + w 2 d 2 + w 3 d 3 = θ w 1 d 1 + w 2 d 2 + w 3 d 3 = θ Example for a 3D linear classifier Example for a 3D linear Points (d 1 d 2 d 3 )with w 1 d 1 + w 2 d 2 + classifier w 3 d 3 θ are in the class c. Points (d 1 d 2 d 3 ) with w 1 d 1 + w 2 d 2 + w 3 d 3 θ are in the class c. Schütze: Support vector machines 17 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 34 / 48

Recap Vector space classification Linear classifiers A linear classifier 3D Support Vector Machines Discussion Alinearclassifierin3D Alinearclassifierin3Dis aplanedescribedbythe A linear classifier in 3D is a equation w 1 d 1 + w 2 d 2 + plane w 3 d 3 = described θ by the Example for aequation 3D linear classifier Points (d 1 d 2 d 3 )with w 1 d 1 + w 2 d 2 + Example w 3 d 3 θ for a 3D linear are in the class classifier c. Points (d 1 d 2 d 3 )with w 1 d 1 + w 2 d 2 + Points w 3 d 3 < (d θ 1 d 2 d 3 ) with are in the complement w 1 d 1 + w 2 d 2 + w 3 d 3 θ are class c. in the class c. Schütze: Support vector machines 17 / 55 w 1 d 1 + w 2 d 2 + w 3 d 3 = θ Points (d 1 d 2 d 3 ) with w 1 d 1 + w 2 d 2 + w 3 d 3 < θ are in the complement class c. Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 34 / 48

Naive Bayes and Logistic Regression as linear classifiers Multinomial Naive Bayes is a linear classifier (in log space) defined by: M w i d i = θ i=1 where w i = log[ˆp(ti c)/ˆp(ti c)], d i = number of occurrences of t i in d, and θ = log[ˆp(c)/ˆp( c)]. Here, the index i, 1 i M, refers to terms of the vocabulary. Logistic regression is the same (we only put it into the logistic function to turn it into a probability). Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 35 / 48

Naive Bayes and Logistic Regression as linear classifiers Multinomial Naive Bayes is a linear classifier (in log space) defined by: M w i d i = θ i=1 where w i = log[ˆp(ti c)/ˆp(ti c)], d i = number of occurrences of t i in d, and θ = log[ˆp(c)/ˆp( c)]. Here, the index i, 1 i M, refers to terms of the vocabulary. Logistic regression is the same (we only put it into the logistic function to turn it into a probability). Takeway Naïve Bayes, logistic regression and SVM (which we ll get to in a second) are all linear methods. They choose their hyperplanes based on different objectives: joint likelihood (NB), conditional likelihood (LR), and the margin (SVM). Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 35 / 48

Which hyperplane? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 36 / 48

Which hyperplane? For linearly separable training sets: there are infinitely many separating hyperplanes. They all separate the training set perfectly...... but they behave differently on test data. Error rates on new data are low for some, high for others. How do we find a low-error separator? Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 37 / 48

Outline 1 Decision Trees 2 Learning Decision Trees 3 Vector space classification 4 Linear Classifiers 5 Support Vector Machines 6 Recap Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 38 / 48

Support vector machines Machine-learning research in the last two decades has improved classifier effectiveness. New generation of state-of-the-art classifiers: support vector machines (SVMs), boosted decision trees, regularized logistic regression, neural networks, and random forests Applications to IR problems, particularly text classification SVMs: A kind of large-margin classifier Vector space based machine-learning method aiming to find a decision boundary between two classes that is maximally far from any point in the training data (possibly discounting some points as outliers or noise) Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 39 / 48

Support Vector Machines Support Vector Machines 2-class training data 2-class training data Schütze: Support vector machines 29 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 40 / 48

Support Vector Machines 2-class training data decision boundary linear separator 2-class training data decision boundary linear separator ütze: Support vector machines 29 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 40 / 48

pport Vector Machines Support Vector Machines 2-class training data decision boundary linear separator 2-class training data criterion: decision being boundary maximally linearfar separator away from criterion: any databeing point determines maximally far away classifier frommargin any data point determines classifier margin Margin is maximized tze: Support vector machines 29 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 40 / 48

Support Vector Machines Why maximize the margin? Recap Vector space classification Linear classifiers Support Vector Machines Discussion Points near decision surface uncertain classification decisions 2-class (50% training either way). data decision Aclassifierwithalarge boundary margin makes no low linear certainty separator classification criterion: decisions. being Gives classification maximally far away safety margin w.r.t slight fromerrors any data in measurement point or determines doc. variation classifier margin linear separator position defined by support vectors Maximum margin decision hyperplane Support vectors Margin is maximized Schütze: Support vector machines 30 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 40 / 48

Why maximize the margin? Why maximize the margin? Points near decision surface uncertain classification decisions Points (50% near either decision way). surface Aclassifierwithalarge uncertain classification margin makes no low certainty classification decisions decisions. (50% either way). Gives classification safety margin w.r.t slight A classifier with a errors in measurement or largedoc. margin variation makes no low certainty classification decisions. Gives classification safety margin w.r.t slight errors in measurement or documents variation Maximum margin decision hyperplane Support vectors Margin is maximized Schütze: Support vector machines 30 / 55 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 41 / 48

Why maximize the margin? SVM classifier: large margin around decision boundary compare to decision hyperplane: place fat separator between classes unique solution decreased memory capacity increased ability to correctly generalize to test data Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 42 / 48

Walkthrough example: building an SVM over the data set shown in the figure Working geometrically: 3 2 1 0 1 2 3 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 43 / 48

Walkthrough example: building an SVM over the data set shown in the figure Working geometrically: The maximum margin weight vector will be parallel to the shortest line connecting points of the two classes, that is, the line between (1,1) and (2,3), giving a weight vector of (1,2). 3 2 1 0 1 2 3 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 43 / 48

Walkthrough example: building an SVM over the data set shown in the figure Working geometrically: The maximum margin weight vector will be parallel to the shortest line connecting points of the two classes, that is, the line between (1,1) and (2,3), giving a weight vector of (1,2). The optimal decision surface is orthogonal to that line and intersects it at the halfway point. Therefore, it passes through (1.5,2). 3 2 1 0 1 2 3 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 43 / 48

Walkthrough example: building an SVM over the data set shown in the figure Working geometrically: The maximum margin weight vector will be parallel to the shortest line connecting points of the two classes, that is, the line between (1,1) and (2,3), giving a weight vector of (1,2). The optimal decision surface is orthogonal to that line and intersects it at the halfway point. Therefore, it passes through (1.5,2). The SVM decision boundary is: 0 = 1 2 x + y 11 4 0 = 2 5 x + 4 5 y 11 5 3 2 1 0 1 2 3 Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 43 / 48

SVM extensions Slack variables: not perfect line Kernels: different geometries 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 Loss functions: Different penalties for getting the answer wrong Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 44 / 48

Outline 1 Decision Trees 2 Learning Decision Trees 3 Vector space classification 4 Linear Classifiers 5 Support Vector Machines 6 Recap Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 45 / 48

Text classification Many commercial applications There are many applications of text classification for corporate Intranets, government departments, and Internet publishers. Often greater performance gains from exploiting domain-specific text features than from changing from one machine learning method to another. (Homework 2) Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 46 / 48

Choosing what kind of classifier to use When building a text classifier, first question: how much training data is there currently available? None? Very little? A fair amount? A huge amount Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 47 / 48

Choosing what kind of classifier to use When building a text classifier, first question: how much training data is there currently available? None? Hand write rules or use active learning Very little? A fair amount? A huge amount Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 47 / 48

Choosing what kind of classifier to use When building a text classifier, first question: how much training data is there currently available? None? Hand write rules or use active learning Very little? Naïve Bayes A fair amount? A huge amount Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 47 / 48

Choosing what kind of classifier to use When building a text classifier, first question: how much training data is there currently available? None? Hand write rules or use active learning Very little? Naïve Bayes A fair amount? SVM A huge amount Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 47 / 48

Choosing what kind of classifier to use When building a text classifier, first question: how much training data is there currently available? None? Hand write rules or use active learning Very little? Naïve Bayes A fair amount? SVM A huge amount Doesn t matter, use whatever works Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 47 / 48

Recap Is there a learning method that is optimal for all text classification problems? No, because there is a tradeoff between bias and variance. Factors to take into account: How much training data is available? How simple/complex is the problem? (linear vs. nonlinear decision boundary) How noisy is the problem? How stable is the problem over time? For an unstable problem, it s better to use a simple and robust classifier. You ll be investigating the role of features in HW2! Digging into Data: Jordan Boyd-Graber () Classification II: Decision Trees and SVMs February 25, 2013 48 / 48