This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Introduc)on to Informa)on Retrieval Recap: Naïve Bayes classiﬁers Classify based on prior weight of class and condi<onal parameter for what each word says: Training is done by coun<ng and dividing: Don’t forget to smooth 1 Introduc)on to Informa)on Retrieval The rest of text classiﬁca<on Today: Vector space methods for Text Classiﬁca<on Vector space classiﬁca<on using centroids (Rocchio) K Nearest Neighbors Decision boundaries, linear and nonlinear classiﬁers Dealing with more than 2 classes 2 1 Introduc)on to Informa)on Retrieval Sec.14.1 Recall: Vector Space Representa<on Each document is a vector, one component for each term (= word). Normally normalize vectors to unit length. High
dimensional vector space: Terms are axes 10,000+ dimensions, or even 100,000+ Docs are vectors in this space How can we do classiﬁca<on in this space? 3 Introduc)on to Informa)on Retrieval Sec.14.1 Classiﬁca<on Using Vector Spaces As before, the training set is a set of documents, each labeled with its class (e.g., topic) In vector space classiﬁca<on, this set corresponds to a labeled set of points (or, equivalently, vectors) in the vector space Premise 1: Documents in the same class form a con<guous region of space Premise 2: Documents from diﬀerent classes don’t overlap (much) We deﬁne surfaces to delineate classes in the space 4 2 Introduc)on to Informa)on Retrieval Sec.14.1 Documents in a Vector Space Government Science Arts 5 Introduc)on to Informa)on Retrieval Sec.14.1 Test Document of what class? Government Science Arts 6 3 Introduc)on to Informa)on Retrieval Sec.14.1 Test Document = Government Is this similarity hypothesis true in general?
Government Science Arts Our main topic today is how to find good separators 7 Introduc)on to Informa)on Retrieval Sec.14.1 Aside: 2D/3D graphs can be misleading 8 4 Introduc)on to Informa)on Retrieval Sec.14.2 Using Rocchio for text classiﬁca<on Relevance feedback methods can be adapted for text categoriza<on As noted before, relevance feedback can be viewed as 2
class classiﬁca<on Relevant vs. nonrelevant documents Use standard d
idf weighted vectors to represent text documents For training documents in each category, compute a prototype vector by summing the vectors of the training documents in the category. Prototype = centroid of members of class Assign test documents to the category with the closest prototype vector based on cosine similarity. 9 Introduc)on to Informa)on Retrieval Sec.14.2 Illustra<on of Rocchio Text Categoriza<on 10 5 Introduc)on to Informa)on Retrieval Sec.14.2 Deﬁni<on of centroid Where Dc is the set of all documents that belong to class c and v(d) is the vector space representa<on of d. Note that centroid will in general not be a unit vector even when the inputs are unit vectors. 11 Introduc)on to Informa)on Retrieval Sec.14.2 Rocchio Proper<es Forms a simple generaliza<on of the examples in each class (a prototype). Prototype vector does not need to be averaged or otherwise normalized for length since cosine similarity is insensi<ve to vector length. Classiﬁca<on is based on similarity to class prototypes. Does not guarantee classiﬁca<ons are consistent with the given training data. Why not? 12 6 Introduc)on to Informa)on Retrieval Sec.14.2 Rocchio Anomaly Prototype models have problems with polymorphic (disjunc<ve) categories. 13 Introduc)on to Informa)on Retrieval Sec.14.2 Rocchio classiﬁca<on Rocchio forms a simple representa<on for each class: the centroid/prototype Classiﬁca<on is based on similarity to / distance from the prototype/centroid It does not guarantee that classiﬁca<ons are consistent with the given training data It is lihle used outside text classiﬁca<on It has been used quite eﬀec<vely for text classiﬁca<on But in general worse than Naïve Bayes Again, cheap to train and test documents 14 7 Introduc)on to Informa)on Retrieval Sec.14.3 k Nearest Neighbor Classiﬁca<on kNN = k Nearest Neighbor To classify a document d into class c: Deﬁne k
neighborhood N as k nearest neighbors of d Count number of documents i in N that belong to c Es<mate P(cd) as i/k Choose as class argmaxc P(cd) [ = majority class] 15 Introduc)on to Informa)on Retrieval Sec.14.3 Example: k=6 (6NN) P(science )? Government Science Arts 16 8 Introduc)on to Informa)on Retrieval Sec.14.3 Nearest
Neighbor Learning Algorithm Learning is just storing the representa<ons of the training examples in D. Tes<ng instance x (under 1NN): Compute similarity between x and all examples in D. Assign x the category of the most similar example in D. Does not explicitly compute a generaliza<on or category prototypes. Also called: Case
based learning Memory
based learning Lazy learning Ra<onale of kNN: con<guity hypothesis 17 Introduc)on to Informa)on Retrieval Sec.14.3 kNN Is Close to Op<mal Cover and Hart (1967) Asympto<cally, the error rate of 1
nearest
neighbor classiﬁca<on is less than twice the Bayes rate [error rate of classiﬁer knowing model that generated data] In par<cular, asympto<c error rate is 0 if Bayes rate is 0. Assume: query point coincides with a training point. Both query point and training point contribute error → 2 <mes Bayes rate 18 9 Introduc)on to Informa)on Retrieval Sec.14.3 k Nearest Neighbor Using only the closest example (1NN) to determine the class is subject to errors due to: A single atypical example. Noise (i.e., an error) in the category label of a single training example. More robust alterna<ve is to ﬁnd the k most
similar examples and return the majority category of these k examples. Value of k is typically odd to avoid <es; 3 and 5 are most common. 19 Introduc)on to Informa)on Retrieval Sec.14.3 kNN decision boundaries Boundaries are in principle arbitrary surfaces – but usually polyhedra Government Science Arts kNN gives locally deﬁned decision boundaries between classes – far away points do not inﬂuence each classiﬁca<on decision (unlike in Naïve Bayes, Rocchio, etc.) 20 10 Introduc)on to Informa)on Retrieval Sec.14.3 Similarity Metrics Nearest neighbor method depends on a similarity (or distance) metric. Simplest for con<nuous m
dimensional instance space is Euclidean distance. Simplest for m
dimensional binary instance space is Hamming distance (number of feature values that diﬀer). For text, cosine similarity of d.idf weighted vectors is typically most eﬀec<ve. 21 Introduc)on to Informa)on Retrieval Sec.14.3 Illustra<on of 3 Nearest Neighbor for Text Vector Space 22 11 Introduc)on to Informa)on Retrieval 3 Nearest Neighbor vs. Rocchio Nearest Neighbor tends to handle polymorphic categories beher than Rocchio/NB. 23 Introduc)on to Informa)on Retrieval Sec.14.3 Nearest Neighbor with Inverted Index Naively ﬁnding nearest neighbors requires a linear search through D documents in collec<on But determining k nearest neighbors is the same as determining the k best retrievals using the test document as a query to a database of training documents. Use standard vector space inverted index methods to ﬁnd the k nearest neighbors. Tes<ng Time: O(BVt) where B is the average number of training documents in which a test
document word appears. Typically B << D 24 12 Introduc)on to Informa)on Retrieval Sec.14.3 kNN: Discussion No feature selec<on necessary Scales well with large number of classes Don’t need to train n classiﬁers for n classes Classes can inﬂuence each other Small changes to one class can have ripple eﬀect Scores can be hard to convert to probabili<es No training necessary Actually: perhaps not true. (Data edi<ng, etc.) May be expensive at test <me In most cases it’s more accurate than NB or Rocchio 25 Introduc)on to Informa)on Retrieval Sec.14.6 kNN vs. Naive Bayes Bias/Variance tradeoﬀ Variance ≈ Capacity kNN has high variance and low bias. Inﬁnite memory NB has low variance and high bias. Decision surface has to be linear (hyperplane – see later) Consider asking a botanist: Is an object a tree? Too much capacity/variance, low bias Botanist who memorizes Will always say “no” to new object (e.g., diﬀerent # of leaves) Not enough capacity/variance, high bias Lazy botanist Says “yes” if the object is green You want the middle ground (Example due to C. Burges)
26 13 Introduc)on to Informa)on Retrieval Sec.14.6 Bias vs. variance: Choosing the correct model capacity 27 Introduc)on to Informa)on Retrieval Sec.14.4 Linear classiﬁers and binary and mul<class classiﬁca<on Consider 2 class problems Deciding between two classes, perhaps, government and non
government One
versus
rest classiﬁca<on How do we deﬁne (and ﬁnd) the separa<ng surface? How do we decide which region a test doc is in? 28 14 Introduc)on to Informa)on Retrieval Sec.14.4 Separa<on by Hyperplanes A strong high
bias assump<on is linear separability: in 2 dimensions, can separate classes by a line in higher dimensions, need hyperplanes Can ﬁnd separa<ng hyperplane by linear programming (or can itera<vely ﬁt solu<on via perceptron): separator can be expressed as ax + by = c 29 Introduc)on to Informa)on Retrieval Sec.14.4 Linear programming / Perceptron Find a,b,c, such that ax + by > c for red points ax + by < c for blue points. 30 15 Introduc)on to Informa)on Retrieval Sec.14.4 Which Hyperplane? In general, lots of possible solutions for a,b,c.
31 Introduc)on to Informa)on Retrieval Sec.14.4 Which Hyperplane? Lots of possible solu<ons for a,b,c. Some methods ﬁnd a separa<ng hyperplane, but not the op<mal one [according to some criterion of expected goodness] E.g., perceptron Most methods ﬁnd an op<mal separa<ng hyperplane Which points should inﬂuence op<mality? All points Linear/logis<c regression Naïve Bayes Only “diﬃcult points” close to decision boundary Support vector machines 32 16 Introduc)on to Informa)on Retrieval Sec.14.4 Linear classiﬁer: Example Class: “interest” (as in interest rate) Example features of a linear classiﬁer wi ti wi ti • 0.70 • 0.67 • 0.63 • 0.60 • 0.46 • 0.43 prime rate interest rates discount bundesbank • −0.71 • −0.35 • −0.33 • −0.25 • −0.24 • −0.24 dlrs world sees year group dlr To classify, ﬁnd dot product of feature vector and weights 33 Introduc)on to Informa)on Retrieval Sec.14.4 Linear Classiﬁers Many common text classiﬁers are linear classiﬁers Naïve Bayes Perceptron Rocchio Logis<c regression Support vector machines (with linear kernel) Linear regression with threshold Despite this similarity, no<ceable performance diﬀerences For separable problems, there is an inﬁnite number of separa<ng hyperplanes. Which one do you choose? What to do for non
separable problems? Diﬀerent training methods pick diﬀerent hyperplanes Classiﬁers more powerful than linear o{en don’t perform beher on text problems. Why? 34 17 Introduc)on to Informa)on Retrieval Sec.14.2 Two
class Rocchio as a linear classiﬁer Line or hyperplane deﬁned by: For Rocchio, set: [Aside for ML/stats people: Rocchio classiﬁca<on is a simpliﬁca<on of the classic Fisher Linear Discriminant where you don’t model the variance (or assume it is spherical).] 35 Introduc)on to Informa)on Retrieval Sec.14.2 Rocchio is a linear classiﬁer 36 18 Introduc)on to Informa)on Retrieval Sec.14.4 Naive Bayes is a linear classiﬁer Two
class Naive Bayes. We compute: Decide class C if the odds is greater than 1, i.e., if the log odds is greater than 0. So decision boundary is hyperplane: 37 Introduc)on to Informa)on Retrieval Sec.14.4 A nonlinear problem A linear classiﬁer like Naïve Bayes does badly on this task kNN will do very well (assuming enough training data) 38 19 Introduc)on to Informa)on Retrieval Sec.14.4 High Dimensional Data Pictures like the one at right are absolutely misleading! Documents are zero along almost all axes Most document pairs are very far apart (i.e., not strictly orthogonal, but only share very common words and a few scahered others) In classiﬁca<on terms: o{en document sets are separable, for most any classiﬁca<on This is part of why linear classiﬁers are quite successful in this domain 39 Introduc)on to Informa)on Retrieval Sec.14.5 More Than Two Classes Any
of or mul<value classiﬁca<on Classes are independent of each other. A document can belong to 0, 1, or >1 classes. Decompose into n binary problems Quite common for documents One
of or mul<nomial or polytomous classiﬁca<on Classes are mutually exclusive. Each document belongs to exactly one class E.g., digit recogni<on is polytomous classiﬁca<on Digits are mutually exclusive 40 20 Introduc)on to Informa)on Retrieval Sec.14.5 Set of Binary Classiﬁers: Any of Build a separator between each class and its complementary set (docs from all other classes). Given test doc, evaluate it for membership in each class. Apply decision criterion of classiﬁers independently Done Though maybe you could do beher by considering dependencies between categories 41 Introduc)on to Informa)on Retrieval Sec.14.5 Set of Binary Classiﬁers: One of Build a separator between each class and its complementary set (docs from all other classes). Given test doc, evaluate it for membership in each class. Assign document to class with: maximum score maximum conﬁdence maximum probability ? ? ? Why diﬀerent from mul<class/ any of classiﬁca<on? 42 21 Introduc)on to Informa)on Retrieval Summary: Representa<on of Text Categoriza<on Ahributes Representa<ons of text are usually very high dimensional (one feature for each word) High
bias algorithms that prevent overﬁ~ng in high
dimensional space should generally work best* For most text categoriza<on tasks, there are many relevant features and many irrelevant ones Methods that combine evidence from many or all features (e.g. naive Bayes, kNN) o{en tend to work beher than ones that try to isolate just a few relevant features* *Although the results are a bit more mixed than o{en thought 43 Introduc)on to Informa)on Retrieval Which classiﬁer do I use for a given text classiﬁca<on problem? Is there a learning method that is op<mal for all text classiﬁca<on problems? No, because there is a tradeoﬀ 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 data? How stable is the problem over <me? For an unstable problem, it’s beher to use a simple and robust classiﬁer. 44 22 Introduc)on to Informa)on Retrieval Ch. 14 Resources for today’s lecture IIR 14 Fabrizio Sebas<ani. Machine Learning in Automated Text Categoriza<on. ACM Compu)ng Surveys, 34(1):1
47, 2002. Yiming Yang & Xin Liu, A re
examina<on of text categoriza<on methods. Proceedings of SIGIR, 1999. Trevor Has<e, Robert Tibshirani and Jerome Friedman, Elements of Sta)s)cal Learning: Data Mining, Inference and Predic)on. Springer
Verlag, New York. Open Calais: Automa<c Seman<c Tagging Free (but they can keep your data), provided by Thompson/Reuters Weka: A data mining so{ware package that includes an implementa<on of many ML algorithms 45 23 ...
View
Full
Document
This note was uploaded on 01/21/2011 for the course CSCP 689 taught by Professor James during the Spring '10 term at Texas A&M.
 Spring '10
 JAMES

Click to edit the document details