Social Media & Public Opinion - Final
Contents
- 1 Abstract
- 2 Change in project scope
- 3 Related Work
- 4 Methodology: Text analytics using RapidMiner
- 5 Improving Accuracy
- 6 Deriving insights from emoticons
- 7 Deriving word associations from tweets
- 8 Pitfalls of using conventional text analysis on social media data
- 9 Improving the effectiveness of sentiment analysis of social media data
- 10 References
Abstract
Sentiment analysis on social media provides organisations an opportunity to monitor their reputation and brands by extracting and analysing online comments posted by Internet users about them or the market in general. There are various existing methods to carry out sentiment analysis on social media data, with varying results. In this paper, we show how to use Twitter as a corpus for sentiment analysis and investigate the effectiveness of sentiment text analysis on tweets. We adopt a supervised approach, by labelling the training data and using it to train a model for predicting the responses on the unlabelled testing data.
Change in project scope
Although anyone and everyone can easily attain such data, there are certain challenges faced that can hamper the effectiveness of such analysis.
- Can conventional text analysis methods be done on social media data?
- How effective are these methods?
- What are some of the unique features of social media that we need to take note of when doing text analysis on them?
Related Work
A real-time text-based hedonometer was built to measure happiness of over 63 million Twitter users over 33 months, as recorded in the paper Temporal Patterns of Happiness and Information in a Global Social Network: Hedonometrics and Twitter (Dodds et al., 2011)[1]. It shows how a highly robust and tunable metric can be constructed with the word list chosen solely by frequency of usage.
In the paper Twitter as a Corpus for Sentiment Analysis and Opinion Mining (Pak & Paroubek, 2010)[2], the authors show how to use Twitter as a corpus for sentiment analysis and opinion mining, perform linguistic analysis of the collected corpus and build a sentiment classifier that is able to determine positive, negative and neutral sentiments for a document. The authors build a sentiment classifier using the multinomial Naïve Bayes classifier that uses N-gram and part-of-speech tags as features as it yielded the best results as compared to Support Vector Machines (SVMs) and Conditional Random Fields (CRFs) classifiers. We will be using the Naive Bayes classifier too.
For the paper Twitter Sentiment Analysis: The Good the Bad and the OMG! (Kouloumpis et al., 2011)[3], the authors investigate the usefulness of linguistic features for detecting the sentiment of tweets. The results show that show that part-of-speech features may not be useful for sentiment analysis in the microblogging domain.
The authors mentioned in the paper Exploiting Emoticons in Sentiment Analysis (Hogenboom et al., 2013)[4] created an emoticon sentiment lexicon in order to improve a state-of-the-art lexicon-based sentiment classification method. It demonstrated that people typically use emoticons in natural language text in order to express, stress, or disambiguate their sentiment in particular text segments, thus rendering them potentially better local proxies for people’s intended overall sentiment than textual cues. We will be analysing emoticons too to improve the accuracy of our model.
In the paper Tokenization and Filtering Process in RapidMiner (Verma et al., 2014)[5], the authors shows how text mining is implemented in Rapidminer through tokenisation, stopword elimination, stemming and filtering. We will be using RapidMiner too in our methodology.
Methodology: Text analytics using RapidMiner
Download RapidMiner here
Screenshots | Steps |
Setting up RapidMiner for text analysisTo carry out text processing in RapidMiner, we need to download the plugin required from the RapidMiner's plugin repository. Click on Help > Managed Extensions and search for the text processing module. Once the plugin is installed, it should appear in the "Operators" window as seen below. | |
Data PreparationIn RapidMiner, there are a few ways in which we can read a file or data from a database. In our case, we will be reading from tweets provided by the LARC team. The format of the tweets given was in the JSON format. In RapidMiner, JSON strings can be read but it is unable to read nested arrays within the string. Thus, due to this restriction, we need to extract the text from the JSON string before we can use RapidMiner to do the text analysis. We did it by converting each JSON string into a javascript object and extracting only the Id and text of each tweet and write them onto a comma separated file (.csv) to be process later in RapidMiner.
|
Defining a Standard
Creating a Model
Screenshots | Steps |
We first used the "read CSV" operator to read the text from the prepared CSV file that was done earlier. This can be done via an "Import Configuration Wizard" or set manually.
| |
Each column is separated by a ",". | |
To check the results at any point of the process, right click on any operators and add a breakpoint. To process the document, we convert the data from nominal to text. | |
We convert the text data into documents. In our case, each tweet is converted in a document. | |
The "process document" operator is a multi-step process to break down each document into single words. The number of frequency of each word as well as their occurrences (in documents) are calculated and used when formulating the model.
To begin the process, double-click on the operator. | |
1. Tokenizing the tweet by word Tokenization is the process of breaking a stream of text up into words or other meaningful elements called tokens to explore words in a sentence. Punctuation marks as well as other characters like brackets, hyphens, etc. are removed.
2. Converting words to lowercase All words are transformed to lowercase as the same word would be counted differently if it was in uppercase vs. lowercase. 3. Eliminating stopwords The most common words such as prepositions, articles and pronouns are eliminated as it helps to improve system performance and reduces text data. 4. Filtering tokens that are smaller than 3 letters in length Filters tokens based on their length (i.e. the number of characters they contain). We set a minimum number of characters to be 3. 5. Stemming using Porter2’s stemmer Stemming is a technique for the reduction of words into their stems, base or root. When words are stemmed, we are keeping the core of the characters which convey effectively the same meaning.
Porter Stemmer vs Snowball (Porter2)[7] Porter: Most commonly used stemmer without a doubt, also one of the gentlest stemmers. It is one of the most computationally intensive of the algorithms(Granted not by a very significant margin). It is also the oldest stemming algorithm by a large margin. Snowball (Porter2): Nearly universally regarded as an improvement over porter, and for good reason. Porter himself in fact admits that Snowball is better than his original algorithm. Has a slightly faster computation time than snowball, with a fairly large community around it.We use the Porter2 stemmer. | |
We used TF-IDF (term frequency*inverse document frequency) to set the importance of each word to a particular label. The TF-IDF takes into account 2 things: if a term appears on a lot of documents, each time it appears in a document, it is probably not so important.
Conversely, if a term is seldom used in most of the documents, when it appears, the term is likely to be important.
| |
Return to the main process.
We need to add the "Set Role" process to indicate the label for each tweet. We have a column called "Classification" to assign the label for that. | |
The "X-validation" operator creates a model based on our manual classification which can later be used on another set of data.
To begin, double click on the operator.
| |
We carry out an X-validation using the Naive Bayes model classification, a simple probabilistic classifier based on applying Bayes' theorem (from Bayesian statistics) with strong (naive) independence assumptions. In simple terms, a Naive Bayes classifier assumes that the presence (or absence) of a particular feature of a class (i.e. attribute) is unrelated to the presence (or absence) of any other feature.
| |
To apply this model to a new set of data, we repeat the above steps of reading a CSV file, converting it the input to text, set the role and processing each document before applying the model to the new set of tweets.
| |
From the performance output, we achieved 44.6% accuracy when the model was cross validated with the original 1000 tweets that were manually tagged. To affirm this accuracy, we randomly extracted 100 tweets from the fresh set of 5000 tweets and manually tag these tweets and cross validated with the predicted values by the model. The predicted model did in fact have an accuracy of 46%, a close percentage to the 44.2% accuracy using the X-validation module.
|
Improving Accuracy
Pruning
We experimented with multiple values to determine the most appropriate amount of words to be pruned off, bearing in mind that we need a sizeable number of words with a high enough accuracy yield.
- Percentage pruned refers to the words that are removed from the word list that do not occur within the said amount of documents. e.g. for 1% pruned out of the set of 1000 documents, words that appeared in less than 10 documents are removed from the word list.
Percentage Pruned | Percentage Accuracy | Deviation | Size of resulting word list |
---|---|---|---|
0% | 39.8% | 5.24% | 3833 |
0.5% | 44.2% | 4.87% | 153 |
1% | 42.2% | 2.68% | 47 |
2% | 45.1% | 1.66% | 15 |
5% | 43.3% | 2.98% | 1 |
Results
(Click on the image to enlarge)
Using Different Classifiers
Support vector machine
K-Nearest Neighbour
Naives Bayes
Deriving insights from emoticons
Experiment
- Print the entire list of tweets that we have
- Identify the ones that has a converted emoticon tag (e.g. "😔")
- Get the list of emoticons from an emoticon library[8] and tag each emoticon with positive (P), Negative (N) and Neutral(X)
- For each tweet that we have, we manually tag the tweets based on the sentiments of the tweets.
- Cross validate that with the sentiments of the emoticons present in the tweet
- Calculate the percentage of matches between the 2 tagged values.
Deriving word associations from tweets
Screenshots | Steps |
| |
| |
|
Pitfalls of using conventional text analysis on social media data
Multiple languages
Misspelled words and abbreviations
Length of status
Other media types
Improving the effectiveness of sentiment analysis of social media data
Increasing size of training data
Leveraging on Emoticons
Allowing the user to tag their feelings to their status
Analyse data on an event/topic basis rather than on time
References
- ↑ Dodds PS, Harris KD, Kloumann IM, Bliss CA, Danforth CM (2011) Temporal Patterns of Happiness and Information in a Global Social Network: Hedonometrics and Twitter. PLoS ONE 6(12): e26752. doi:10.1371/journal.pone.0026752
- ↑ Pak, A., & Paroubek, P. (2010). Twitter as a Corpus for Sentiment Analysis and Opinion Mining.
- ↑ Kouloumpis, E., Wilson, T., & Moore, J. (2011). . In International AAAI Conference on Weblogs and Social Media. Retrieved from https://www.aaai.org/ocs/index.php/ICWSM/ICWSM11/paper/view/2857/3251
- ↑ Hogenboom, A. and Bal, D. and Frasincar, F. and Bal, M. and de Jong, F.M.G. and Kaymak, U. (2013) Exploiting emoticons in sentiment analysis. In: Proceedings of the 28th Annual ACM Symposium on Applied Computing, SAC 2013, 18-22 Mar 2013, Lisbon, Portugal. pp. 703-710. ACM. ISBN 978-1-4503-1656-9
- ↑ Verma, T., & Renu, D. G. (2014). Tokenization and Filtering Process in RapidMiner. International Journal of Applied Information Systems (IJAIS)–ISSN, 2249-0868.
- ↑ Wiebe, J., Wilson, T., & Cardie, C. (2005). Annotating Expressions of Opinions and Emotions in Language. Language Resources and Evaluation, 165-210. Retrieved from http://people.cs.pitt.edu/~wiebe/pubs/papers/lre05.pdf
- ↑ Tyranus, S. (2012, June 26). What are the major differences and benefits of Porter and Lancaster Stemming algorithms? Retrieved from http://stackoverflow.com/questions/10554052/what-are-the-major-differences-and-benefits-of-porter-and-lancaster-stemming-alg
- ↑ Emoticon - emotions library https://github.com/wooorm/emoji-emotion/blob/master/data/emoji-emotion.json