sentiment analysis
play

Sentiment Analysis A Baseline Algorithm Dan Jurafsky - PowerPoint PPT Presentation

Sentiment Analysis A Baseline Algorithm Dan Jurafsky Sentiment Classification in Movie Reviews Bo Pang, Lillian Lee, and Shivakumar Vaithyanathan. 2002. Thumbs up?


  1. Sentiment Analysis A ¡Baseline ¡ Algorithm ¡

  2. Dan ¡Jurafsky ¡ Sentiment Classification in Movie Reviews Bo ¡Pang, ¡Lillian ¡Lee, ¡and ¡Shivakumar ¡Vaithyanathan. ¡ ¡2002. ¡ ¡Thumbs ¡up? ¡Sen+ment ¡ Classifica+on ¡using ¡Machine ¡Learning ¡Techniques. ¡EMNLP-­‑2002, ¡79—86. ¡ Bo ¡Pang ¡and ¡Lillian ¡Lee. ¡ ¡2004. ¡ ¡A ¡Sen+mental ¡Educa+on: ¡Sen+ment ¡Analysis ¡Using ¡ Subjec+vity ¡Summariza+on ¡Based ¡on ¡Minimum ¡Cuts. ¡ ¡ACL, ¡271-­‑278 ¡ • Polarity ¡detec+on: ¡ • Is ¡an ¡IMDB ¡movie ¡review ¡posi+ve ¡or ¡nega+ve? ¡ • Data: ¡ Polarity ¡Data ¡2.0: ¡ ¡ • hXp://www.cs.cornell.edu/people/pabo/movie-­‑review-­‑data ¡

  3. Dan ¡Jurafsky ¡ IMDB ¡data ¡in ¡the ¡Pang ¡and ¡Lee ¡database ¡ ✓ ¡ ✗ ¡ when ¡_star ¡wars_ ¡came ¡out ¡some ¡twenty ¡years ¡ “ ¡snake ¡eyes ¡” ¡is ¡the ¡most ¡aggrava+ng ¡ ago ¡, ¡the ¡image ¡of ¡traveling ¡throughout ¡the ¡stars ¡ kind ¡of ¡movie ¡: ¡the ¡kind ¡that ¡shows ¡so ¡ has ¡become ¡a ¡commonplace ¡image ¡. ¡[…] ¡ much ¡poten+al ¡then ¡becomes ¡ unbelievably ¡disappoin+ng ¡. ¡ ¡ when ¡han ¡solo ¡goes ¡light ¡speed ¡, ¡the ¡stars ¡change ¡ to ¡bright ¡lines ¡, ¡going ¡towards ¡the ¡viewer ¡in ¡lines ¡ it’s ¡not ¡just ¡because ¡this ¡is ¡a ¡brian ¡ that ¡converge ¡at ¡an ¡invisible ¡point ¡. ¡ ¡ depalma ¡film ¡, ¡and ¡since ¡he’s ¡a ¡great ¡ director ¡and ¡one ¡who’s ¡films ¡are ¡always ¡ cool ¡. ¡ ¡ greeted ¡with ¡at ¡least ¡some ¡fanfare ¡. ¡ ¡ _october ¡sky_ ¡offers ¡a ¡much ¡simpler ¡image–that ¡of ¡ and ¡it’s ¡not ¡even ¡because ¡this ¡was ¡a ¡film ¡ a ¡single ¡white ¡dot ¡, ¡traveling ¡horizontally ¡across ¡the ¡ starring ¡nicolas ¡cage ¡and ¡since ¡he ¡gives ¡a ¡ night ¡sky ¡. ¡ ¡ ¡[. ¡. ¡. ¡] ¡ brauvara ¡performance ¡, ¡this ¡film ¡is ¡hardly ¡ worth ¡his ¡talents ¡. ¡ ¡

  4. Dan ¡Jurafsky ¡ Baseline ¡Algorithm ¡(adapted ¡from ¡Pang ¡ and ¡Lee) ¡ • Tokeniza+on ¡ • Feature ¡Extrac+on ¡ • Classifica+on ¡using ¡different ¡classifiers ¡ • Naïve ¡Bayes ¡ • MaxEnt ¡ • SVM ¡

  5. Dan ¡Jurafsky ¡ Sen%ment ¡Tokeniza%on ¡Issues ¡ • Deal ¡with ¡HTML ¡and ¡XML ¡markup ¡ • TwiXer ¡mark-­‑up ¡(names, ¡hash ¡tags) ¡ • Capitaliza+on ¡(preserve ¡for ¡ ¡ PoXs ¡emo+cons ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡words ¡in ¡all ¡caps) ¡ [<>]? # optional hat/brow � [:;=8] # eyes � [\-o\*\']? # optional nose � • Phone ¡numbers, ¡dates ¡ [\)\]\(\[dDpP/\:\}\{@\|\\] # mouth � | #### reverse orientation � • Emo+cons ¡ [\)\]\(\[dDpP/\:\}\{@\|\\] # mouth � [\-o\*\']? # optional nose � [:;=8] # eyes � • Useful ¡code: ¡ [<>]? # optional hat/brow � • Christopher ¡PoXs ¡sen+ment ¡tokenizer ¡ 21 ¡ • Brendan ¡O’Connor ¡twiXer ¡tokenizer ¡

  6. Dan ¡Jurafsky ¡ Extrac%ng ¡Features ¡for ¡Sen%ment ¡ Classifica%on ¡ • How ¡to ¡handle ¡nega+on ¡ • I didn’t like this movie � ¡ ¡ ¡vs ¡ • I really like this movie � • Which ¡words ¡to ¡use? ¡ • Only ¡adjec+ves ¡ • All ¡words ¡ • All ¡words ¡turns ¡out ¡to ¡work ¡beXer, ¡at ¡least ¡on ¡this ¡data ¡ 22 ¡

  7. Dan ¡Jurafsky ¡ Nega%on ¡ Das, ¡Sanjiv ¡and ¡Mike ¡Chen. ¡2001. ¡Yahoo! ¡for ¡Amazon: ¡Extrac+ng ¡market ¡sen+ment ¡from ¡stock ¡ message ¡boards. ¡In ¡Proceedings ¡of ¡the ¡Asia ¡Pacific ¡Finance ¡Associa+on ¡Annual ¡Conference ¡(APFA). ¡ Bo Pang, Lillian Lee, and Shivakumar Vaithyanathan. 2002. Thumbs up? Sentiment Classification using Machine Learning Techniques. EMNLP-2002, 79—86. Add ¡NOT_ ¡to ¡every ¡word ¡between ¡nega+on ¡and ¡following ¡punctua+on: ¡ didn’t like this movie , but I � didn’t NOT_like NOT_this NOT_movie but I �

  8. Dan ¡Jurafsky ¡ Reminder: ¡Naïve ¡Bayes ¡ " c NB = argmax P ( c j ) P ( w i | c j ) c j ! C i ! positions P ( w | c ) = count ( w , c ) + 1 ˆ count ( c ) + V 24 ¡

  9. Dan ¡Jurafsky ¡ Binarized ¡(Boolean ¡feature) ¡ ¡Mul%nomial ¡Naïve ¡Bayes ¡ • Intui+on: ¡ • For ¡sen+ment ¡(and ¡probably ¡for ¡other ¡text ¡classifica+on ¡domains) ¡ • Word ¡occurrence ¡may ¡maXer ¡more ¡than ¡word ¡frequency ¡ • The ¡occurrence ¡of ¡the ¡word ¡ fantas1c ¡tells ¡us ¡a ¡lot ¡ • The ¡fact ¡that ¡it ¡occurs ¡5 ¡+mes ¡may ¡not ¡tell ¡us ¡much ¡more. ¡ • Boolean ¡Mul+nomial ¡Naïve ¡Bayes ¡ • Clips ¡all ¡the ¡word ¡counts ¡in ¡each ¡document ¡at ¡1 ¡ 25 ¡

  10. Dan ¡Jurafsky ¡ Boolean ¡Mul%nomial ¡Naïve ¡Bayes: ¡Learning ¡ • From ¡training ¡corpus, ¡extract ¡ Vocabulary ¡ • Calculate ¡ P ( c j ) ¡ terms ¡ • Calculate ¡ P ( w k ¡ | ¡c j ) ¡ terms ¡ • For ¡each ¡ c j ¡ in ¡ C ¡do ¡ • Text j ¡ ← ¡single ¡doc ¡containing ¡all ¡ docs j ¡ • Remove ¡duplicates ¡in ¡each ¡doc: ¡ • For ¡each ¡word ¡type ¡w ¡in ¡doc j ¡ ¡ ¡ ¡docs j ¡ ← ¡ all ¡docs ¡with ¡ ¡class ¡= c j ¡ • For ¡ each ¡word ¡ w k ¡ in ¡ Vocabulary ¡ • Retain ¡only ¡a ¡single ¡instance ¡of ¡w ¡ ¡ ¡ ¡ ¡n k ¡ ← ¡# ¡of ¡occurrences ¡of ¡ w k ¡ in ¡ Text j ¡ | docs j | P ( c j ) ← n k + ! P ( w k | c j ) ← | total # documents| n + ! | Vocabulary |

  11. Dan ¡Jurafsky ¡ Boolean ¡Mul%nomial ¡Naïve ¡Bayes ¡ ¡on ¡a ¡test ¡document ¡ d ¡ • First ¡remove ¡all ¡duplicate ¡words ¡from ¡ d ¡ • Then ¡compute ¡NB ¡using ¡the ¡same ¡equa+on: ¡ ¡ " c NB = argmax P ( c j ) P ( w i | c j ) c j ! C i ! positions 27 ¡

  12. Dan ¡Jurafsky ¡ Normal ¡vs. ¡Boolean ¡Mul%nomial ¡NB ¡ Normal ¡ Doc ¡ Words ¡ Class ¡ Training ¡ 1 ¡ Chinese ¡Beijing ¡Chinese ¡ c ¡ 2 ¡ Chinese ¡Chinese ¡Shanghai ¡ c ¡ 3 ¡ Chinese ¡Macao ¡ c ¡ 4 ¡ Tokyo ¡Japan ¡Chinese ¡ j ¡ Test ¡ 5 ¡ Chinese ¡Chinese ¡Chinese ¡Tokyo ¡Japan ¡ ? ¡ Boolean ¡ Doc ¡ Words ¡ Class ¡ Training ¡ 1 ¡ Chinese ¡Beijing ¡ c ¡ 2 ¡ Chinese ¡Shanghai ¡ c ¡ 3 ¡ Chinese ¡Macao ¡ c ¡ 4 ¡ Tokyo ¡Japan ¡Chinese ¡ j ¡ Test ¡ 5 ¡ Chinese ¡Tokyo ¡Japan ¡ ? ¡ 28 ¡

  13. Dan ¡Jurafsky ¡ Binarized ¡(Boolean ¡feature) ¡ ¡ Mul%nomial ¡Naïve ¡Bayes ¡ B. ¡Pang, ¡L. ¡Lee, ¡and ¡S. ¡Vaithyanathan. ¡ ¡2002. ¡ ¡Thumbs ¡up? ¡Sen+ment ¡Classifica+on ¡using ¡Machine ¡Learning ¡ Techniques. ¡EMNLP-­‑2002, ¡79—86. ¡ V. ¡Metsis, ¡I. ¡Androutsopoulos, ¡G. ¡Paliouras. ¡2006. ¡Spam ¡Filtering ¡with ¡Naive ¡Bayes ¡– ¡Which ¡Naive ¡Bayes? ¡ CEAS ¡2006 ¡-­‑ ¡Third ¡Conference ¡on ¡Email ¡and ¡An+-­‑Spam. ¡ K.-­‑M. ¡Schneider. ¡2004. ¡On ¡word ¡frequency ¡informa+on ¡and ¡nega+ve ¡evidence ¡in ¡Naive ¡Bayes ¡text ¡ classifica+on. ¡ICANLP, ¡474-­‑485. ¡ JD ¡Rennie, ¡L ¡Shih, ¡J ¡Teevan. ¡2003. ¡Tackling ¡the ¡poor ¡assump+ons ¡of ¡naive ¡bayes ¡text ¡classifiers. ¡ICML ¡2003 ¡ • Binary ¡seems ¡to ¡work ¡beXer ¡than ¡full ¡word ¡counts ¡ • This ¡is ¡ not ¡the ¡same ¡as ¡Mul+variate ¡Bernoulli ¡Naïve ¡Bayes ¡ • MBNB ¡doesn’t ¡work ¡well ¡for ¡sen+ment ¡or ¡other ¡text ¡tasks ¡ • Other ¡possibility: ¡log(freq( w )) ¡ 29 ¡

  14. Dan ¡Jurafsky ¡ Cross-­‑Valida%on ¡ Iteration • Break ¡up ¡data ¡into ¡10 ¡folds ¡ 1 Test Training • (Equal ¡posi+ve ¡and ¡nega+ve ¡ inside ¡each ¡fold?) ¡ 2 Test Training • For ¡each ¡fold ¡ • Choose ¡the ¡fold ¡as ¡a ¡ 3 Training Test Training temporary ¡test ¡set ¡ • Train ¡on ¡9 ¡folds, ¡compute ¡ 4 Training Test performance ¡on ¡the ¡test ¡fold ¡ • Report ¡average ¡ Training 5 Test performance ¡of ¡the ¡10 ¡runs ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend