IR 12: Text Classification; Vector space classification

Similar documents
LCs for Binary Classification

Search Taxonomy. Web Search. Search Engine Optimization. Information Retrieval

Big Data Analytics CSCI 4030

Content-Based Recommendation

Linear Threshold Units

Statistical Machine Learning

Predictive Dynamix Inc

CS 2750 Machine Learning. Lecture 1. Machine Learning. CS 2750 Machine Learning.

PATTERN RECOGNITION AND MACHINE LEARNING CHAPTER 4: LINEAR MODELS FOR CLASSIFICATION

Class #6: Non-linear classification. ML4Bio 2012 February 17 th, 2012 Quaid Morris

Classification algorithm in Data mining: An Overview

Example: Credit card default, we may be more interested in predicting the probabilty of a default than classifying individuals as default or not.

Supervised Learning (Big Data Analytics)

An Introduction to Data Mining. Big Data World. Related Fields and Disciplines. What is Data Mining? 2/12/2015

Machine Learning Final Project Spam Filtering

: Introduction to Machine Learning Dr. Rita Osadchy

The Scientific Data Mining Process

An Introduction to Data Mining

MACHINE LEARNING IN HIGH ENERGY PHYSICS

Classifying Large Data Sets Using SVMs with Hierarchical Clusters. Presented by :Limou Wang

Social Media Mining. Data Mining Essentials

Reference Books. Data Mining. Supervised vs. Unsupervised Learning. Classification: Definition. Classification k-nearest neighbors

Representation of Electronic Mail Filtering Profiles: A User Study

Introduction to Machine Learning Lecture 1. Mehryar Mohri Courant Institute and Google Research

Analysis of kiva.com Microlending Service! Hoda Eydgahi Julia Ma Andy Bardagjy December 9, 2010 MAS.622j

Comparison of Non-linear Dimensionality Reduction Techniques for Classification with Gene Expression Microarray Data

Assessing Data Mining: The State of the Practice

A Simple Introduction to Support Vector Machines

Machine Learning Logistic Regression

Data Mining Practical Machine Learning Tools and Techniques

Lecture 3: Linear methods for classification

Learning Example. Machine learning and our focus. Another Example. An example: data (loan application) The data and the goal

SURVEY OF TEXT CLASSIFICATION ALGORITHMS FOR SPAM FILTERING

Knowledge Discovery from patents using KMX Text Analytics

Lecture 10: Regression Trees

Machine Learning. CUNY Graduate Center, Spring Professor Liang Huang.

Machine Learning using MapReduce

International Journal of Computer Science Trends and Technology (IJCST) Volume 3 Issue 3, May-June 2015

Question 2 Naïve Bayes (16 points)

Neural Networks and Support Vector Machines

Machine Learning. Mausam (based on slides by Tom Mitchell, Oren Etzioni and Pedro Domingos)

Machine Learning in Spam Filtering

Introduction to nonparametric regression: Least squares vs. Nearest neighbors

Data Mining - Evaluation of Classifiers

STA 4273H: Statistical Machine Learning

3 An Illustrative Example

Principles of Data Mining by Hand&Mannila&Smyth

Medical Information Management & Mining. You Chen Jan,15, 2013 You.chen@vanderbilt.edu

Sentiment analysis using emoticons

Data Mining Classification: Decision Trees

Facebook Friend Suggestion Eytan Daniyalzade and Tim Lipus

Artificial Neural Networks and Support Vector Machines. CS 486/686: Introduction to Artificial Intelligence

Spam Detection A Machine Learning Approach

Classification Techniques (1)

Support Vector Machine (SVM)

Active Learning SVM for Blogs recommendation

1 Maximum likelihood estimation

Machine Learning and Pattern Recognition Logistic Regression

Machine Learning Capacity and Performance Analysis and R

Comparing the Results of Support Vector Machines with Traditional Data Mining Algorithms

Logistic Regression. Vibhav Gogate The University of Texas at Dallas. Some Slides from Carlos Guestrin, Luke Zettlemoyer and Dan Weld.

Employer Health Insurance Premium Prediction Elliott Lui

Introduction to Learning & Decision Trees

Local classification and local likelihoods

A Non-Linear Schema Theorem for Genetic Algorithms

Machine Learning. Chapter 18, 21. Some material adopted from notes by Chuck Dyer

Neural Networks Lesson 5 - Cluster Analysis

Comparison of machine learning methods for intelligent tutoring systems

Introduction to Support Vector Machines. Colin Campbell, Bristol University

Meta-learning. Synonyms. Definition. Characteristics

Exam in course TDT4215 Web Intelligence - Solutions and guidelines -

Data Mining III: Numeric Estimation

Linear Classification. Volker Tresp Summer 2015

CSCI567 Machine Learning (Fall 2014)

CSC 411: Lecture 07: Multiclass Classification

The Data Mining Process

Christfried Webers. Canberra February June 2015

Data Mining: An Overview. David Madigan

The Enron Corpus: A New Dataset for Classification Research

E-commerce Transaction Anomaly Classification

Mining a Corpus of Job Ads

WE DEFINE spam as an message that is unwanted basically

Predicting Student Performance by Using Data Mining Methods for Classification

Supervised Feature Selection & Unsupervised Dimensionality Reduction

Machine learning for algo trading

Classification and Prediction techniques using Machine Learning for Anomaly Detection.

Analytics on Big Data

COMP3420: Advanced Databases and Data Mining. Classification and prediction: Introduction and Decision Tree Induction

Vector storage and access; algorithms in GIS. This is lecture 6

Data, Measurements, Features

Pixels Description of scene contents. Rob Fergus (NYU) Antonio Torralba (MIT) Yair Weiss (Hebrew U.) William T. Freeman (MIT) Banksy, 2006

A Proposed Algorithm for Spam Filtering s by Hash Table Approach

These slides follow closely the (English) course textbook Pattern Recognition and Machine Learning by Christopher Bishop

Environmental Remote Sensing GEOG 2021

A semi-supervised Spam mail detector

Defending Networks with Incomplete Information: A Machine Learning Approach. Alexandre

Ensemble Methods. Knowledge Discovery and Data Mining 2 (VU) ( ) Roman Kern. KTI, TU Graz

Identifying SPAM with Predictive Models

Decision Trees from large Databases: SLIQ

Machine Learning. CS 188: Artificial Intelligence Naïve Bayes. Example: Digit Recognition. Other Classification Tasks

Transcription:

IR 12: Text Classification; Vector space classification

Recap: Naïve Bayes classifiers Classify based on prior weight of class and conditional parameter for what each word says: $ ' c NB = argmax& log P(c j ) + # log P(x i c j )) c j "C %& i" positions () Training is done by counting and dividing: P(c j ) " N c j N P(x k c j ) " T c j x k + # % xi $V [T c j x i + # ] Don t forget to smooth 2

The rest of text classification This lecture: Vector space methods for Text Classification K Nearest Neighbors Decision boundaries Vector space classification using centroids Decision Trees (briefly) 3

Recall: Vector Space Representation 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 classification in this space? 4 14.1

Classification Using Vector Spaces As before, the training set is a set of documents, each labeled with its class (e.g., topic) In vector space classification, 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 contiguous region of space Premise 2: Documents from different classes don t overlap (much) We define surfaces to delineate classes in the space 5

Documents in a Vector Space Government Science Arts 6

Test Document of what class? Government Science Arts 7

Test Document = Government Is this similarity hypothesis true in general? Government Science Arts Our main topic today is how to find good separators 8

Aside: 2D/3D graphs can be misleading 9

k Nearest Neighbor Classification knn = k Nearest Neighbor To classify document d into class c: Define k-neighborhood N as k nearest neighbors of d Count number of documents i in N that belong to c Estimate P(c d) as i/k Choose as class argmax c P(c d) [ = majority class] 10 14.3

Example: k=6 (6NN) P(science )? Government Science Arts 11

Nearest-Neighbor Learning Algorithm Learning is just storing the representations of the training examples in D. Testing 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 generalization or category prototypes. Also called: Case-based learning Memory-based learning Lazy learning Rationale of knn: contiguity hypothesis 12

knn Is Close to Optimal Cover and Hart (1967) Asymptotically, the error rate of 1-nearestneighbor classification is less than twice the Bayes rate [error rate of classifier knowing model that generated data] In particular, asymptotic 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 times Bayes rate 13

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 alternative is to find the k mostsimilar examples and return the majority category of these k examples. Value of k is typically odd to avoid ties; 3 and 5 are most common. 14

knn decision boundaries Boundaries are in principle arbitrary surfaces but usually polyhedra Government Science Arts knn gives locally defined decision boundaries between classes far away points do not influence each classification decision (unlike in Naïve Bayes, Rocchio, etc.) 15

Similarity Metrics Nearest neighbor method depends on a similarity (or distance) metric. Simplest for continuous m-dimensional instance space is Euclidean distance. Simplest for m-dimensional binary instance space is Hamming distance (number of feature values that differ). For text, cosine similarity of tf.idf weighted vectors is typically most effective. 16

Illustration of 3 Nearest Neighbor for Text Vector Space 17

Nearest Neighbor with Inverted Index Naively finding nearest neighbors requires a linear search through D documents in collection 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 find the k nearest neighbors. Testing Time: O(B V t ) where B is the average number of training documents in which a test-document word appears. Typically B << D 18

knn: Discussion No feature selection necessary Scales well with large number of classes Don t need to train n classifiers for n classes Classes can influence each other Small changes to one class can have ripple effect Scores can be hard to convert to probabilities No training necessary Actually: perhaps not true. (Data editing, etc.) May be more expensive at test time 19

Linear classifiers and binary and multiclass classification Consider 2 class problems Deciding between two classes, perhaps, government and non-government One-versus-rest classification How do we define (and find) the separating surface? How do we decide which region a test doc is in? 20 14.4

Separation by Hyperplanes A strong high-bias assumption is linear separability: in 2 dimensions, can separate classes by a line in higher dimensions, need hyperplanes Can find separating hyperplane by linear programming (or can iteratively fit solution via perceptron): separator can be expressed as ax + by = c 21

Linear programming / Perceptron Find a,b,c, such that ax + by > c for red points ax + by < c for green points. 22

Which Hyperplane? In general, lots of possible solutions for a,b,c. 23

Which Hyperplane? Lots of possible solutions for a,b,c. Some methods find a separating hyperplane, but not the optimal one [according to some criterion of expected goodness] E.g., perceptron Most methods find an optimal separating hyperplane Which points should influence optimality? All points Linear regression Naïve Bayes Only difficult points close to decision boundary Support vector machines 24

Linear classifier: Example Class: interest (as in interest rate) Example features of a linear classifier w i t i w i t i 0.70 prime 0.67 rate 0.63 interest 0.60 rates 0.46 discount 0.43 bundesbank -0.71 dlrs -0.35 world -0.33 sees -0.25 year -0.24 group -0.24 dlr To classify, find dot product of feature vector and weights 25

Linear Classifiers Many common text classifiers are linear classifiers Naïve Bayes Perceptron Rocchio Logistic regression Support vector machines (with linear kernel) Linear regression Despite this similarity, noticeable performance differences For separable problems, there is an infinite number of separating hyperplanes. Which one do you choose? What to do for non-separable problems? Different training methods pick different hyperplanes Classifiers more powerful than linear often don t perform better on text problems. Why? 26

Naive Bayes is a linear classifier Two-class Naive Bayes. We compute: P( C d) P( C) P( w C) log = log +" log P( C d) P( C) P( w C) 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: % $ + " w # V w $ w! n w = P( w C) = log ; P( w C ) 0 n w where% = = # of w! d P( C) log ; P( C ) occurrences of w in d 27

A nonlinear problem A linear classifier like Naïve Bayes does badly on this task knn will do very well (assuming enough training data) 28

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 scattered others) In classification terms: often document sets are separable, for most any classification This is part of why linear classifiers are quite successful in this domain 29

More Than Two Classes Any-of or multivalue classification 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 multinomial or polytomous classification Classes are mutually exclusive. Each document belongs to exactly one class E.g., digit recognition is polytomous classification Digits are mutually exclusive 30 14.5

Set of Binary Classifiers: 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 classifiers independently Done Though maybe you could do better by considering dependencies between categories 31

Set of Binary Classifiers: 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 confidence maximum probability Why different from multiclass/ any of classification???? 32

Using Rocchio for text classification Relevance feedback methods can be adapted for text categorization As noted before, relevance feedback can be viewed as 2- class classification Relevant vs. nonrelevant documents Use standard TF/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. 33 14.2

Illustration of Rocchio Text Categorization 34

Definition of centroid r µ (c) = 1 D c # d "D c r v (d) Where D c is the set of all documents that belong to class c and v(d) is the vector space representation of d. Note that centroid will in general not be a unit vector even when the inputs are unit vectors. 35

Rocchio Properties Forms a simple generalization 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 insensitive to vector length. Classification is based on similarity to class prototypes. Does not guarantee classifications are consistent with the given training data. Why not? 36

Rocchio Anomaly Prototype models have problems with polymorphic (disjunctive) categories. 37

3 Nearest Neighbor Comparison Nearest Neighbor tends to handle polymorphic categories better. 38

Rocchio is a linear classifier 39

Two-class Rocchio as a linear classifier Line or hyperplane defined by: M " i=1 w i d i = 0 For Rocchio, set: r w = r µ (c 1 ) " r # = 0.5 $ ( µ (c 2 ) r µ (c 1 ) 2 " r µ (c 2 ) 2 ) 40

Rocchio classification Rocchio forms a simple representation for each class: the centroid/prototype Classification is based on similarity to / distance from the prototype/centroid It does not guarantee that classifications are consistent with the given training data It is little used outside text classification, but has been used quite effectively for text classification Again, cheap to train and test documents 41

Decision Tree Classification Tree with internal nodes labeled by terms Branches are labeled by tests on the weight that the term has Leaves are labeled by categories Classifier categorizes document by descending tree following tests to leaf The label of the leaf node is then assigned to the document Most decision trees are binary trees (never disadvantageous; may require extra internal nodes) DT make good use of a few high-leverage features 42

Decision Tree Categorization: Example Geometric interpretation of DT? 43

Decision Tree Learning Learn a sequence of tests on features, typically using top-down, greedy search At each stage choose the unused feature with highest Information Gain That is, feature/class Mutual Information Binary (yes/no) or continuous decisions f 1!f 1 f 7!f 7 P(class) =.9 P(class) =.6 P(class) =.2 44

Category: interest Dumais et al. (Microsoft) Decision Tree rate=1 rate.t=1 lending=0 prime=0 discount=0 pct=1 year=0 year=1 45

Summary: Representation of Text Categorization Attributes Representations of text are usually very high dimensional (one feature for each word) High-bias algorithms that prevent overfitting in high-dimensional space generally work best For most text categorization tasks, there are many relevant features and many irrelevant ones Methods that combine evidence from many or all features (e.g. naive Bayes, knn, neural-nets) often tend to work better than ones that try to isolate just a few relevant features (standard decision-tree or rule induction)* *Although the results are a bit more mixed than often thought 46

Which classifier do I use for a given text classification problem? 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. 47

References IIR 14 Fabrizio Sebastiani. Machine Learning in Automated Text Categorization. ACM Computing Surveys, 34(1):1-47, 2002. Tom Mitchell, Machine Learning. McGraw-Hill, 1997. Yiming Yang & Xin Liu, A re-examination of text categorization methods. Proceedings of SIGIR, 1999. Evaluating and Optimizing Autonomous Text Classification Systems (1995) David Lewis. Proceedings of the 18th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval Trevor Hastie, Robert Tibshirani and Jerome Friedman, Elements of Statistical Learning: Data Mining, Inference and Prediction. Springer-Verlag, New York. Open Calais: Automatic Semantic Tagging Free (but they can keep y our data), provided by Thompson/Reuters Weka: A data mining software package that includes an implementation of many ML algorithms 48