SlideShare una empresa de Scribd logo
1 de 12
Twitter Sentiment Analysis using
Python and NLTK
Presentation by:
ASHWIN PERTI,
Department of IT
Sentiment Analysis using PYTHON
The purpose of this Sentiment Analysis is:
● Able to automatically classify a tweet as a
positive
OR
● Negative tweet Sentiment wise
Sentiment Analysis using PYTHON
● The classifier needs to be trained:
● We need a list of manually classified tweets.
Positive Tweets
● I love this car
● This view is amazing
● I feel great this morning
● I am so excited about the concert
● He is my best friend
Negative Tweets
● I do not like this car
● This view is horrible
● I feel tired this morning
● I am not looking forward to the concert
● He is my enemy
Test Tweets
● TEST SET – to assess the exactitude of the
trained classifier
● I feel happy this morning. positive
● Larry is my friend. positive
● I do not like that man. negative
● My house not great. negative
● Your song annoying. negative
CLASSIFIER
● The list of word features need to be extracted
from the tweets.
● It is a list with every distinct words ordered by
frequency of appearance.
CLASSIFIER – Feature Extractor
● To decide which features are more relevant.
● The one we are going to use returns a
dictionary indicating that words are contained
in the input passed.
● INPUT - tweet
classifier=nltk.NaiveBayesClassifier.
train(training_set)
Naive Bayes Classifier
● It uses the prior probability of each label – which is
the frequency of each label in the training set and the
contribution from each feature.
● In our case, the frequency of each label is the same
for 'positive' and 'negative'.
● Word 'amazing' appears in 1 of 5 of the positive
tweets and none of the negative tweets.
● This means that the likelihood of the 'positive' label
will be multiplied by 0.2 when this word is seen as
part of the input.
CLASSIFY
● Now that we have our classifier initialized,
● Classify a tweet and
● See what the sentiment type output is:
● Our classifier is able to detect that this tweet
has a positive sentiment because
● Of the word 'friend'
● Which is associated to the positive tweet:
● 'He is my best friend'
print extract_features(tweet2.split())
● 'contains(looking)': False,
'contains(feel)': False,
● 'contains(the)': False,
● 'contains(excited)': False,
● 'contains(about)': False,
● 'contains(great)': False,
● 'contains(horrible)': False,
● 'contains(car)': False,
● 'contains(this)': False,
● 'contains(best)': False,
● 'contains(friend)': True,
● 'contains(concert)': False,
● 'contains(forward)': False,
● 'contains(view)': False,
● 'contains(tired)': False,
● 'contains(like)': False,
● 'contains(love)': False,
● 'contains(amazing)': False,
● 'contains(enemy)': False,
● 'contains(not)': True,
● 'contains(morning)': False}

Más contenido relacionado

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 

Destacado

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destacado (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Sentiments Analysis using Python and nltk

  • 1. Twitter Sentiment Analysis using Python and NLTK Presentation by: ASHWIN PERTI, Department of IT
  • 2. Sentiment Analysis using PYTHON The purpose of this Sentiment Analysis is: ● Able to automatically classify a tweet as a positive OR ● Negative tweet Sentiment wise
  • 3. Sentiment Analysis using PYTHON ● The classifier needs to be trained: ● We need a list of manually classified tweets.
  • 4. Positive Tweets ● I love this car ● This view is amazing ● I feel great this morning ● I am so excited about the concert ● He is my best friend
  • 5. Negative Tweets ● I do not like this car ● This view is horrible ● I feel tired this morning ● I am not looking forward to the concert ● He is my enemy
  • 6. Test Tweets ● TEST SET – to assess the exactitude of the trained classifier ● I feel happy this morning. positive ● Larry is my friend. positive ● I do not like that man. negative ● My house not great. negative ● Your song annoying. negative
  • 7. CLASSIFIER ● The list of word features need to be extracted from the tweets. ● It is a list with every distinct words ordered by frequency of appearance.
  • 8. CLASSIFIER – Feature Extractor ● To decide which features are more relevant. ● The one we are going to use returns a dictionary indicating that words are contained in the input passed. ● INPUT - tweet
  • 10. Naive Bayes Classifier ● It uses the prior probability of each label – which is the frequency of each label in the training set and the contribution from each feature. ● In our case, the frequency of each label is the same for 'positive' and 'negative'. ● Word 'amazing' appears in 1 of 5 of the positive tweets and none of the negative tweets. ● This means that the likelihood of the 'positive' label will be multiplied by 0.2 when this word is seen as part of the input.
  • 11. CLASSIFY ● Now that we have our classifier initialized, ● Classify a tweet and ● See what the sentiment type output is: ● Our classifier is able to detect that this tweet has a positive sentiment because ● Of the word 'friend' ● Which is associated to the positive tweet: ● 'He is my best friend'
  • 12. print extract_features(tweet2.split()) ● 'contains(looking)': False, 'contains(feel)': False, ● 'contains(the)': False, ● 'contains(excited)': False, ● 'contains(about)': False, ● 'contains(great)': False, ● 'contains(horrible)': False, ● 'contains(car)': False, ● 'contains(this)': False, ● 'contains(best)': False, ● 'contains(friend)': True, ● 'contains(concert)': False, ● 'contains(forward)': False, ● 'contains(view)': False, ● 'contains(tired)': False, ● 'contains(like)': False, ● 'contains(love)': False, ● 'contains(amazing)': False, ● 'contains(enemy)': False, ● 'contains(not)': True, ● 'contains(morning)': False}