Advanced Mul,media Text Classifica,on Tamara Berg Slide - - PowerPoint PPT Presentation

advanced mul media
SMART_READER_LITE
LIVE PREVIEW

Advanced Mul,media Text Classifica,on Tamara Berg Slide - - PowerPoint PPT Presentation

Advanced Mul,media Text Classifica,on Tamara Berg Slide from Dan Klein Slide from Dan Klein Today! Slide from Dan Klein What does


slide-1
SLIDE 1

Advanced ¡Mul,media ¡

Text ¡Classifica,on ¡ Tamara ¡Berg ¡

slide-2
SLIDE 2

Slide ¡from ¡Dan ¡Klein ¡

slide-3
SLIDE 3

Slide ¡from ¡Dan ¡Klein ¡

slide-4
SLIDE 4

Slide ¡from ¡Dan ¡Klein ¡

Today! ¡

slide-5
SLIDE 5

What ¡does ¡categoriza,on/classifica,on ¡ mean? ¡

slide-6
SLIDE 6

Slide ¡from ¡Dan ¡Klein ¡

slide-7
SLIDE 7

Slide ¡from ¡Dan ¡Klein ¡

slide-8
SLIDE 8

Slide ¡from ¡Dan ¡Klein ¡

slide-9
SLIDE 9

Slide ¡from ¡Dan ¡Klein ¡

slide-10
SLIDE 10

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-11
SLIDE 11

Slide ¡from ¡Dan ¡Klein ¡

hFp://yann.lecun.com/exdb/mnist/index.html ¡

slide-12
SLIDE 12

Slide ¡from ¡Dan ¡Klein ¡

slide-13
SLIDE 13

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-14
SLIDE 14

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-15
SLIDE 15

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-16
SLIDE 16

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

  • Machine ¡Learning ¡-­‑ ¡how ¡to ¡select ¡a ¡model ¡on ¡

the ¡basis ¡of ¡data ¡/ ¡experience ¡ ¡ ¡Learning ¡parameters ¡(e.g. ¡probabili,es) ¡ ¡ ¡Learning ¡structure ¡(e.g. ¡dependencies) ¡ ¡ ¡Learning ¡hidden ¡concepts ¡(e.g. ¡clustering) ¡

slide-17
SLIDE 17
slide-18
SLIDE 18

Classifiers ¡

  • Today ¡we’ll ¡talk ¡about ¡2 ¡simple ¡kinds ¡of ¡

classifiers ¡

– Nearest ¡Neighbor ¡Classifier ¡ – Naïve ¡Bayes ¡Classifier ¡

slide-19
SLIDE 19

Classifiers ¡

  • Today ¡we’ll ¡talk ¡about ¡2 ¡simple ¡kinds ¡of ¡

classifiers ¡

– Nearest ¡Neighbor ¡Classifier ¡ – Naïve ¡Bayes ¡Classifier ¡

slide-20
SLIDE 20

Document ¡Vectors ¡

slide-21
SLIDE 21

Document ¡Vectors ¡

  • Represent ¡document ¡as ¡a ¡“bag ¡of ¡words” ¡
slide-22
SLIDE 22

Example ¡

  • Doc1 ¡= ¡“the ¡quick ¡brown ¡fox ¡jumped” ¡
  • Doc2 ¡= ¡“brown ¡quick ¡jumped ¡fox ¡the” ¡
slide-23
SLIDE 23

Example ¡

  • Doc1 ¡= ¡“the ¡quick ¡brown ¡fox ¡jumped” ¡
  • Doc2 ¡= ¡“brown ¡quick ¡jumped ¡fox ¡the” ¡

Would ¡a ¡bag ¡of ¡words ¡model ¡represent ¡these ¡ two ¡documents ¡differently? ¡ ¡

slide-24
SLIDE 24

Document ¡Vectors ¡

  • Documents ¡are ¡represented ¡as ¡“bags ¡of ¡words” ¡
  • Represented ¡as ¡vectors ¡when ¡used ¡computa8onally ¡
  • Each ¡vector ¡holds ¡a ¡place ¡for ¡every ¡term ¡in ¡the ¡collec,on ¡
  • Therefore, ¡most ¡vectors ¡are ¡sparse ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-25
SLIDE 25

Document ¡Vectors ¡

  • Documents ¡are ¡represented ¡as ¡“bags ¡of ¡words” ¡
  • Represented ¡as ¡vectors ¡when ¡used ¡computa8onally ¡
  • Each ¡vector ¡holds ¡a ¡place ¡for ¡every ¡term ¡in ¡the ¡collec,on ¡
  • Therefore, ¡most ¡vectors ¡are ¡sparse ¡

Slide ¡from ¡Mitch ¡Marcus ¡

Lexicon ¡– ¡the ¡vocabulary ¡set ¡that ¡you ¡consider ¡to ¡be ¡valid ¡ words ¡in ¡your ¡documents. ¡ ¡ ¡Usually ¡stemmed ¡(e.g. ¡running-­‑>run) ¡

slide-26
SLIDE 26

Document ¡Vectors: ¡ One ¡loca,on ¡for ¡each ¡word. ¡ ¡

nova galaxy heat h’wood film role diet fur 10 5 3 5 10 10 8 7 9 10 5 10 10 9 10 5 7 9 6 10 2 8 7 5 1 3 A A B B C C D D E E F F G G H H I I

“Nova” ¡occurs ¡10 ¡,mes ¡in ¡text ¡A ¡ “Galaxy” ¡occurs ¡5 ¡,mes ¡in ¡text ¡A ¡ “Heat” ¡occurs ¡3 ¡,mes ¡in ¡text ¡A ¡ (Blank ¡means ¡0 ¡occurrences.) ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-27
SLIDE 27

Document ¡Vectors: ¡ One ¡loca,on ¡for ¡each ¡word. ¡ ¡

nova galaxy heat h’wood film role diet fur 10 5 3 5 10 10 8 7 9 10 5 10 10 9 10 5 7 9 6 10 2 8 7 5 1 3 A A B B C C D D E E F F G G H H I I

“Nova” ¡occurs ¡10 ¡,mes ¡in ¡text ¡A ¡ “Galaxy” ¡occurs ¡5 ¡,mes ¡in ¡text ¡A ¡ “Heat” ¡occurs ¡3 ¡,mes ¡in ¡text ¡A ¡ (Blank ¡means ¡0 ¡occurrences.) ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-28
SLIDE 28

Document ¡Vectors ¡ ¡

nova galaxy heat h’wood film role diet fur 10 5 3 5 10 10 8 7 9 10 5 10 10 9 10 5 7 9 6 10 2 8 7 5 1 3 A A B B C C D D E E F F G G H H I I

Document ids

Slide ¡from ¡Mitch ¡Marcus ¡

slide-29
SLIDE 29

Vector ¡Space ¡Model ¡

  • Documents ¡are ¡represented ¡as ¡vectors ¡in ¡term ¡space ¡
  • Terms ¡are ¡usually ¡stems ¡
  • Documents ¡represented ¡by ¡vectors ¡of ¡terms ¡
  • A ¡vector ¡distance ¡measures ¡similarity ¡between ¡documents ¡

¡

  • Document ¡similarity ¡is ¡based ¡on ¡length ¡and ¡direc,on ¡of ¡their ¡vectors

¡

  • Terms ¡in ¡a ¡vector ¡can ¡be ¡“weighted” ¡in ¡many ¡ways ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-30
SLIDE 30

Document ¡Vectors ¡ ¡

nova galaxy heat h’wood film role diet fur 10 5 3 5 10 10 8 7 9 10 5 10 10 9 10 5 7 9 6 10 2 8 7 5 1 3 A A B B C C D D E E F F G G H H I I

Document ids

Slide ¡from ¡Mitch ¡Marcus ¡

slide-31
SLIDE 31

Similarity ¡between ¡documents ¡

A ¡= ¡[10 ¡5 ¡3 ¡0 ¡0 ¡0 ¡0 ¡0]; ¡ G ¡= ¡[5 ¡0 ¡7 ¡0 ¡0 ¡9 ¡0 ¡0]; ¡ E ¡= ¡[0 ¡0 ¡0 ¡0 ¡0 ¡10 ¡10 ¡0]; ¡

slide-32
SLIDE 32

Similarity ¡between ¡documents ¡

A ¡= ¡[10 ¡ ¡5 ¡ ¡3 ¡ ¡0 ¡ ¡ ¡0 ¡ ¡ ¡ ¡ ¡0 ¡ ¡ ¡ ¡0 ¡ ¡ ¡0]; ¡ G ¡= ¡[ ¡ ¡5 ¡ ¡0 ¡ ¡7 ¡ ¡0 ¡ ¡ ¡0 ¡ ¡ ¡ ¡ ¡9 ¡ ¡ ¡ ¡0 ¡ ¡ ¡0]; ¡ E ¡= ¡ ¡[ ¡ ¡0 ¡ ¡0 ¡ ¡0 ¡ ¡0 ¡ ¡ ¡0 ¡ ¡10 ¡ ¡10 ¡ ¡ ¡0]; ¡ Treat ¡the ¡vectors ¡as ¡binary ¡= ¡number ¡of ¡words ¡in ¡

  • common. ¡ ¡

Sb(A,G) ¡= ¡? ¡ Sb(A,E) ¡= ¡? ¡ Sb(G,E) ¡= ¡? ¡ Which ¡pair ¡of ¡documents ¡are ¡the ¡most ¡similar? ¡

slide-33
SLIDE 33

Similarity ¡between ¡documents ¡

A ¡= ¡[10 ¡5 ¡3 ¡0 ¡0 ¡0 ¡0 ¡0]; ¡ G ¡= ¡[5 ¡0 ¡7 ¡0 ¡0 ¡9 ¡0 ¡0]; ¡ E ¡= ¡[0 ¡0 ¡0 ¡0 ¡0 ¡10 ¡10 ¡0]; ¡ Sum ¡of ¡Squared ¡Distances ¡(SSD) ¡= ¡ ¡ SSD(A,G) ¡= ¡? ¡ SSD(A,E) ¡= ¡? ¡ SSD(G,E) ¡= ¡? ¡

(Xi

i=1 n

−Yi)2

slide-34
SLIDE 34

Similarity ¡between ¡documents ¡

A ¡= ¡[10 ¡5 ¡3 ¡0 ¡0 ¡0 ¡0 ¡0]; ¡ G ¡= ¡[5 ¡0 ¡7 ¡0 ¡0 ¡9 ¡0 ¡0]; ¡ E ¡= ¡[0 ¡0 ¡0 ¡0 ¡0 ¡10 ¡10 ¡0]; ¡ Angle ¡between ¡vectors: ¡Cos(θ) ¡= ¡ ¡

a⋅ b a b

Dot ¡Product: ¡ Length ¡(Euclidean ¡norm): ¡ a =

a2

1 + a2 2 + ...+ a2 n

slide-35
SLIDE 35

Some ¡words ¡give ¡more ¡informa,on ¡ than ¡others ¡

  • Does ¡the ¡fact ¡that ¡two ¡documents ¡both ¡

contain ¡the ¡word ¡“the” ¡tell ¡us ¡anything? ¡How ¡ about ¡“and”? ¡Stop ¡words ¡(noise ¡words): ¡ Words ¡that ¡are ¡probably ¡not ¡useful ¡for ¡

  • processing. ¡Filtered ¡out ¡before ¡natural ¡

language ¡is ¡applied. ¡

  • Other ¡words ¡can ¡be ¡more ¡or ¡less ¡informa,ve. ¡ ¡

No ¡defini,ve ¡list ¡but ¡might ¡include ¡things ¡like: ¡ ¡ hFp://www.dcs.gla.ac.uk/idom/ir_resources/linguis,c_u,ls/stop_words ¡

slide-36
SLIDE 36

Some ¡words ¡give ¡more ¡informa,on ¡ than ¡others ¡

  • Does ¡the ¡fact ¡that ¡two ¡documents ¡both ¡

contain ¡the ¡word ¡“the” ¡tell ¡us ¡anything? ¡How ¡ about ¡“and”? ¡Stop ¡words ¡(noise ¡words): ¡ Words ¡that ¡are ¡probably ¡not ¡useful ¡for ¡

  • processing. ¡Filtered ¡out ¡before ¡natural ¡

language ¡is ¡applied. ¡

  • Other ¡words ¡can ¡be ¡more ¡or ¡less ¡informa,ve. ¡ ¡

No ¡defini,ve ¡list ¡but ¡might ¡include ¡things ¡like: ¡ ¡ hFp://www.dcs.gla.ac.uk/idom/ir_resources/linguis,c_u,ls/stop_words ¡

slide-37
SLIDE 37

Vector ¡Space ¡Model ¡

  • Documents ¡are ¡represented ¡as ¡vectors ¡in ¡term ¡space ¡
  • Terms ¡are ¡usually ¡stems ¡
  • Documents ¡represented ¡by ¡vectors ¡of ¡terms ¡
  • A ¡vector ¡distance ¡measures ¡similarity ¡between ¡documents ¡

¡

  • Document ¡similarity ¡is ¡based ¡on ¡length ¡and ¡direc,on ¡of ¡their ¡vectors

¡

  • Terms ¡in ¡a ¡vector ¡can ¡be ¡“weighted” ¡in ¡many ¡ways ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-38
SLIDE 38

Assigning ¡Weights ¡to ¡Terms ¡

 Binary ¡Weights ¡  Raw ¡term ¡frequency ¡ ¡  @ ¡x ¡idf ¡

  • Want ¡to ¡weight ¡terms ¡highly ¡if ¡they ¡are ¡

— frequent ¡in ¡relevant ¡documents ¡… ¡BUT ¡ — infrequent ¡in ¡the ¡collec,on ¡as ¡a ¡whole ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-39
SLIDE 39

TF ¡x ¡IDF ¡Weights ¡

  • @ ¡x ¡idf ¡measure: ¡
  • Term ¡Frequency ¡(t) ¡– ¡how ¡ouen ¡a ¡term ¡appears ¡in ¡a ¡document ¡
  • Inverse ¡Document ¡Frequency ¡(idf) ¡-­‑-­‑ ¡a ¡way ¡to ¡deal ¡with ¡terms ¡that ¡

are ¡frequent ¡across ¡many ¡documents ¡

  • Goal: ¡Assign ¡a ¡@ ¡* ¡idf ¡weight ¡to ¡each ¡term ¡in ¡each ¡

document ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-40
SLIDE 40

TF ¡x ¡IDF ¡Calcula,on ¡

Tk = term k in document Di tfik = frequency of term Tk in document Di idfk = inverse document frequency of term T

k in C

N = total number of documents in the collection C nk = the number of documents in C that contain Tk idfk = log N

k

n

( )

Slide ¡from ¡Mitch ¡Marcus ¡

slide-41
SLIDE 41

TF ¡x ¡IDF ¡Calcula,on ¡

Tk = term k in document Di tfik = frequency of term Tk in document Di idfk = inverse document frequency of term T

k in C

N = total number of documents in the collection C nk = the number of documents in C that contain Tk idfk = log N

k

n

( )

Slide ¡from ¡Mitch ¡Marcus ¡

slide-42
SLIDE 42

TF ¡x ¡IDF ¡Calcula,on ¡

Tk = term k in document Di tfik = frequency of term Tk in document Di idfk = inverse document frequency of term T

k in C

N = total number of documents in the collection C nk = the number of documents in C that contain Tk idfk = log N

k

n

( )

Slide ¡from ¡Mitch ¡Marcus ¡

slide-43
SLIDE 43

Inverse ¡Document ¡Frequency ¡

  • IDF ¡provides ¡high ¡values ¡for ¡rare ¡words ¡and ¡low ¡values ¡

for ¡common ¡words ¡

For ¡a ¡collec,on ¡

  • f ¡10000 ¡

documents ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-44
SLIDE 44

TF ¡x ¡IDF ¡Normaliza,on ¡

  • Normalize ¡the ¡term ¡weights ¡(so ¡longer ¡documents ¡are ¡

not ¡unfairly ¡given ¡more ¡weight) ¡

  • The ¡longer ¡the ¡document, ¡the ¡more ¡likely ¡it ¡is ¡for ¡a ¡given ¡term ¡to ¡

appear ¡in ¡it, ¡and ¡the ¡more ¡ouen ¡a ¡given ¡term ¡is ¡likely ¡to ¡appear ¡in ¡

  • it. ¡So, ¡we ¡want ¡to ¡reduce ¡the ¡importance ¡aFached ¡to ¡a ¡term ¡

appearing ¡in ¡a ¡document ¡based ¡on ¡the ¡length ¡of ¡the ¡document. ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-45
SLIDE 45

Pair-­‑wise ¡Document ¡Similarity ¡

D

1 = w11,w12,...,w1n

D2 = w21,w22,...,w2n sim(D

1,D2) =

w1i ∗ w2i

i=1 n

(w1i)2 ∗

i=1 n

(w2i)2

i=1 n

Documents ¡now ¡represented ¡as ¡vectors ¡of ¡TFxIDF ¡weights ¡

Similarity ¡can ¡be ¡ computed ¡as ¡usual ¡

  • n ¡these ¡new ¡

weight ¡vectors ¡ (e.g. ¡cos(θ) ¡here) ¡

Slide ¡from ¡Mitch ¡Marcus ¡

nova galaxy heat h’wood film role diet fur 1 3 1 5 2 2 1 5 4 1

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

A B C D

slide-46
SLIDE 46

Pair-­‑wise ¡Document ¡Similarity ¡

D

1 = w11,w12,...,w1n

D2 = w21,w22,...,w2n sim(D

1,D2) =

w1i ∗ w2i

i=1 n

(w1i)2 ∗

i=1 n

(w2i)2

i=1 n

Documents ¡now ¡represented ¡as ¡vectors ¡of ¡TFxIDF ¡weights ¡

Similarity ¡can ¡be ¡ computed ¡as ¡usual ¡

  • n ¡these ¡new ¡

weight ¡vectors ¡ (e.g. ¡cos(θ) ¡here) ¡

Slide ¡from ¡Mitch ¡Marcus ¡

slide-47
SLIDE 47

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

Here ¡the ¡vector ¡space ¡is ¡illustrated ¡as ¡having ¡2 ¡dimensions. ¡How ¡ many ¡dimensions ¡would ¡the ¡data ¡actually ¡live ¡in? ¡

slide-48
SLIDE 48

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

Query ¡document ¡– ¡which ¡class ¡should ¡you ¡label ¡it ¡with? ¡

slide-49
SLIDE 49

Classifica,on ¡by ¡Nearest ¡Neighbor ¡

Classify ¡the ¡test ¡document ¡as ¡the ¡class ¡of ¡the ¡document ¡“nearest” ¡to ¡the ¡query ¡ document ¡(use ¡vector ¡similarity ¡to ¡find ¡most ¡similar ¡doc) ¡

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-50
SLIDE 50

Classifica,on ¡by ¡kNN ¡

Classify ¡the ¡test ¡document ¡as ¡the ¡majority ¡class ¡of ¡the ¡k ¡documents ¡ “nearest” ¡to ¡the ¡query ¡document. ¡

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-51
SLIDE 51

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-52
SLIDE 52

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-53
SLIDE 53

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-54
SLIDE 54

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-55
SLIDE 55

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

slide-56
SLIDE 56
slide-57
SLIDE 57

Slide ¡from ¡Min-­‑Yen ¡Kan ¡

What ¡are ¡the ¡features? ¡What’s ¡the ¡training ¡data? ¡Tes,ng ¡data? ¡ Parameters? ¡ ¡

Classifica,on ¡by ¡kNN ¡

slide-58
SLIDE 58

Classifiers ¡

  • Today ¡we’ll ¡talk ¡about ¡2 ¡simple ¡kinds ¡of ¡

classifiers ¡

– Nearest ¡Neighbor ¡Classifier ¡ – Naïve ¡Bayes ¡Classifier ¡

Nearest ¡neighbor ¡treats ¡all ¡features ¡equally ¡whether ¡or ¡not ¡they ¡maFer ¡for ¡ the ¡classifica,on ¡task ¡(even ¡txIDF ¡weights ¡are ¡independent ¡of ¡document ¡ class). ¡Naïve ¡Bayes ¡lets ¡us ¡learn ¡which ¡features ¡are ¡most ¡indica,ve ¡for ¡ classifica,on. ¡

slide-59
SLIDE 59
slide-60
SLIDE 60

R ¡

A ¡random ¡variable ¡is ¡some ¡aspect ¡of ¡the ¡world ¡about ¡which ¡ we ¡(may) ¡have ¡uncertainty. ¡ ¡ Random ¡variables ¡can ¡be: ¡ ¡Binary ¡(e.g. ¡{true,false}, ¡{spam/ham}), ¡ ¡ ¡Take ¡on ¡a ¡discrete ¡set ¡of ¡values ¡ ¡ ¡ ¡(e.g. ¡{Spring, ¡Summer, ¡Fall, ¡Winter}), ¡ ¡ ¡Or ¡be ¡con,nuous ¡(e.g. ¡[0 ¡1]). ¡

slide-61
SLIDE 61
slide-62
SLIDE 62
slide-63
SLIDE 63
slide-64
SLIDE 64

Arrows ¡encode ¡rela,onships ¡between ¡ ¡ cariables ¡(causality): ¡

slide-65
SLIDE 65
slide-66
SLIDE 66
slide-67
SLIDE 67

Y ¡class ¡(e.g. ¡spam/ham) ¡ F

1,F2,...,Fn Features ¡(e.g. ¡words) ¡

slide-68
SLIDE 68
slide-69
SLIDE 69
slide-70
SLIDE 70
slide-71
SLIDE 71
slide-72
SLIDE 72

Percentage ¡of ¡ documents ¡in ¡ training ¡set ¡labeled ¡ as ¡spam/ham ¡

slide-73
SLIDE 73

In ¡the ¡documents ¡labeled ¡ as ¡spam, ¡occurrence ¡ percentage ¡of ¡each ¡word ¡ ¡ (e.g. ¡# ¡,mes ¡“the” ¡

  • ccurred/# ¡total ¡words). ¡
slide-74
SLIDE 74

In ¡the ¡documents ¡labeled ¡ as ¡ham, ¡occurrence ¡ percentage ¡of ¡each ¡word ¡ ¡ (e.g. ¡# ¡,mes ¡“the” ¡

  • ccurred/# ¡total ¡words). ¡
slide-75
SLIDE 75

Classifica,on ¡

The ¡class ¡that ¡maximizes: ¡ How ¡would ¡you ¡do ¡this? ¡

= argmaxC P(C) P(Wi |C)

i

slide-76
SLIDE 76

In ¡Prac,ce: ¡

Cmap = argmaxC log(P(C)) + log(P(Wi |C))

i

slide-77
SLIDE 77

Naïve ¡Bayes ¡

  • Is ¡this ¡a ¡“bag ¡of ¡words” ¡model? ¡
slide-78
SLIDE 78

600.465 ¡-­‑ ¡Intro ¡to ¡NLP ¡-­‑ ¡J. ¡ Eisner ¡ 78 ¡

Measuring ¡Performance ¡

  • Classifica,on ¡accuracy: ¡What ¡% ¡of ¡messages ¡

were ¡classified ¡correctly? ¡

  • Is ¡this ¡what ¡we ¡care ¡about? ¡

Overall accuracy Accuracy

  • n spam

Accuracy

  • n ling

System 1 95% 99.99% 90% System 2 95% 90% 99.99%

  • Which system do you prefer?
slide-79
SLIDE 79

600.465 ¡-­‑ ¡Intro ¡to ¡NLP ¡-­‑ ¡J. ¡ Eisner ¡ 79 ¡

Measuring ¡Performance ¡

  • Classifica,on ¡accuracy: ¡What ¡% ¡of ¡messages ¡

were ¡classified ¡correctly? ¡

  • Is ¡this ¡what ¡we ¡care ¡about? ¡

Overall accuracy Accuracy

  • n spam

Accuracy

  • n ham

System 1 95% 99.99% 90% System 2 95% 90% 99.99%

  • Which system do you prefer?
slide-80
SLIDE 80

600.465 ¡-­‑ ¡Intro ¡to ¡NLP ¡-­‑ ¡J. ¡Eisner ¡ 80 ¡

Measuring ¡Performance ¡

  • Precision ¡= ¡ ¡

good ¡messages ¡kept ¡ ¡ ¡all ¡messages ¡kept ¡

  • Recall ¡= ¡

good ¡messages ¡kept ¡ ¡all ¡good ¡messages ¡ Trade off precision vs. recall by setting threshold Measure the curve on annotated data Choose a threshold where user is comfortable

slide-81
SLIDE 81

600.465 ¡-­‑ ¡Intro ¡to ¡NLP ¡-­‑ ¡J. ¡ Eisner ¡ 81 ¡

Measuring ¡Performance ¡

low threshold: keep all the good stuff, but a lot of the bad too high threshold: all we keep is good, but we don’t keep much OK for spam filtering and legal search OK for search engines (maybe) would prefer to be here! point where precision=recall (often reported)

slide-82
SLIDE 82

Naive ¡Bayes ¡is ¡Not ¡So ¡Naive ¡

  • Naïve ¡Bayes: ¡First ¡and ¡Second ¡place ¡in ¡KDD-­‑CUP ¡97 ¡compe88on, ¡among ¡16 ¡(then) ¡state ¡of ¡

the ¡art ¡algorithms ¡

¡Goal: ¡Financial ¡services ¡industry ¡direct ¡mail ¡response ¡predic,on ¡model: ¡Predict ¡if ¡the ¡recipient ¡of ¡mail ¡will ¡actually ¡

respond ¡to ¡the ¡adver,sement ¡– ¡750,000 ¡records. ¡

  • Robust ¡to ¡Irrelevant ¡Features ¡

¡Irrelevant ¡Features ¡cancel ¡each ¡other ¡without ¡affec,ng ¡results ¡

  • Very ¡good ¡in ¡Domains ¡with ¡many ¡equally ¡important ¡features ¡
  • A ¡good ¡dependable ¡baseline ¡for ¡text ¡classifica8on ¡(but ¡not ¡the ¡best)! ¡
  • Op8mal ¡if ¡the ¡Independence ¡Assump8ons ¡hold: ¡If ¡assumed ¡independence ¡is ¡correct, ¡then ¡it ¡

is ¡the ¡Bayes ¡Op8mal ¡Classifier ¡for ¡problem ¡

  • Very ¡Fast: ¡Learning ¡with ¡one ¡pass ¡over ¡the ¡data; ¡tes8ng ¡linear ¡in ¡the ¡number ¡of ¡a^ributes, ¡and ¡

document ¡collec8on ¡size ¡

  • Low ¡Storage ¡requirements ¡

Slide ¡from ¡Mitch ¡Marcus ¡