Challenges and Opportunities for Sentiment Analysis over Social Media for Dynamic Events such as an Election

2:57:00 PM
by Knoesis Center

Monireh Ebrahimi and Amir Hossein Yazdavar

Previous efforts to assess people’s sentiment on Twitter have suggested that Twitter may be a valuable resource for studying political sentiment and that it reflects the offline political landscape. According to a Pew Research Center report, in January 2016 44% of US adults stated having learned about the presidential election through social media. Furthermore, 24% reported use of social media posts of the two candidates as a source of news and information, which is more than the 15% who have used both candidates’ websites or emails combined (Pew Research Center). The first presidential debate between Trump and Hillary was the most tweeted debate ever with 17.1 million tweets (First Presidential Debate Breaks Twitter Record).

Many opinion mining systems and tools have been developed to provide users with the attitudes of people towards products/people/topics and their attributes/aspects. One of the most often used techniques to gauge the public’s attitude, including its preferences and support, is that of sentiment analysis.  However, sentiment analysis for predicting the result of an election is still a challenging task. Though apparently simple, it is empirically highly challenging to train a successful model for conducting sentiment analysis on tweet streams for an election. Among the key challenges are changes in the topics of conversation and the people on which social media posts express their opinions.  In this blog, we will provide a brief overview of our sentiment analysis classifier and highlight some of the challenges that we have encountered during our monitoring of the presidential election at Kno.e.sis using our Twitris system. We should note here that Twitris-enabled election predictions by Kno.e.sis and the Cognovi Labs team were some of the very few that succeeded while a vast majority of predictions failed (Election Day #SocialMedia Analysis #Election2016 08Nov2016, Cognovi Labs: Twitter Analytics Startup Predicts Trump Upset in Real-Time).

We first created a supervised multi-class classifier (positive vs. negative vs. neutral) for analyzing people’s opinions about different election candidates. To this end, we trained our model for each candidate separately. The motivation for this segregation comes from our observation that the same tweet on an issue can be positive for one candidate while negative for another one. In fact, the sentiment of a tweet is very candidate-dependent. In the first round of training in July 2016 before the convention, we used 10,000 labeled tweets collected for 5 candidates, including Bernie Sanders, Donald Trump, Hillary Clinton, John Kasich, and Ted Cruz on 10 issues encompassing budget, finance, education, energy, environment, healthcare, immigration, gun control, and civil liberties . In addition to excluding re-tweets, tweets were tested for similarity using a ratio of levenshtein distance to ensure that no two tweets were too similar. Afterward, through many experiments over different machine learning algorithms and parameter settings, we found our best model with respect to F-measure. Our best model for Clinton uses SVM with TF-IDF vectorization of 1-3 grams, positive and negative hashtags for each candidate, number of positive and negative words (sentiment score), and achieved 0.66 precision, 0.63 recall, and 0.63 f-measure. Through manual error analysis, however, we noticed the importance of considering more comprehensive features like the number of positive and negative words to avoid some outrageous errors. Therefore, we conducted some experiments with the number of positive words, the number of negative words, and LIWC as features. Surprisingly, these features improved our F-measure by only around 1 %. Apart from that, we also used a distributed vector representation of training instances obtained from a pre-trained word2vec model on Twitter and Google News instead of using a discrete/traditional representation. However, the performance decreased. Finally, we achieved the best performance using CNN: three models—Random initialization, static (word2vec), non-static (fine-tuning word2vec).


1. Fast-paced change in dataset

The foremost challenging part is creating a robust classification system to cope with the dynamic nature of tweets related to an election. The election is very active (or dynamic) as everyday people talk about some new aspects of the election and candidates in the context of new events. Therefore, important features used to classify sentiment may soon become irrelevant and new emerging features would be neglected if we did not update the training set regularly. Furthermore, in a political domain, unlike many other domains, people mostly express their sentiment toward the candidates implicitly and without using sentiment words extensively. This phenomenon makes the situation worse and more challenging. Another factor that may exacerbate the problem is differentiating the transient important features from lasting or recurring ones. Those features may disappear and then reappear in the future [1]. In the context of the election, for example, this scenario may happen because of the temporal changes in what each candidate’s supporters talk about. Given this non-stationary characteristic of the election, we may encounter a concept drift/dataset shift problem. That is, learning when the test and training data have a different distribution. In fact, most of the machine learning approaches assume an identical distribution for the training and test set, although the test/target environment changes over time in many real-world problems. This phenomenon is an important factor for selecting our classification model. Among the classification models, SVM is one of the most robust models for dataset shift.
Untitled drawing (2) (1).jpg
Untitled drawing (1) (1).jpg
All of these aforementioned challenges make active learning necessary. In fact, we can seldom apply machine learning to a real-world problem successfully without using active learning. There are two possible models for active learning which are useful to our problem as shown in the figures  below. Both of the above models are expensive because of involving the human in the loop for doing the really labor-intensive and time-consuming task of annotation. Annotation is even more challenging here due to both the short length of tweets and the inherent vagueness in the political tweets. A question may arise concerning why we have not used any unsupervised approach like a lexicon-based approach when the annotation part is so challenging and our annotated dataset becomes obsolete and outdated very fast. The answer is that in political tweets people often do not use many sentiment words; hence, the performance of a lexicon-based method would be low. Empirically, we employed the MPQA subjectivity lexicon [2] to capture the subjectivity of each tweet. However the accuracy of this model did not go beyond 0.49.

Despite the costs, updating the training set regularly was the most effective measure for keeping the classifier reasonably good during the 2016 election. In fact, no matter how well our system may have been working, what worked well up until yesterday could become useless today after a new political event, set of propaganda, or scandal. For example, our first model trained during the primaries performed quite poorly during and after the conventions. Therefore, feeding the dataset with a new training set was the key task for  keeping the system reliable. To do so, we were updating the training data in a timely manner, e.g., every few days. It may also be worth trying to include more important/influential tweets in the training data. To achieve this goal we were collecting the data mostly at specific times, such as during the presidential debates.

2. Candidate-dependence

Most of sentiment analysis tools work in a target-independent manner. However, a target-independent sentiment analyzer is prone to yield poor results on our dataset because post-conventions a huge number of our tweets contain the names of both candidates. “I am getting so nervous because I want Trump to win so bad. Hillary scares me to death and with her America will be over” and “I don't really want Hillary to win but I want Trump to lose can we just do the election over” are examples of such tweets. Based on our observation, about 48% of our instances contained variants of both Clinton’s and Trump’s names. In such cases, the sentiment of those tweets may get misclassified for a given candidate because of the interference of the features related to another candidate. The state-of-the-art approaches for supervised target-dependent sentiment analysis can be grouped into two groups of syntax-based and context-based methods. The first group merely relies on POS tagging or syntax parsing for feature extraction (e.g., [3]), while the second group defines the left and right context for each target [4]. [4] demonstrates that the latter outperforms the former in the classification of informal texts such as tweets. To further enhance performance, sentiment lexicon expansion-related works such as [5] can be used to extract the sentiment-bearing candidate-specific expressions and those expressions can be added to the feature vector of a classifier. In our case, since we have trained one classifier per candidate, we can include the instances containing the name of more than one candidate in the training set of both classifiers. The key is to include features related to the target candidate in its corresponding classifier and exclude the irrelevant one both in the training and testing phase. To do that, we can use either dependency or proximity (similar to the two aforementioned works) to include the on-target features and ignore the off-target ones. Similarly, in the testing phase, depending on the classifier, we should include and exclude some of the features from our feature vector.

3. The importance of identifying the user’s political preference

The ultimate goal of sentiment analysis over political tweet streams is predicting election results. Hence, obtaining some information about the political preference of the users can provide more fine-grained sources of information to a political pundit or analyzer for  insight. Inspired by [6], we have developed a simple but effective algorithm to categorize users into 5 groups of far left-leaning,  left-leaning, far right-leaning, right-leaning, and independent users. The idea behind our approach is the tendency of users to follow others who have a similar political orientation as themselves. The more right/left-leaning a user follows, the more probability of that particular user being right/left-leaning. Therefore, we have collected a set of Twitter users with known political orientation, including all senators, congresspersons, and political pundits. Then, we estimate the probability that a user is left-leaning(right-leaning) by calculating the ratio of left-leaning (right-leaning) followees of a user to his/her total number of followers. Finally, we decide the political preference of a user by comparing the above ratio with a threshold T. Gaining this information about users helps to improve the social media-based prediction of the election.

4. Content-related challenges (hash tags)

Recently, there has been a surge of interest in distant supervision, which is training a classifier on a weekly labeled training set [7,8]. In this method, the training data gets automatically labeled based on some heuristics. In the context of sentiment analysis, using the emoticons :) and :(  and other similar emoticons as a positive and a negative label respectively is one way of using distant supervision. Hashtags are also widely used for different machine learning tasks such as emotion identification [9]. Similarly, people use a plethora of hashtags in their tweets about the election. Besides, as we mentioned before, due to the dynamic nature of election domain, the quality, quantity, and freshness of labeled data plays a vital role in creating a robust classifier. It is therefore desirable to use popular hashtags that each candidate’s supporters use as a weak label in our dataset. However, our analysis for the 2016 election showed that people widely use hashtags sarcastically in the political domain and using popular hashtags for automatic labeling leads to a huge number of incorrectly labeled instances. For example, through the election only 43% of tweets containing #Imwithher were positive for Clinton and it was used sarcastically in 27% of tweets. Furthermore, our experiments show that using those hashtags as a feature for our classifier will also not boost our performance.

5. Content-related challenges (links)

All existing techniques for tweet classifiers rely merely on tweet contents and ignore the content of the documents they point to through a URL. However, based on our observation in the  2016 election, around 36% of of tweets contain a URL to an external link. Similarly in the  2012 election, [6] demonstrates that 60% of tweets from very highly engaged users contain URLs. Those links are crucial as without them often the tweet is incomplete and inferring the sentiment is impossible or difficult even for a human annotator. Therefore, our hypothesis is that incorporating the content, keywords or title of the documents that a URL points to as a feature will cause a significant gain in our performance intuitively. To the best of our knowledge, there is no work on tweet classification that expands tweets based on their URLs. However, link expansion has successfully been applied to other problems such as topical anomaly detection [10] and distant supervision [11].  

6. Content-related challenges (sarcasm)

Based on our observation 7% of Trump’s tweets and 6% of Clinton’s tweets are sarcastic. Among these sarcastic tweets, 39% and 32% of them have been classified incorrectly by our system. To date, many sophisticated tools and approaches have been proposed to deal with sarcasm. Looking closer at these works, they mostly focus only on detecting the sarcasm in the text and not on how to cope with it in the sentiment analysis task. This, therefore, raises the interesting question about how sarcasm may or may not affect the sentiment of the tweets and how to deal with sarcastic tweets in both the training and prediction phases. Ellon Rillof et al [12] has proposed an algorithm to recognize the common form of sarcasm which flips the polarity in the sentence. These kinds of polarity-reverser sarcastic tweets often express the positive (negative) sentiment in the context of a negative (positive) activity or situation. However, Maynard et al [13] show that determining the scope of sarcasm in tweets is still challenging. In fact, the polarity of sarcasm may apply to part of a tweet or its hashtags but not necessarily the whole. As a result, dealing with sarcasm in the task of sentiment analysis is an open research issue worth more work. In terms of the training set, our hypothesis is that excluding the sarcastic instances from the training set will remove the noise and improve the quality of our training set.

7. Interpretation-related challenges (Sentiment Analysis versus Emotion Analysis)

Study of sentiment has evolved to the study of emotions, which has finer granularity. Positive, negative, and neutral sentiments can be expressed with different emotions such as joy and love for positive polarity; anxiety and sadness for negative; and apathy for neutral sentiment. Our emotion analysis on who tweeted #IVOTED in the 2016 US presidential election  reveals Trump followers were joyful about Trump on election day. Though the sentiment analysis favored Hillary in the early hours, emotion analysis was showing support for Trump (joy). In fact, emotion is a better criterion for predicting people’s action like voting and usually there are huge emotional differences in the tweets which belong to the same polarity. Hence, emotion analysis should  inevitably be a component of an election prediction tool.

8. Interpretation-related challenges (Vote counting vs engagement counting)

Most/all of the aforementioned challenges affect the quality of our sentiment analysis approach. It is also very important to correlate a user’s online behavior and opinion with their actual vote. Lu et al [6] show the more important role of highly engaged users in the result prediction of the 2012 election  . There are two plausible explanations for this. First, the more a user tweets, the more reliably we can predict his/her opinion. Second, highly active people are usually more influential and more likely to actually vote in the real world. That is why an election monitoring system should report both user-level normalized sentiment in addition to a tweet-level one. It is the end user analyzer’s task to consider both of these factors in prediction.

9. The importance of location

An application that predicts the election result must consider each state’s influence in the election by means of the number of electoral votes for that state. Many tools and approaches have been developed for both fine-grained [14] and coarse-grained (Twitris) location identification in tweets for different purposes such as disaster management (Hazards SEES: Social and Physical Sensing Enabled Decision Support for Disaster Management and Response) and election monitoring. In the latter case, the geographic location of a tweet or the user location in the profile can be used to estimate the user’s approximate location. During the 2016 election , the spatial aspect of our Twitris system played a crucial role in assisting the end users in predicting the election.

10. Trustworthiness-related challenges (Bots)

What happens when a large number of participants in a conversation are biased robots which artificially inflate social-media traffic by manipulating public opinion and spreading political misinformation? A social bot is a computer algorithm that automatically generates content over social media and is trying to emulate and possibly change public attitude. For the past few years, social bots have inhabited social media platforms. Our analysis demonstrates that a large portion of tweets which were pro-Trump and pro-Clinton during the first and second debates originated from automated accounts (How Twitter Bots Are Shaping the Election, How the Bot-y Politic Influenced This Election). Indeed, we have witnessed bot wars during the election.  Recently, pinpointing the sources of bots has attracted many researchers. Supervised statistical models is done utilizing a different feature set from network features: retweets, mentions, and hashtag co-occurrence [15] to user features (i.e. language, geographic locations, account creation time, number of followers, followees), posts [16], and timing features (i.e. content generation and consumption, by measuring tweet rate and inter-tweet time distribution [17]). Content features are based on natural language cues measured via linguistic analysis, e.g. part-of-speech tagging [18]. At Kno.e.sis, by examining the resource that generates a tweet (checking whether it is originating from an API or not), our system has found bots in support of both Trump and Clinton with a high precision but low recall. A more sophisticated approach is needed to improve the recall.


Pinage, Felipe Azevedo, Eulanda Miranda dos Santos, and João Manuel Portela da Gama. "Classification systems in dynamic environments: an overview." Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery 6.5 (2016): 156-166.

Wilson, Theresa, Janyce Wiebe, and Paul Hoffmann. "Recognizing contextual polarity in phrase-level sentiment analysis." Proceedings of the conference on human language technology and empirical methods in natural language processing. Association for Computational Linguistics, 2005.

Jiang, Long, et al. "Target-dependent twitter sentiment classification." Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies-Volume 1. Association for Computational Linguistics, 2011.

Vo, Duy-Tin, and Yue Zhang. "Target-Dependent Twitter Sentiment Classification with Rich Automatic Features." IJCAI. 2015.

Chen, Lu, et al. "Extracting Diverse Sentiment Expressions with Target-Dependent Polarity from Twitter." Sixth International AAAI Conference on Weblogs and Social Media. 2012.

Chen, Lu, Wenbo Wang, and Amit P. Sheth. "Are Twitter users equal in predicting elections? A study of user groups in predicting 2012 US Republican Presidential Primaries." International Conference on Social Informatics. Springer Berlin Heidelberg, 2012.

Purver, Matthew, and Stuart Battersby. "Experimenting with distant supervision for emotion classification." Proceedings of the 13th Conference of the European Chapter of the Association for Computational Linguistics. Association for Computational Linguistics, 2012.

Go, Alec, Richa Bhayani, and Lei Huang. "Twitter sentiment classification using distant supervision." CS224N Project Report, Stanford 1.12 (2009).

Wang, Wenbo, et al. "Harnessing twitter" big data" for automatic emotion identification." Privacy, Security, Risk and Trust (PASSAT), 2012 International Conference on and 2012 International Conference on Social Computing (SocialCom). IEEE, 2012.

Anantharam, Pramod, Krishnaprasad Thirunarayan, and Amit Sheth. "Topical anomaly detection from twitter stream." Proceedings of the 4th Annual ACM Web Science Conference. ACM, 2012.

Magdy, Walid, et al. "Distant Supervision for Tweet Classification Using YouTube Labels." ICWSM. 2015.

Riloff, Ellen, et al. "Sarcasm as Contrast between a Positive Sentiment and Negative Situation." EMNLP. Vol. 13. 2013.

Maynard, Diana, and Mark A. Greenwood. "Who cares about Sarcastic Tweets? Investigating the Impact of Sarcasm on Sentiment Analysis." LREC. 2014.

Ji, Zongcheng, et al. "Joint Recognition and Linking of Fine-Grained Locations from Tweets." Proceedings of the 25th International Conference on World Wide Web. International World Wide Web Conferences Steering Committee, 2016.

Lee, Kyumin, Brian David Eoff, and James Caverlee. "Seven Months with the Devils: A Long-Term Study of Content Polluters on Twitter." ICWSM. 2011.

Kramer, Adam DI, Jamie E. Guillory, and Jeffrey T. Hancock. "Experimental evidence of massive-scale emotional contagion through social networks." Proceedings of the National Academy of Sciences 111.24 (2014): 8788-8790.

Yang, Zhi, et al. "Uncovering social network sybils in the wild." ACM Transactions on Knowledge Discovery from Data (TKDD) 8.1 (2014): 2.

Davis, Clayton Allen, et al. "BotOrNot: A system to evaluate social bots." Proceedings of the 25th International Conference Companion on World Wide Web. International World Wide Web Conferences Steering Committee, 2016.

You Might Also Like