Docsity

Introduction to Classification - Lecture Notes | LING 570, Study notes of Linguistics

Partial preview of the text

Download Introduction to Classification - Lecture Notes | LING 570 and more Study notes Linguistics in PDF only on Docsity!

Introduction to Classification

LING 570

Fei Xia

Week 9: 11/19/

Outline

  • What is a classification problem?
  • How to solve a classification problem?
  • Case study

An example: text classification task

  • Task: given an article, predict its category.
  • Categories:
    • Politics, sports, entertainment, travel, …
    • Spam or not spam
  • What kind of information is useful to solve

the problem?

Classification task

  • Task:
    • C is a finite set of labels (a.k.a. categories, classes)
    • Given a x, decide its category y 2 C.
  • Instance: (x, y)
    • x: the thing to be labeled/classified
    • y 2 C.
  • Data: a set of instances
    • Labeled data: y is known
    • Unlabeled data: y is unknown
  • Training data, test data

POS tagging

  • Task: given a sentence, predict the tag of each word in the sentence.
  • Is it a classification problem?
  • Categories: noun, verb, adjective, …
  • What information is useful?
  • What are the differences between the text classification task and POS tagging?  Sequence labeling problem

Tokenization / Word segmentation

  • Task: given a string, break it into words.
  • Categories:
    • NB (no break), B (with break)
    • B (beginning), I (inside), E (end)
  • Ex: c1 c2 || c3 c4 c
    • c1/NB c2/B c3/NB c4/NB c5/B
    • c1/B c2/E c3/B c4/I c5/E
  • Relation to POS tagging?

Two stages

  • Training stage
    • Learner : Training data  classifier
  • Testing stage
    • Decoder : Test data * classifier  classification results
  • Others:
    • Preprocessing stage
    • Postprocessing stage
    • Evaluation

How to represent x?

  • The number of possible values for x could be infinite.
  • Representing x as a feature vector: x=<v 1 ,v 2 ,…, v n

x=<f 1 =v 1 ,f 2 =v 2 ,…, f n =v n

  • What is a good feature?

Training data: attribute-value table (Input to the training stage) f 1 f 2 … f K Target x 1 0 1 2.5 -1000 c 2 x 2 2.5 0 0 20 c 1 x 3 … x n

A classifier

  • It is the output of the training stage.
  • Narrow definition:
    • f(x) = y, x is input, y 2 C
  • More general definition:
    • f(x) = {(c i , score i )}, c i 2 C.

Evaluation

  • Precision = TP/(TP+FP)
  • Recall = TP/(TP+FN)
  • F-score = 2PR/(P+R)
  • Accuracy=(TP+TN)/(TP+TN+FP+FN)
  • F-score or Accuracy?
  • Why F-score? Gold System

+ TP FP

- FN TN

An Example

  • Accuracy=91%
  • Precision = 1/
  • Recall = 1/
  • F-score = Gold System

Important subtasks (for you)

  • Convert the problem into a classification task
  • Converting the data into attribute-value table
    • Define feature types
    • Feature selection
    • Convert an instance into a feature vector
  • Select a classification algorithm

Classification algorithms

  • Decision Tree (DT)
  • K nearest neighbor (kNN)
  • Naïve Bayes (NB)
  • Maximum Entropy (MaxEnt)*
  • Supporting vector machine (SVM)**
  • Conditional random field (CRF)**
  • …

 Will be covered in LING