Report on Social Media Analytics
W5: DATA4500 Twitter-verse Sentiment Analysis using Natural Language Toolkit (NLTK) PART 1 A case study look into how machines process and understand human language using Twitterverse data.
DATA4500 Roadmap
Week 1 A Brief History
Week 2 User Behaviour &
Monetisation
Week 3 Methods of
Analysis
Week 4 Commercial
Opportunities
Week 5 Sentiment
Analysis – Part 1
Week 6 Assessment: Case Study 1
Week 7 Sentiment
Analysis – Part 2
Week 8 Insights Mining
Part 1
Week 9 Insights Mining
Part 2
Week 10 Ethical
Considerations Part 1
Week 11 Ethical
Considerations Part 2
Week 12 Assessment: Case Study 2
Lesson Learning Outcomes
1 Develop an understanding of the applications of Natural Language Processing.
2 Examine the differences between structured and unstructured data regimens.
3 Evaluate the steps involved in developing an NLP sentiment classifier.
4 Analyse and discuss the metrics used to measure model efficacy for the sentiment classification algorithm.
5 Consider the implications of language analysis for revealing hidden features and clusters.
Abraham Lincoln Reformed theologian, ethicist, commentator on politics and public affairs
“Public sentiment is everything. With public sentiment nothing can fail. Without it nothing can succeed.”
A finger on the pulse…
Case Study 1 Company Profile Australian based boutique tech consulting firm founded in 1994 by Pippa Ingram.
55 employees and growing.
Website: www.ionplus.io
Focus Areas • Accelerated commercialisation. • Research & Development assistance. • Cryptocurrency & blockchain. • AI risk management. • IT governance & compliance. • Data security & privacy. • Sustainability.
Project Categories Tech consulting is the nexus between a high end work force and the broader business community, providing subject matter expertise to innovators with great ideas and connecting entrepreneurs with tech talent.
AGILE firmware development for 5G infrastructure in
Singapore (Singtel)
Artificial Intelligence in next generation service chatbots
and recommendation engines.
Blockchain technology for smart contracts in exchange settled products (EuroNEXT).
Building cybersecurity resilience in mission critical systems and supply chains.
Cloud computing and SAAS innovations to rebuild cost
structures and minimize total cost of ownership.
Leverage the Network of Networks concept in platform
integration to extend influence.
Ready or Not…
Technology is empowering and endangering our way of life.
Those who fail to keep pace with the rate of change will be made irrelevant and redundant.
Miniaturised chipsets for cryptocurrency mining.
This chip is one tenth the surface area of a fingertip.
It can be implemented at scale to mine for Bitcoin with an efficient energy profile.
The Client Amazon Inc. is a US tech conglomerate focusing on cloud computing, e-commerce, digital streaming, and artificial intelligence.
Deep learning algorithms implemented through artificial neural networks provide real time feedback on:
• Flows across in Just-in-Time logistics networks. • The totality of customer reviews on every product
and service offered by Amazon. • Competitor intelligence and market sentiment. • Fraud detection & transactional forensics.
Cloud ComputingArtificial Intelligence
Crisis & Opportunity Monitoring Amazon Inc is one of a handful of companies that have benefited from the COVID-19 pandemic.
• Direct sales – strong growth.
• Significantly increased demand for web service products.
Despite the obvious good news, some analysts have detected potential negative macro headwinds:
• Elevated delays and errors in delivers.
• Discontent amongst warehouse and administrative staff who feel overworked and underpaid.
Crisis & Opportunity Monitoring How a company responds during times of crisis can have far reaching consequences…
Monitoring Sentiment Amazon has engaged Ion Plus to help them develop an omni-channel social sentiment analyser.
This tool will be used to provide Amazon with real time data on public sentiment toward the company.
Your approach is to develop a prototype sentiment analyser for Twitter using relevant tweet handles and hashtags to evaluate public sentiment.
STEP ONE Scrape AMZN related tweets.
STEP TWO Analyse language patterns within tweets for sentiment clues.
STEP THREE Develop summary statistics on Amazon tweets.
Activity 1 Q1.
Discuss the differences in communication style and format between:
• Social media (comments, posts, personal blogs) • Professional writing (emails, letters, articles)
Q2.
Amazon has an AI language tool that’s currently used to review formal documents such as business plans, internal memos and outgoing company mail.
Discuss whether it is possible to modify Amazon’s AI language tool so that it can be used to analyse informal communications such as those over social media.
Prototype Roadmap The following high level roadmap outlines the seven development stages for building and testing the Twitter sentiment analyser prototype…
ONE Get the tweets
TWO Break up tweets
THREE Sort words
FOUR Reduce noise
FIVE Word frequency
SIX Build model
SEVEN Visualise!
A Structureless World FACT: A vast amount of data that is generated today is unstructured.
FACT: Increasingly, gaining competitive advantage requires generating insights from unstructured data sources.
Examples of unstructured data: news articles, social media posts, search history, chat logs and audio / visual media.
Guiding Principles
NOTE:
Unstructured data still has some structure to it.
The ability to store and process data relies on there being some form of underlying structure.
Businesses like Amazon must manage structured and unstructured data to scale up…
Natural Language Processing (NLP) The process of analysing natural languages and deriving sense, context and meaning of it falls under the field of Natural Language Processing (NLP).
Applications There are FIVE key segments in the application of NLP.
Machine Translation Algorithmic translation
between natural languages.
Q&A Chatbots Automation of FAQs and
generic queries.
Info. Retrieval Search queries and search
engine optimisation.
Info. Extraction Identification of key markers
and references across content.
Sentiment Analysis Algorithmic translation
between natural languages.
Applications NLP is not a new concept. it has been widely implemented across multiple application with early examples in word process and, later, in predictive algorithms such as auto-correct.
Autocomplete helps users with search query and narrative suggestions.
Google search’s predictive typing helps users through next word’ recommendations.
Spell checker in your email application saves users from typing errors (mixed results here).
Spam detection in your mail box separates spam and phishing mails from regular mail.
Activity 2 Q1.
What are the differences between structured and unstructured data?
Q2. What is the reason behind unstructured data analysis being able to deliver more competitive advantage?
Q3. What are the major applications of Natural Language Processing for an organisation like Amazon?
NLP Terminologies To have a conversation about NLP, we need to have a basic understanding of the lingo used in the industry…
Tokenisation — Breaking up sentences into individual words.
Corpus / Corpora — A (usually very large) collection of text documents.
Stemming — Extracting the ‘stem’ of a term by removing modifiers.
Bag of Words — A list of words (usually a VERY long list) and their frequency of occurrence.
Stop Words — Joining words that don’t have meaning on their own.
Word Boundaries — Identifying the start and stop of sentences in audio and visual recordings.
NLP Terminologies To have a conversation about NLP, we need to have a basic understanding of the lingo used in the industry…
tf-idf — Short for ‘term frequency-inverse document frequency’. A statistic used to measure the RELEVANCE of a word.
Term Frequency — How often a word appears in a document or a corpus.
Inverse Document Frequency — A measure of the importance of a word.
Disambiguation — Resolving the meaning of a word that has multiple meanings.
Topic Model — A statistical representation of abstract topics.
Terms & Definitions Before we move on, let’s do a quick review. Match the following terms with their definitons…
word boundaries
stop words
topic model disambiguation
tf-idf
term frequency
corpus
bag of words
stemmingtokenisation
break up sentence into words
collection of text documents
remove word modifiers
list of words and their frequencies
joining words – don’t make sense
on their own
features identifying sentence stop and start
a statistic that measures word RELEVANCE
a word’s frequency of appearance
inverse document frequency
a statistic that measures word IMPORTANCE
resolve multiple meanings in a word
statistical representation of abstract topics
Step 1: Twitter API Twitter API is a software tool provided by Twitter for developers to automate the collection of twitter feed data … Standard API is free.
Step 1: Twitter API Data requested from Twitter’s public sources are stored in a data frame. Twitter has premium APIs that give businesses access to real time tweets.
Is this structured or unstructured data?
Activity 3 Q1. Stemming removes language modifiers.
E.g. Handling Handle , Verified Verify , Steadily Steady
Why is this necessary?
Q2. Word boundaries.
The chart above refers to an audio recording. The height (amplitude) of the signal is proportional to the sound level (measured in Decibels).
How can we use this signal sequence to identify word boundaries?
Step 2: Data Tokenisation Machines cannot process raw text – some pre-processing is required.
Tokenisation is the process of splitting sentence strings into individual words called ‘tokens’.
{{ Tokenisation },{ is },{ the },{ process },{ of },{ splitting },{ sentence }, { strings },{ into },{ individual },{ words },{ called },{ ‘ },{ tokens },{ ’ },{ . }}
A token is a sequence of characters in text that serves as a unit.
A token is a sequence of characters in text that serves as a unit.
Step 3: Normalisation Words have different forms—for instance, “ran”, “runs”, and “running” are various forms of the same verb, “run”.
Depending on the requirement of your analysis, all of these versions may need to be converted to the same form, “run”. Normalization or Lemma in NLP is the process of converting a word to its canonical form.
v v
Lemmatised Tweet Example [('#FollowFriday', 'JJ'), ('@France_Inte', 'NNP'), ('@PKuchly57', 'NNP'), ('@Milipol_Paris', 'NNP'), ('for', 'IN'), ('being', 'VBG'), ('top', 'JJ'), ('engaged', 'VBN'), ('members', 'NNS'), ('in', 'IN'), ('my', 'PRP$'), ('community', 'NN'), ('this', 'DT'), ('week', 'NN'), (':)', 'NN')]
JJ = Adjective
NNP = Proper Noun, Singular
IN = Preposition or subordinating conjunction VBG = Verb, gerund or present participle
VBN = Verb, past participle
NNS = Noun, plural
PRP$ = Possessive Pronoun NN = Noun, singular or mass
DT = Determiner
Lemmatisation – why do we care? The percent of these language components in text can indicate the type of communication taking place.
Corpus data (evidence from large collections of different document types) can be used to provide statistical insights.
Corpus evidence used in the ‘Longman Grammar of Spoken and Written English’ provides approximate frequencies of thousands of words per million. This data can be found in the file WK7_EnglishCompositionText.xlsx.
Conversational Constructs Formal Constructs
Lemmatisation – why do we care? Data file WK5_EnglishCompositionText.xlsx contains the term frequencies of English language constructs split across 3 dimensions…
We would expect conversational English to have different term frequencies than formal / academic English.
WORDS
LEXICAL FUNCTIONAL
CONVERSATION ACADEMIC
Lemmatisation – why do we care? Insert a new Pivot Table and select range ‘A1:D25’. Place the Pivot Table in a new worksheet.
Lemmatisation – why do we care? Place Level 1 in the Filter category. Place Level 2 in the Columns category. Place Level 3 in the Rows category. Place Frequency in the Values category (set calculation to ‘Sum’).
Lemmatisation – why do we care? Filter for Level 1 should select ‘All’ by default. Highlight range ‘A4:C16’ and insert a 2D column chart.
Functional & Lexical Combined By setting the Level 1 filter to ‘All’, data across functional and lexical words are combined.
Across functional and lexical terms, how would we determine whether a text is academic or conversational?
Functional Only By setting the Level 1 filter to ‘Function Words’, we are able to focus on practical English datasets.
Examining the functional terms subset only, how would we determine whether a text is academic or conversational?
Lexical Only By setting the Level 1 filter to ‘Lexical Words’, we are able to focus on definitional English datasets.
Examining the lexical terms subset only, how would we determine whether a text is academic or conversational?
Step 4: Noise Reduction Noise is any part of the text that does not add meaning or information to data.
Noise is specific to each project, so what constitutes noise in one project may not be in a different project. For instance, the most common words in a language are called stop words.
Some examples of stop words are “is”, “the”, and “a”. They are generally irrelevant when processing language, unless a specific use case warrants their inclusion.
Step 4: Noise Reduction We will need to remove the following artefacts from our tweets:
• Hyperlinks - All hyperlinks in Twitter are converted to the URL shortener t.co. Therefore, keeping them in the text processing would not add any value to the analysis.
• Twitter handles in replies - These Twitter usernames are preceded by a @ symbol, which does not convey any meaning.
• Punctuation and special characters - While these often provide context to textual data, this context is often difficult to process. For simplicity, you will remove all punctuation and special characters from tweets.
I added a video to a @YouTube playlist http://t.co/HVVPhSYakA. I’m back on twitch and today it’s going to be league :) - 1 / 3
Step 5: Word Density The most basic form of analysis on textual data is to calculate the word frequency. Sentiment is established by calculating the positive : negative ratio.
A single tweet is too small of an entity to find out the distribution of words, hence, the analysis of the frequency of words would be done on all tweets within a category [positive, negative and neutral].
Activity 4 Q1. What is the difference between tokenisation and lemmatisation?
Q2. What type of content is removed in noise reduction?
Q3. How can we use word density to gauge sentiment?
Q4.
1. Find a tweet.
2. Apply noise reduction to remove no-context artefacts.
3. What does the lemmatised string look like?
Next Week
Case Study 1!
We continue with Sentiment Analysis in week 7.
- Slide Number 1
- Slide Number 2
- Slide Number 3
- A finger on the pulse…
- Case Study 1
- Project Categories
- Ready or Not…
- The Client
- Crisis & Opportunity Monitoring
- Crisis & Opportunity Monitoring
- Monitoring Sentiment
- Activity 1
- Prototype Roadmap
- A Structureless World
- Guiding Principles
- Natural Language Processing (NLP)
- Applications
- Applications
- Activity 2
- NLP Terminologies
- NLP Terminologies
- Terms & Definitions
- Step 1: Twitter API
- Step 1: Twitter API
- Activity 3
- Step 2: Data Tokenisation
- Step 3: Normalisation
- Lemmatised Tweet Example
- Lemmatisation – why do we care?
- Lemmatisation – why do we care?
- Lemmatisation – why do we care?
- Lemmatisation – why do we care?
- Lemmatisation – why do we care?
- Functional & Lexical Combined
- Functional Only
- Lexical Only
- Step 4: Noise Reduction
- Step 4: Noise Reduction
- Step 5: Word Density
- Activity 4
- Next Week