scieee AI-readable full text Open interactive document viewer

politicanalytics: social media analytics for political data science

Luís Filipe Castanheira Gomes

Full text

FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO PoliticAnalytics: social media analytics for political data science Luís Filipe Castanheira Gomes Mestrado Integrado em Engenharia Informática e Computação Supervisor: Carlos Soares Co-Supervisor: Pedro Saleiro February 7, 2014 PoliticAnalytics: social media analytics for political data science Luís Filipe Castanheira Gomes Mestrado Integrado em Engenharia Informática e Computação February 7, 2014 Abstract In this project we studied the problem of predicting the results of political polls based on the combination of several aggregators of buzz and sentiment obtained from Twitter posts. We followed a machine learning approach, where the combination model was estimated from data. We used tweets from the portuguese tweetosphere since June 2011. This dataset contains tweets from 100 000 users who were classified as Portuguese. Futhermore, we had access to the polls results, since June 2011, of a private portuguese company that studies portuguese public opinion (Eurosondagens). We performed some experiments using two regression algorithms (Random Forests and Ordinary Least Squares). We compared the real poll values with the predicted values of our regression models. The lower absolute error we could obtain was 0.50 using only buzz aggregators. It means that our prediction model has a small predictive error. These results highlight the potential of using twitter data to complement or substitute traditional surveys. i ii Resumo Neste projecto estudámos o problema de prever o resultado de sondagens políticas com base na combinação de vários agregadores de buzz e sentimento obtidos de mensagens do Twitter. Seguimos uma abordagem de machine learning para estimar o modelo de combinação através dos dados recolhidos. Utilizámos tweets da tweetosfera portuguesa desde Junho de 2011. Este dataset contém tweets de 100 000 utilizadores diferentes classificados como Portugueses. Para além disso, tivemos acesso ao resultados das sondagens, desde Junho de 2011, levadas a cabo por uma empresa privada que estuda a opinião publica portuguesa (Eurosondagens). Foram feitas experiências usando dois algoritmos regressão (Random Forests eOrdinary Least Squares). Comparámos o resultado real das sondagens com os valores previstos pelos nossos modelos regressivos e anotámos os resultados. O menor erro absoluto obtido foi 0.50 usando apenas agregadores de buzz. Isto significa que o nosso modelo predictivo tem um pequeno erro predictivo. Estes resultados realçam o potencial existente em usar dados do Twitter para complementar ou substituir as sondagens tradicionais. iii iv Acknowledgements I would like to show my gratitude to Carlos Soares and Pedro Saleiro, for the patience at guiding me, for all the time they spent and for all the knowledge they share with me. To SAPO Labs, for providing me a workstation and a grant, so I could have all the conditions to develop this project. To all my friends who were by my side over these years with whom I shared joys and sorrows. To Vanda, my girlfriend, for her love, support and patience, and for cheering me up in every single moment. To my family, for their patience and support, even in the nights and days that I was not at home and for providing all the conditions so I could conclude this course. This work is partially funded by National Funds through the FCT – Fundação para a Ciência e a Tecnologia (Portuguese Foundation for Science and Technology) within projects "REACTION (UTAustin/EST-MAI/0006/2009)" and "POPSTAR (PTDC/CPJ-CPO/116888/2010)" as well as Project "NORTE-07-0124-FEDER-000059", which is funded by the North Portugal Regional Operational Programme (ON.2 – O Novo Norte), under the National Strategic Reference Framework (NSRF), through the European Regional Development Fund (ERDF), and the Portuguese funding agency, Fundação para a Ciência e a Tecnologia (FCT). Luís Filipe Castanheira Gomes v LIST OF FIGURES B.60 Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) . . . . . . . . . . . . . . . . . . . . . . . 87 B.61 Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the D(yt1)feature................... 88 B.62 Predicted and real values of vote intention, from January 2013 to June 2013, for AntónioJoséSeguro(PS).............................. 89 B.63 Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the D(yt1)feature. ............... 89 B.64 Predicted and real values of vote intention, from January 2013 to June 2013, for PedroPassosCoelho(PSD)............................. 90 B.65 Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP), excluding the D(yt1)feature. ................ 90 B.66 Predicted and real values of vote intention, from January 2013 to June 2013, for JerónimodeSousa(PCP).............................. 91 B.67 Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the D(yt1)feature...................... 91 B.68 Predicted and real values of vote int[!ht]ention, from January 2013 to June 2013, forPauloPortas(PP) ................................ 92 B.69 Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the D(yt1)feature. ........... 92 B.70 Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) . . . . . . . . . . . . . . . . . . . . . . . 93 B.71 Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the D(yt1)feature................... 93 B.72 Predicted and real values of vote intention, from January 2013 to June 2013, for AntónioJoséSeguro(PS).............................. 94 B.73 Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the D(yt1)feature. ............... 94 B.74 Predicted and real values of vote intention, from January 2013 to June 2013, for PedroPassosCoelho(PSD)............................. 95 B.75 Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP), excluding the D(yt1)feature. ................ 95 B.76 Predicted and real values of vote intention, from January 2013 to June 2013, for JerónimodeSousa(PCP).............................. 96 B.77 Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the D(yt1)feature...................... 96 B.78 Predicted and real values of vote int[!ht]ention, from January 2013 to June 2013, forPauloPortas(PP) ................................ 97 B.79 Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the D(yt1)feature. ........... 97 B.80 Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) . . . . . . . . . . . . . . . . . . . . . . . 98 B.81 Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS), including the previous poll variation of all political targets 99 B.82 Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD), including the previous poll variation of all political targets........................................ 100 xii LIST OF FIGURES B.83 Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP), including the previous poll variation of all political targets100 B.84 Predicted and real values of vote intention, from January 2013 to June 2013, for Paulo Portas (PP), including the previous poll variation of all political targets . . 101 B.85 Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE), including the previous poll variation of all politicaltargets ................................... 101 B.87 Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD), including the previous poll variation of all political targets........................................ 102 B.86 Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS), including the previous poll variation of all political targets102 B.88 Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP), including the previous poll variation of all political targets103 B.89 Predicted and real values of vote intention, from January 2013 to June 2013, for Paulo Portas (PP), including the previous poll variation of all political targets . . 103 B.90 Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE), including the previous poll variation of all politicaltargets ................................... 104 B.91 Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS), including the previous poll variation of all political targets105 B.92 Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD), including the previous poll variation of all political targets........................................ 106 B.93 Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP), including the previous poll variation of all political targets106 B.94 Predicted and real values of vote intention, from January 2013 to June 2013, for Paulo Portas (PP), including the previous poll variation of all political targets . . 107 B.95 Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE), including the previous poll variation of all politicaltargets ................................... 107 xiii LIST OF FIGURES xiv List of Tables 2.1 List of implemented aggregators . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.1 Distribution of positive, negative and neutral mentions per political party, provided byPOPSTAR .................................... 22 4.2 Mean Absolute Errors of predictive models and baseline . . . . . . . . . . . . . 24 4.4 MAE and MSE comparision when the variation from the previous month is greater orsmallerthan1 .................................. 26 4.3 Mean Absolute Errors of predictive models and baseline . . . . . . . . . . . . . 26 4.5 Globalconfusionmatrix .............................. 27 4.6 ConfusionmatrixPS ................................ 27 4.7 ConfusionmatrixPSD ............................... 27 4.8 ConfusionmatrixCDS ............................... 27 4.9 ConfusionmatrixCDU............................... 27 4.10ConfusionmatrixBE ................................ 27 4.11 Mean Absolute Errors of predictive models and baseline . . . . . . . . . . . . . 28 4.12 MAE and MSE when the variation from the previous month is greater or smaller than1 ........................................ 28 4.13 Mean Absolute Errors of predictive models and baseline . . . . . . . . . . . . . 29 4.14 MAE and MSE comparision when the variation from the previous month is greater orsmallerthan1 .................................. 29 4.15 Mean Absolute Errors of predictive models and baseline . . . . . . . . . . . . . 30 4.16 MAE and MSE comparision when the variation from the previous month is greater orsmallerthan1 .................................. 30 4.17 Mean Absolute Errors of predictive models and baseline . . . . . . . . . . . . . 31 4.18 MAE and MSE comparision when the variation from the previous month is greater orsmallerthan1 .................................. 31 4.19MAEcomparision.................................. 31 4.21 Average of the poll variation module in the first and second semester . . . . . . . 32 4.20 MAE and MSE when the monthly variation is greater or smaller than 1 . . . . . . 32 4.22Globalconfusionmatrix .............................. 32 4.23ConfusionmatrixPS ................................ 32 4.24ConfusionmatrixPSD ............................... 32 4.25ConfusionmatrixCDS ............................... 32 4.26ConfusionmatrixCDU............................... 33 4.27ConfusionmatrixBE ................................ 33 A.1 Aggregators correlation for António José Seguro (PS) . . . . . . . . . . . . . . . 40 A.2 Aggregators correlation for António José Seguro (PS) . . . . . . . . . . . . . . . 41 xv LIST OF TABLES A.3 Aggregators correlation for António José Seguro (PS) . . . . . . . . . . . . . . . 42 A.4 Aggregators correlation for Pedro Passos Coelho (PSD) . . . . . . . . . . . . . . 43 A.5 Aggregators correlation for Pedro Passos Coelho (PSD) . . . . . . . . . . . . . . 44 A.6 Aggregators correlation for Pedro Passos Coelho (PSD) . . . . . . . . . . . . . . 45 A.7 Aggregators correlation for Paulo Portas (CDS) . . . . . . . . . . . . . . . . . . 46 A.8 Aggregators correlation for Paulo Portas (CDS) . . . . . . . . . . . . . . . . . . 47 A.9 Aggregators correlation for Paulo Portas (CDS) . . . . . . . . . . . . . . . . . . 48 A.10 Aggregators correlation for Jerónimo de Sousa (PCP) . . . . . . . . . . . . . . . 49 A.11 Aggregators correlation for Jerónimo de Sousa (PCP) . . . . . . . . . . . . . . . 50 A.12 Aggregators correlation for Jerónimo de Sousa (PCP) . . . . . . . . . . . . . . . 51 A.13 Aggregators correlation for João Semedo and Catarina Martins (BE) . . . . . . . 52 A.14 Aggregators correlation for João Semedo and Catarina Martins (BE) . . . . . . . 53 A.15 Aggregators correlation for João Semedo and Catarina Martins (BE) . . . . . . . 54 xvi Abbreviations MAE Mean Absolute Error NLP Natural Language Processing MSE Mean Squared Error OLS Ordinary Least Squares RF Random Forests xvii Chapter 1 Introduction Before the internet existance, traditional surveys and polls were the only methods to provide information about what people thought about parties or political personalities [JSS]. These methods use the telephone to collect the opinions about political targets. Surveys randomly select the electorate sample, avoiding selection bias, and are designed to collect the perception of a population regarding some subject, such as public opinion or brand experience. However, this method is expensive and time consuming [CBRS,JSS]. Furthermore, over the years it is becoming more difficult to contact people and persuade them to participate in telephone survey, as is evidenced in figure 1.1 [KKD+12]. Figure 1.1: Evolution of contact, cooperation and response rates of traditional surveys However, social networks, blogs and online forums have turned the internet into an information and opinions repository generating a big amount of data that can be used in scientific research [TBP11]. Thus, researchers started their work in order to understand how social media data can be used in political scenario. People express their opinions or political leanings on social media for free. Thus, why cannot we collect those opinions and try to understand if people are happy with 1 Introduction their government? Moreover, can opinions collected from the social media be used as predictors in the election processes? With the raise of social media, namely Facebook1and Twitter2, people share online their thoughts and opinions about political targets [BS]. Twitter has roughly 288 million users accessing the site at least once a month [Hol13a] creating 5 787 new tweets every second [Hol13b]. Part of this information is publicly available for free. Additionally, changed the relationship between news and people. Blogs, Facebook and Twitter allow people to consume news and express their opinions about related entities almost in real time. Thus, social media itself has becoming an important source of information both to journalists and politicians. Furthermore, there is a growing number of studies suggesting that social media messages can be relevant indicators of public opinion and, in some cases, lead to the prediction of election results. Studying the relationship between social media messages and traditional polls is an active area of research. Due to the amount of data available online, the most conventional way to extract some meaningful information is using machine learning and other data analysis techniques. Approaches in this area usually create predictive models using aggregated social media data as input signal and polls results as target variable. However, there is no consensus on how to aggregate social media data, i.e., how we can predict polls results using raw messages mentioning specific political entities. The most common approaches aggregate the frequency of mentions [TSSW10] or the obtained sentiment of those messages, using a sentiment analysis classifier [MMGA11]. 1.1 Objectives The main objective of this dissertation is to study and define a methodology that allows us to aggregate social media data in order to predict polls results. We collected buzz data from social media and apply sentiment methods used in literature. However, there is no consensus on how to aggregate the social media data or which aggregation methods should we use. We combined several aggregation methods and used machine learning techniques in order to predict poll results. We propose to evaluate the suitability of the model using data from Portuguese Politics. This thesis was carried out as part of an FCT funded project, POPSTAR, which aims to study the relationship between online mentions of Portuguese political targets and the results of traditional polls. 1.2 Document Structure The document is organized as follows: 1www.facebook.com 2www.twitter.com 2 Introduction Chapter 2contains the background and the state of the art as well as some related work. We explain in more detail what data mining is as well as regression and classification methods. Furthermore we present a list of opinion aggregation methods. Chapter 3contains the methodology we used in the portuguese case study. We describe step by step the data transformation so the methodology can be used in different domains. Chapter 4we present the results of our study and some discussion. In chapter 5we have some conclusions as well as ideas for future work. 3 Background and State of the Art w1=Â|D| i=1(xixp)(yiyp) Â|D| i=1(xixp)2(2.6) where xpand ypare the predicted values. However, in some cases we do not have just one predictor variable. It might be necessary to consider more than one predictor variable. In these cases, we have to perform a Multiple Linear Regression, which takes the form: y=w0+w1x1+w2x2(2.7) In this case, we can still use the method of least squares to solve this problem. A regression model has also been used to achieve the election outcome on each party, based on the relevant tweets of the five main Irish parties, on the Irish General Election, 2011. In that study, some sentiment measures were been defined (we will discuss them in detail later) to use as input for the regression model [BS]. Linear least-squares model was used to correlate data collected from twitter related to Obama with two set of polls during the 2008 U.S. presidential election. In this particular case, it was concluded that when consumers confidence changes, it can be noticed first in the text sentiment measure than in polls, which means that text seems to be a leading indicator [CBRS]. However, as told before, regression models can be applied in other professional areas. Actually, there are a some studies on the cinematographic industry that use regression models to predict a movie revenue before its release [AH10,JDGS10,ZS09]. For that purpose, it was built a linear model using the average of the tweet-rate related to a film, in the weekend prior the release, for 24 movies and they conclude that the tweet-rate is a strong indicator of the revenue of a film. Another work that used regression models is [JDGS10], once they used it to directly predict opening weekend gross earnings, based on some features extracted from the movie metadata (such as whether the film is from, running time, genre, actors or whether the movie opened on a holidays weekend or in summer months.) This information extracted from text was made using three different approaches. (1) n-grams: considering n-grams, bigrams and trigrams. N-grams is a contiguous sequence of nitems from a given sequence of text. Bigrams and trigrams were only considered if all the words were included in the 25-word stoplist; (2) part of speech n-grams, using the [TM00] tagger; (3) Dependency relations [KM02]. 2.2.3 Evaluation An important issue in Machine Learning is evaluation. There are several evaluation measures that can be used to measure how good and reality adjusted a model is. We have distinct evaluation measures for classification and regression problems. One of the measures we can use to evaluate a classifier is accuracy [HK]. Accuracy represents the percentage of test set that are correctly classified by the classifier. An example of usage of accuracy to measure the performance of their sentiment classification model is given by [JSS]. 10 Background and State of the Art Other evaluative measures that we can use to evaluate the performance of a classification model are recall and precision. While recall measures the percentage of relevant documents that are correctly classified as relevant by the model, precision measures the percentage of documents classified as relevant that actually are relevant [RL94]. On the other hand, we have others fitted to to determine the performance of a regression model.MAE (Mean Absolute Error), for instance, is used to know how close the forecast is to the real outcome [BS,HK], and is defined by the following formula: MAE =Ân i=1|fiyi| n(2.8) where nis the number of forecasts, fiis the model forecast and yithe real forecast. As the name suggests, the Mean Absolute Error is the average of the absolue errors of each prediction: ei=|fiyi|(2.9) where fiis the prediction and yiis the real outcome. R2, also called as coefficient of determination, reflects how strong the variables used as input in the regression model are as predictors [AH10,CBRS]. R2varies between 0 and 1. The bigger R2, the more predictive the measures are [AH10]. 2.3 Sentiment Analysis Sentiment analysis, as well as opinion mining, has enjoyed a huge burst of research activity [PL08]. The rise of machine learning methods in Natural Language Processing (NLP) and information retrieval as well as the availability of data sets for machine learning algorithms to be trained on, contributed to this burst. Sentiment analysis "deals with the computational treatment of opinion, sentiment, and subjectivity in text" [PL08]. In summary, sentiment analysis aims to extract the overall sentiment or opinion from a given text or message. However, with the complexity of the languages syntaxes, this is not a simple task. In the political scenario, sentiment analysis is a useful tool once there is the constant need of extracting the overall sentiment inherent to a message. One possible sentiment analysis approach is using lexicons. The lexicon approaches only consider a certain word if it is contained in a pre existing list lexicons. This lexicon list, also contains the information about the positiveness or the negativeness of each word. [CBRS,BS] used the lexicon based approach. [CBRS] classified each tweet as positive or negative according to the existence or not of positive and negative words, respectively. This means that a given message can be both positive and negative if it contains both positive and negative words. The same approach was used in [MMGA11] with a little modification. In this particular case, each positive and negative word within a twitter message counts as +1 and -1 respectively. Thus, 11 Background and State of the Art the message is positive, neutral or negative depending on the sum of all the labelled words it contains. Another approach to the sentiment classification problem, is using supervised learning algorithms. A classifier can be trained using a data set. [JSS] used a Maximum Entropy classifier to classify the political sentiment of the tweets containing the word "Obama". 2.3.1 Opinion Aggregators An important decision to make is what to do with labelled data, once labeling messages as positives, negatives or neutrals might be, by itself, meaningless. One challenge on the political science is to create a method to aggregate data the most meaningful way in order to raise the accuracy of our model. Many authors have tried to develop mathematical formulae to quantify the popularity of a given political target or party, based on twitter data, called aggregator. The aggregator, is a numerical value based on twitter messages annotated as positive, negative or neutral by a sentiment analysis method. We can have two different approaches when aggregating data to include in our predictive model: sentiment [JSS,BS,MMGA11,CBRS] and buzz [MMGA11,TSSW10,BS]. Buzz is merely the frequency that a political target is mentioned in social networks. The following equation represents a simple aggregation method using sentiment analysis [CBRS]. xt=countt(pos.word ^topicword) countt(neg.word ^topicword)(2.10) xtis the sentiment score on day tas the ratio of positive versus negative messages on the topic. [MMGA11] used an interesting approach based on sentiment analysis. In a two candidate race, c1 and c2, all negative mentions refered to c1 will count as positive for c2. Assuming that, the vote share for c1 can be calculated as the ratio of the sum of the number of positive messages of c1 and negative messages of c2, over the total of positive and negative messages. vote_share(c1)= pos(c1)+neg(c2) pos(c1)+neg(c1)+pos(c2)+neg(c2)(2.11) However, in a (at least) 3 parties race, we cannot assume that a negative tweet related to c1 will automatically represent a positive one for c2. Generally, if the majority of the mentions to a party are negative, we can automatically assume that people are in general negatively disposed towards that party. But what if the negative majority holds true for all parties? To solve that problem, [BS] purpose two models: inter- and intra-party. To better classify each party according to the others, [BS] calculate the share of positive and negative volume, berminghamsovp and berminghamsovn. There are also some aggregators that use buzz. [TSSW10] states that "the mere number of party mentions accurately reflects the election result". [MMGA11] also experimented the use of 12 Background and State of the Art buzz as predictor to compare the results against using sentiment. Buzz indicators are all the ones that do not need sentiment analysis, such as the mentions total (buzz) and buzz share, of each candidate. Besides using the sentiment analysis to aggregate collected data, [BS] also tries buzz as a predictor (share). Table 2.1 presents the complete list of all aggregators collected from the state of the art, and their formulas. There are buzz and sentiment aggregators. Some sentiment aggregators have been normalized. It means that normalized aggregators instead of using the number of positive, negative and neutral tweets, used the ratio of positive, negative and neutral tweets over the candidate buzz. 13 Background and State of the Art Table 2.1: List of implemented aggregators Name Description Formula bermingham2 [BS] - log10 related_pos+1 related_neg+1 normalized_bermingham2 Normalization of the previous formula log10 related_pos candidate_buzz +1 related_neg candidate_buzz +1 berminghamsovn [BS] Share of negative buzz related_neg total_neg berminghamsovp [BS] Share of positive buzz related_pos total_pos connor [CBRS] Ratio between positive and negative tweets related_pos related_neg normalized_connor Normalization of the previous formula related_pos candidate_buzz related_neg candidate_buzz gayo [MMGA11] - related_pos+total_neg total_pos+total_neg normalized_gayo Normalization of the previous formula related_pos candidate_buzz +normalized_total_neg normalized_total_pos+normalized_total_neg ind - related_neg+related_pos candidate_buzz polarity - related_pos related_neg normalized_polarity Normalization of the previous formula related_pos candidate_buzz related_neg candidate_buzz polarityONeutral Polarity over neutrality related_posrelated_neg related_neutral polarityOTotal Polarity over total related_posrelated_neg candidate_buzz subjNeu Subjectivity over neutrality related_pos+related_neg related_neutral subjSoV Share of subjectivity related_pos+related_neg total_pos+total_neg subjVol Subjectivity related_pos +related_neg share [BS] Buzz Share candidate_buzz total shareOfNegDistribution Share of negative distribution related_neg candidate_buzz Ân i=0 posi buzzi+negi buzzi normalized_negative Normalization of negative buzz related_neg candidate_buzz normalized_neutral Normalization of neutral buzz related_neu candidate_buzz normalized_positive Normalization of positive buzz related_pos candidate_buzz positive_mentions Positive buzz related_pos negative_mentions Negative buzz related_neg neutral_mentions Neutral buzz related_neu total_mentions Candidate Buzz candidate_buzz 14 Chapter 3 Methodology and Case Study 3.1 Problem Nowadays the most used and common way to collect public opinion surveys is through telephone surveys. Surveys randomly select the electorate sample, avoiding selection bias. The questions are designed and tested to measure whatever we want to measure. However, this method is time consuming and expensive [CBRS,JSS]. Another obstacle to telephone surveys is the low response rate. It is becoming more difficult to contact people and persuade them to participate in telephone survey (from 1997 to 2012 the response rate dropped from 36% to 9%) [KKD+12]. The big challenge of this dissertation is to understand how public opinion expressed within twitter messages can be used as a predictor of political target popularity. 3.2 Goals The main objective of this dissertation is to study and define a methodology that allows us to aggregate social media data in order to predict poll results using a regression model. Another objective is to understand which type of data aggregator (buzz, sentiment, or both) are more suitable to predict poll results. To perform the study, we apply two regression algorithms (Random Forests and Ordinary Least Squares) to predict poll results. Its results are validated based on the minimization of the prediction error. 3.3 Data Sources To study the relationship between portuguese electorate opinions on social media and poll results we use two main distinct data sets: (1) Social media data and (2) Portuguese poll results. The social media data set may contain data collected from three different sources: Twitter, blogs and news. With respect to this case study, the social media data set does not need to contain the 15 Methodology and Case Study message/news/text itself. The social media data set contains the daily count of positive, negative or neutral message/news/text referring to each political target or party. The second main data set contains the monthly polls result of the political targets or parties we want to predict. 3.4 Data Preparation As described in section 3.3, we have access to the political parties daily count of positive, negative and neutral messages/news/text. Futhermore we have access to monthly polls results. Polls results would act as target variable in our regression model. At this point the need of monthly aggregate the daily count emerged. If we used daily counts as predictive features, we would be trying to predict daily vote intention. Due to the lack of daily poll results to be used as target variable, it would not possible to determine the predictive effectiveness of our model, given that we had no real results to compare our prediction with. On the other hand, monthly aggregated data allowed us to use polls results to compare with our vote intention prediction and determine the prediction error. After aggregating monthly data, we are able to apply the opinion aggregators described in section 2.3.1. The next step is joining monthly aggregated data and real polls results in the same data set. This allows us to store political parties monthly count of positive, negative and neutral messages, values of the opinion aggregators, and polls results on the same data set. Furthermore, we include in the aggregated data set the value of the previous month polls result, for each candidate, which we called yt1feature. Each political target poll results has a small variation from month to month. Thus, we decided to use a different approach. Instead of using absolute values, we transform both polls and aggregators data sets to carry the monthly variation from the previous month. In a mathematical notation, an aggregator iin month mwould take the value agg(i)magg(i)m1. It allows the model to predict the poll monthly variation instead of predicting the absolute polls result. Having these two data sets allows us to perform two kind of experiments: (1) Using absolute values and (2) using monthly variations. 3.5 Architecture Figure 3.1 represents the architecture of our vote intention prediction model prototype. 16 Methodology and Case Study Figure 3.1: PoliticAnalytics’ Solution Architecture This methodology can support multiple data sources (twitter, blogs and news). With respect to this particular case study, we only used one of the three possible data sources: Twitter. After the correct preparation of this data set, we use the second main data set: Polls results. This second data set is defined as our target variable in the regression model. After data preparation, we can use the dataset as input in our prediction model. We apply a regression algorithm and predict the monthly vote intention for each candidate. 17 Methodology and Case Study 18 Chapter 4 Results 4.1 Overview This chapter is reserved to describe in detail the data sources we used as well as to explain the data preparation. Ultimately, we describe in detail all the experiments we performed as well as their results. We performed multiple experiments in order to predict poll results from January 2013 to June 2013 with low MAE. Thus, we used different two different regression algorithms combined with different data sets. 4.2 Experimental Setup 4.2.1 Data Although the methodology defined in chapter 3can support multiple data sources, in this project we center our efforts on Twitter. POPSTAR project, which collect and label twitter messages as positive, negative or neutral using sentiment analysis methods, provided us a data set containing the daily count of labeled twitter messages with respect to national and international public figures, since June 2011. In our case study, it was not necessary to access the messages themselves. The second main data set contains the mothly polls result. We had access to the polls results from Eurosondagens, provided by the Instituto de Ciências Sociais da Universidade de Lisboa, also as part of the POPSTAR project. Eurosondagens is a private portuguese company that studies public opinion and performs monthly polls on public political preference. This data set contains the traditional monthly polls results of the five main portuguese political parties (PS, PSD, CDS, BE and CDS), from June 2011 until June 2013. Both twitter and polls data are stored in a MongoDB database. MongoDB is an open-source document database, and the leading NoSQL databases. The programming language we used was Python, and its scientific libraries scipy, numpy and scikit-learn. 19 Results Table 4.4: MAE and MSE comparision when the variation from the previous month is greater or smaller than 1 MSE MAE <1 >=1 <1 >=1 Baseline 0.27 1.28 0.47 1.13 Random Forests 0.37 1.56 0.51 1.15 Random Forests (D(yt1)) 0.36 1.52 0.52 1.15 OLS 0.41 1.67 0.53 1.27 OLS (D(yt1)) 0.57 1.49 0.58 1.19 Table 4.3: Mean Absolute Errors of predictive models and baseline Prediction Method PS CDS PSD PCP BE Overall Baseline 0.62 0.38 0.67 0.70 0.43 0.56 Random Forests 0.84 0.41 0.57 0.70 0.46 0.60 Random Forests (D(yt1)) 0.85 0.40 0.57 0.74 0.48 0.60 OLS 0.78 0.30 0.60 0.86 0.62 0.63 OLS (D(yt1)) 0.84 0.37 0.53 0.86 0.70 0.66 This experiment has lower error values than the experiment described in section 4.5. Also, it presents some different behaviours. If we include the Dyt1feature as input in the Random Forests algorithm we will obtain lower error value than excluding it. However, the MAE difference between using Random Forests including and excluding the D(yt1)feature is smaller than it was in section 4.5. On the other hand, OLS presents greater absolute error values when including the D(yt1)feature. Another important fact is that the absolute error of Random Forests (excluding the D(yt1) feature) is smaller than the one obtained in experiment 4.5, which is an important improvement. The MAE dropped from 3.19 to 0.60. At this point, we can conclude that D(yt1)feature has not the determinant role that yt1had in the first experiment. In this experiment we also analyzed the behavior of the model when the poll variation is greater than or equal to 1 (1%) and when is smaller than 1, presented in table 4.4. We can see that the baseline has lower error values than our predictions. In this experiment, we verified that almost all results of both algorithms present lower absolute error than in experiment 4.5. Including the D(yt1)feature in the OLS algorithm, we obtained greater absolute error values than in the previous experiment. However, table 4.3 shows that baseline still has lower absolute error value that our experiments. The smaller error value we could obtain is 0.60 using the Random Forests algorithm. This is closer to the baseline MAE (0.56) than in any other experiments. The error of the predictions, as discussed above, presents one perspetive on the performance of the models. However, in this domain it also makes sense to analyse if the model is able to 26 Results predict the trends correctly. In other words, if the model predicts a positive or negative variation in the vote intentions and the observed value is consistent with that prediction or not. Thus, we build a confusion matrix for each party composed by the times that our model (Random Forests, without Dyt1feature) correctly and mistakenly predicted the signal of the poll variation (tables 4.5 to 4.10), and a global one. Our model has some difficulty to predict true positives, specially when predicting PS and PSD poll results. It means that in the majority of the months where the poll results rised, the model predicted a fall. On the other hand, in 70% of the cases where the poll results actually dropped, our model correctly predicted the drop. Table 4.5: Global confusion matrix Predicted Value Positive Negative Real Value Positive 5 7 Negative 5 13 Table 4.6: Confusion matrix PS Predicted Value Positive Negative Real Value Positive 1 3 Negative 0 2 Table 4.7: Confusion matrix PSD Predicted Value Positive Negative Real Value Positive 0 2 Negative 0 4 Table 4.8: Confusion matrix CDS Predicted Value Positive Negative Real Value Positive 0 0 Negative 3 3 Table 4.9: Confusion matrix CDU Predicted Value Positive Negative Real Value Positive 3 1 Negative 1 1 Table 4.10: Confusion matrix BE Predicted Value Positive Negative Real Value Positive 1 1 Negative 1 3 All graphical representations can be consulted on the appendix section B.2. 4.7 Experiment Sentiment vs Buzz So far, the lower error value we could obtain is 0.60 performing experiment 4.5, using the Random Forests algorithm. As described in section 3.4, in this experience we divided the aggregator list into two groups: buzz and sentiment aggregators. We repeated the process used in previous experiments for each group. The next chapters, will present the results for OLS and Random Forests, using sentiment and buzz aggregators, separately. A detailed representation of results is given in appendix section B.3. 27 Results 4.7.1 Sentiment In this experiment, Random Forests has smaller MAE than in experiment 4.5. OLS on the other hand, has lower absolute error when including D(yt1)feature, and a greater one when including it, as can be seen in table 4.15. Table 4.12 shows that Random Forests is the algorithm with the lowest MAE when the poll variation is greater or equal to 1. This results means that when the poll variation is bigger or equal to 1, Random Forests has better preditive power than the baseline itself. However, the global MAE is greater than the baseline due to the lack of predictiveness when there is a small poll variation between two consecutive months. Table 4.11: Mean Absolute Errors of predictive models and baseline Prediction Method PS CDS PSD PCP BE Overall Baseline 0.62 0.38 0.67 0.70 0.43 0.56 Random Forests 0.81 0.37 0.51 0.72 0.48 0.58 Random Forests (D(yt1)) 0.81 0.40 0.48 0.69 0.48 0.57 OLS 0.85 0.38 0.48 0.90 0.72 0.66 OLS (D(yt1)) 0.76 0.32 0.57 0.89 0.63 0.63 Table 4.12: MAE and MSE when the variation from the previous month is greater or smaller than 1 MSE MAE <1 >=1 <1 >=1 Baseline 0.27 1.28 0.47 1.13 Random Forests 0.33 1.44 0.49 1.12 Random Forests (D(yt1)) 0.33 1.44 0.49 1.10 OLS 0.57 1.54 0.58 1.21 OLS (D(yt1)) 0.42 1.73 0.53 1.30 At the moment, the smaller absolute error we could obtain is using sentiment aggregators with Random Forests algorithm. Despite that fact, and despite the fact that that Random Forests algorithm can predict poll values with lower error than OLS, it still has greater absolute error than the baseline. 4.7.2 Buzz This section is dedicated to study the relationship between polls results and buzz aggregators. In other words, we ignored all the aggregators from the aggregators list that used sentiment anal- 28 Results ysis. Thus, to perform this experiment we used the aggregators share (buzz share) and the total_mentions (number of tweets that refers to a given candidate), together with the party id. Table 4.13: Mean Absolute Errors of predictive models and baseline Prediction Method PS CDS PSD PCP BE Overall Baseline 0.62 0.38 0.67 0.70 0.43 0.56 Random Forests 0.63 0.33 0.54 0.60 0.45 0.52 Random Forests (D(yt1)) 0.71 0.38 0.68 0.60 0.42 0.56 OLS 0.57 0.35 0.70 0.71 0.42 0.55 OLS (D(yt1)) 0.68 0.32 0.68 0.75 0.38 0.56 Table 4.14: MAE and MSE comparision when the variation from the previous month is greater or smaller than 1 MSE MAE <1 >=1 <1 >=1 Baseline 0.27 1.28 0.47 1.13 Random Forests 0.29 1.33 0.42 1.14 Random Forests (D(yt1)) 0.29 1.44 0.46 1.19 OLS 0.27 1.36 0.46 1.16 OLS (D(yt1)) 0.30 1.49 0.46 1.20 In table 4.13 we can see that buzz has an important role in predicting the poll results, given that it presents lower MAE than other experiments. Using buzz aggregators, the bigger absolute error we obtained was 0.56. This means that the MAE of the worst performance of this experiment is equal to the baseline. At this point we can conclude that D(yt1)feature has not the determinant role it had in other experiments. According to table 4.13, excluding the D(yt1)feature, OLS or Random Forests obtained lower error value than the baseline itself. So far, these results are the best results of the three experiments we made. Without using the D(yt1)feature we can obtain a better prediction (with lower MAE) than the baseline. Including the D(yt1)feature, the MAE error is equal to the baseline. These results show that when using buzz aggregators, Random Forests algorithm performs better than OLS and the baseline. 4.8 Experiment Sentiment vs Buzz All At this point, we are able to conclude that using Random Forests algorithm with buzz aggregators, without including the D(yt1)feature, we can obtain better predictive power than the one provided by the baseline. However we decided to perform one last experiment. The variation of the surveys 29 Results results of a candidate is not an independent event by itself. Probably, it is correlated with the variation of the popularity of another political target or party. Based on this premise, we decided also to include the previous monthly variation of polls of all parties as predictive features in our regression model. We perform this experiment using sentiment and buzz aggregators separately. All graphical representations can be consulted on the appendix section B.4. 4.8.1 Sentiment In this section we present the results of the experiment using only sentiment aggregators. Table 4.15: Mean Absolute Errors of predictive models and baseline Prediction Method PS CDS PSD PCP BE Overall Baseline 0.62 0.38 0.67 0.70 0.43 0.56 Random Forests (D(yt1)) 0.81 0.39 0.46 0.70 0.47 0.57 OLS (D(yt1)) 0.74 0.32 0.58 0.93 0.58 0.63 Table 4.16: MAE and MSE comparision when the variation from the previous month is greater or smaller than 1 MSE MAE <1 >=1 <1 >=1 Baseline 0.27 1.28 0.47 1.13 Random Forests (D(yt1)) 0.32 1.46 0.48 1.11 OLS (D(yt1)) 0.44 1.50 0.54 1.20 This experiment showed that including the previous monthly poll results of all political target in every prediction worsens the model, given that there is an increase of the MAE. This means a decrease in the predictive power of our model. All graphical representations can be consulted on the appendix section B.4. 4.8.2 Buzz In this section we present the results of the experiment using only buzz aggregators. All graphical representations can be consulted on the appendix section B.4. 30 Results Table 4.17: Mean Absolute Errors of predictive models and baseline Prediction Method PS CDS PSD PCP BE Overall Baseline 0.62 0.38 0.67 0.70 0.43 0.56 Random Forests (D(yt1)) 0.61 0.30 0.56 0.58 0.43 0.50 OLS (D(yt1)) 0.50 0.43 0.66 0.70 0.45 0.55 Table 4.18: MAE and MSE comparision when the variation from the previous month is greater or smaller than 1 MSE MAE <1 >=1 <1 >=1 Baseline 0.27 1.28 0.47 1.13 Random Forests (D(yt1)) 0.26 1.16 0.41 1.06 OLS (D(yt1)) 0.30 1.43 0.45 1.19 According to this study, when using Random Forests algorithm we can minimize the absolute error to 0.50, which is an important improvement. Table 4.17 also shows that OLS has lower MAE than the baseline. 4.9 Experiment with different data set (predicting July to December) In the previous experiments, we used the same set of data for multiple experiments, namely varying the features, the algorithm and its parameters. Although an adequate methodology was used to ensure that models are tested on data that was not used for training, multiple experiments increase the probability that a good result is obtained by chance. Therefore, it is a good practice to develop a model using a data set, and test it with a different one. Thus, in order to evaluate our model with different data from the one used to develop it, we used the best model obtained in experiment 4.5, to predict poll results from July to December 2013. We could use the model with the lowest MAE we obtained, however given the proximity of the MAEs of all experiments that use variations, we used a model that includes all the aggregators. Table 4.19: MAE comparision Prediction Method PS CDS PSD PCP BE Overall Baseline (Jan to Jun) 0.62 0.38 0.67 0.70 0.43 0.56 Random Forests (Jan to Jun) 0.84 0.41 0.57 0.70 0.46 0.60 Baseline (Jul to Dec) 0.70 0.70 0.92 0.67 0.45 0.69 Random Forests (Jul to Dec) 0.47 0.94 0.84 0.80 0.54 0.72 31 Results Table 4.21: Average of the poll variation module in the first and second semester PS CDS PSD PCP BE First Semester 0.6 0.4 0.7 0.7 0.4 Second Semester 0.7 0.7 0.9 0.7 0.5 Table 4.20: MAE and MSE when the monthly variation is greater or smaller than 1 MSE MAE <1 >=1 <1 >=1 Baseline (Jan to Jun) 0.27 1.28 0.47 1.13 Random Forests (Jan to Jun) 0.37 1.56 0.51 1.15 Baseline (Jul to Dec) 0.23 2.05 0.40 1.37 Random Forests (Jul to Dec) 0.24 3.67 0.40 1.80 Table 4.19 presents the comparision between the MAE of poll results predictions from Jan to June 2013 and from July to December 2013. The baseline MAE is different because we aimed to predict the poll results of the second semester of the year 2013. Table 4.19 shows that the baseline MAE had a slight increase. It happened because in the second semester of the year, the poll results were not so stable as they were in the first semester, as table 4.21 suggests. Table 4.19 shows that our model has a predictive power slightly weaker than the baseline, except when predicting PS poll results. Also, we build confusion matrices the same way we did in section 4.6 (tables 4.22 to 4.27). In table 4.26 and 4.27 are only represented 5 and 4 predictions, respectively. It happens because there are one and two months where the CDU and BE poll results, respectively, did not variate. However, the 3 times the poll results variation is 0, the model predicted a rise. According to table 4.22, only in 50% of the cases that the poll results actually dropped were correctly predicted by our model. Table 4.22: Global confusion matrix Predicted Value Positive Negative Real Value Positive 8 5 Negative 7 7 Table 4.23: Confusion matrix PS Predicted Value Positive Negative Real Value Positive 4 0 Negative 1 1 Table 4.24: Confusion matrix PSD Predicted Value Positive Negative Real Value Positive 3 1 Negative 1 1 Table 4.25: Confusion matrix CDS Predicted Value Positive Negative Real Value Positive 1 1 Negative 1 2 32 Results Table 4.26: Confusion matrix CDU Predicted Value Positive Negative Real Value Positive 0 1 Negative 3 1 Table 4.27: Confusion matrix BE Predicted Value Positive Negative Real Value Positive 0 1 Negative 1 2 33 Results 34 Chapter 5 Conclusions Traditional telephone surveys are the most common method used to collect public opinion. However, this method is expensive and time consuming. On the other hand, people freely express their opinions on the web. With this project we proposed to define a methodology capable of predicting the poll results using social media data. First, we performed an exhaustive study of the sentiment aggregation methods present in the literature. The second step was to apply these aggregators in our data set (containing the daily count of positive, negative and neutral messages relative to each candidate). Furthermore we performed multiple experiments, namely varying the features and the algorithm and studied its results. This dissertation project allows us to take some conclusions with respect to the relationship between the Portuguese tweetoshphere and the polls results of the Portuguese private company Eurosondagem. The first conclusion is that we could estimate the polls results using the sentiment inherent to twitter messages of our case study with a small prediction error (0.50, in a scale from 0 to 100). Furthermore, due to the small poll variation from month to month, we used a naive baseline, where we predict for month ithe same real poll result of month i1. We showed that this baseline has a strong predictive power, given the small MAE obtained (0.56). It happens due to the small variation of the poll results of the Portuguese scenario. Using absolute aggregators values in the regression models has a worst predictive performance, given that the experiment obtained the highest prediction error of all experiments. Furthermore, the yt1feature has a determinant role in the regression models predictive effectiveness of that experiment. This can be easily explainable once we are including the baseline in the regression model. Another important conclusion we can take is that experiments using only buzz aggregators have lower prediction errors, which highlights the strong predictive power of buzz aggregators. The smaller MAE we obtained (0.50, from 0 to 100) was using the Random Forests algorithm, together with buzz aggregators, share and total_mentions, and the previous poll variation of all candidates. 35 Correlation Tables Table A.3: Aggregators correlation for António José Seguro (PS) normalized positive pollEuro pollEuro-1 positive mentions negative mentions neutral mentions total mentions bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity polarityONeutral polarityOTotal subjNeu subjSoV subjVol share shareOfNegDistribution normalized negative normalized neutral normalized positive 1.00 pollEuro 0.08 1.00 pollEuro-1 -0.09 0.08 1.00 positive mentions 0.50 -0.15 0.21 1.00 negative mentions -0.12 -0.27 0.34 0.29 1.00 neutral mentions -0.07 -0.16 0.26 0.33 0.59 1.00 total mentions -0.12 -0.25 0.34 0.34 0.89 0.70 1.00 42 Correlation Tables Table A.4: Aggregators correlation for Pedro Passos Coelho (PSD) bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity bermingham2 1.00 normalized bermingham2 0.21 1.00 bermingham (sovn) -0.18 -0.21 1.00 bermingham (sovp) 0.58 -0.05 0.07 1.00 connor 0.64 -0.03 0.04 0.73 1.00 normalized connor 0.64 -0.03 0.04 0.73 1.00 1.00 gayo 0.17 0.21 -0.99 -0.07 -0.05 -0.05 1.00 normalized gayo -0.11 0.23 -0.50 -0.20 -0.30 -0.30 0.51 1.00 ind -0.20 -0.96 0.21 0.08 0.07 0.07 -0.21 -0.23 1.00 polarity 0.19 0.35 -0.18 0.02 0.05 0.05 0.18 0.03 -0.35 1.00 normalized polarity 0.22 0.99 -0.20 -0.04 -0.03 -0.03 0.19 0.22 -0.96 0.37 polarityONeutral 0.20 0.84 -0.14 -0.05 -0.04 -0.04 0.13 0.12 -0.85 0.39 polarityOTotal 0.22 0.99 -0.20 -0.04 -0.03 -0.03 0.19 0.22 -0.96 0.37 subjNeu -0.19 -0.83 0.13 0.05 0.05 0.05 -0.13 -0.11 0.85 -0.38 subjSoV -0.17 -0.22 0.99 0.07 0.05 0.05 -0.99 -0.51 0.22 -0.19 subjVol -0.19 -0.35 0.18 -0.02 -0.04 -0.04 -0.17 -0.02 0.35 -0.99 share -0.26 -0.09 0.64 -0.03 -0.05 -0.05 -0.64 -0.19 0.10 -0.21 shareOfNegDistribution 0.04 -0.22 0.44 0.16 0.22 0.22 -0.45 -0.85 0.22 0.03 normalized negative -0.21 -0.97 0.22 0.07 0.06 0.06 -0.21 -0.24 0.99 -0.36 normalized neutral 0.20 0.96 -0.21 -0.08 -0.07 -0.07 0.21 0.23 -1.00 0.35 normalized positive 0.64 -0.03 0.03 0.75 0.99 0.99 -0.03 -0.28 0.07 0.05 pollEuro -0.04 -0.11 0.02 0.08 -0.04 -0.04 -0.02 0.00 0.11 0.00 pollEuro-1 -0.06 0.07 -0.13 -0.12 -0.22 -0.22 0.13 0.29 -0.08 0.03 positive mentions 0.58 -0.06 0.00 0.65 0.75 0.75 -0.01 -0.13 0.10 -0.09 negative mentions -0.19 -0.35 0.18 -0.02 -0.05 -0.05 -0.18 -0.03 0.35 -1.00 neutral mentions -0.18 -0.14 0.14 -0.01 -0.08 -0.08 -0.13 0.02 0.14 -0.78 total mentions -0.18 -0.27 0.14 -0.03 -0.07 -0.07 -0.14 0.02 0.27 -0.91 43 Correlation Tables Table A.5: Aggregators correlation for Pedro Passos Coelho (PSD) normalized polarity polarity Over Neutral polarity Over Total subjNeu subjSoV subjVol share share Of Neg Distribution normalized negative normalized neutral bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity 1.00 polarityONeutral 0.85 1.00 polarityOTotal 1.00 0.85 1.00 subjNeu -0.85 -0.99 -0.85 1.00 subjSoV -0.21 -0.14 -0.21 0.14 1.00 subjVol -0.36 -0.40 -0.36 0.39 0.18 1.00 share -0.10 -0.11 -0.10 0.11 0.64 0.20 1.00 shareOfNegDistribution -0.21 -0.10 -0.21 0.09 0.45 -0.04 0.12 1.00 normalized negative -0.97 -0.85 -0.97 0.84 0.22 0.35 0.11 0.22 1.00 normalized neutral 0.96 0.85 0.96 -0.85 -0.22 -0.35 -0.10 -0.22 -0.99 1.00 normalized positive -0.03 -0.04 -0.03 0.05 0.03 -0.04 -0.05 0.21 0.06 -0.07 pollEuro -0.11 -0.11 -0.11 0.10 0.02 -0.01 -0.07 0.05 0.12 -0.11 pollEuro-1 0.06 0.06 0.06 -0.05 -0.13 -0.03 -0.01 -0.28 -0.09 0.08 positive mentions -0.07 -0.11 -0.07 0.11 0.01 0.10 -0.03 0.06 0.09 -0.10 negative mentions -0.37 -0.39 -0.37 0.38 0.19 0.99 0.21 -0.03 0.36 -0.35 neutral mentions -0.15 -0.17 -0.15 0.17 0.14 0.77 0.23 -0.09 0.14 -0.14 total mentions -0.28 -0.30 -0.28 0.30 0.15 0.91 0.19 -0.08 0.27 -0.27 44 Correlation Tables Table A.6: Aggregators correlation for Pedro Passos Coelho (PSD) normalized positive pollEuro pollEuro-1 positive mentions negative mentions neutral mentions total mentions bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity polarityONeutral polarityOTotal subjNeu subjSoV subjVol share shareOfNegDistribution normalized negative normalized neutral normalized positive 1.00 pollEuro -0.04 1.00 pollEuro-1 -0.20 0.04 1.00 positive mentions 0.77 -0.09 -0.13 1.00 negative mentions -0.05 0.00 -0.03 0.09 1.00 neutral mentions -0.07 -0.01 -0.03 0.08 0.78 1.00 total mentions -0.05 0.00 -0.01 0.10 0.91 0.86 1.00 45 Correlation Tables Table A.7: Aggregators correlation for Paulo Portas (CDS) bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity bermingham2 1.00 normalized bermingham2 0.32 1.00 bermingham (sovn) 0.06 -0.13 1.00 bermingham (sovp) 0.49 -0.07 0.13 1.00 connor 0.55 -0.02 0.07 0.85 1.00 normalized connor 0.55 -0.02 0.07 0.85 1.00 1.00 gayo -0.08 0.11 -0.98 -0.13 -0.07 -0.07 1.00 normalized gayo 0.00 0.03 -0.22 0.09 0.03 0.03 0.22 1.00 ind -0.26 -0.92 0.13 0.13 0.09 0.09 -0.10 0.00 1.00 polarity 0.22 0.36 -0.18 -0.08 -0.03 -0.03 0.17 -0.07 -0.37 1.00 normalized polarity 0.30 0.95 -0.14 -0.10 -0.05 -0.05 0.12 0.03 -0.96 0.36 polarityONeutral 0.18 0.77 -0.16 -0.20 -0.14 -0.14 0.13 -0.08 -0.85 0.40 polarityOTotal 0.30 0.95 -0.14 -0.10 -0.05 -0.05 0.12 0.03 -0.96 0.36 subjNeu -0.16 -0.76 0.15 0.20 0.16 0.16 -0.13 0.08 0.84 -0.39 subjSoV 0.08 -0.14 0.98 0.16 0.10 0.10 -0.95 -0.21 0.15 -0.19 subjVol -0.22 -0.36 0.18 0.08 0.03 0.03 -0.17 0.07 0.36 -1.00 share 0.06 -0.03 0.67 0.16 0.10 0.10 -0.69 0.05 0.02 -0.14 shareOfNegDistribution -0.05 -0.10 0.31 -0.07 -0.01 -0.01 -0.31 -0.81 0.06 0.00 normalized negative -0.29 -0.94 0.14 0.10 0.06 0.06 -0.12 -0.03 0.97 -0.36 normalized neutral 0.26 0.92 -0.13 -0.13 -0.09 -0.09 0.10 0.00 -1.00 0.37 normalized positive 0.58 -0.02 0.08 0.83 0.97 0.97 -0.08 0.04 0.10 -0.04 pollEuro 0.03 0.02 -0.07 0.13 0.14 0.14 0.07 0.29 -0.01 -0.14 pollEuro-1 0.00 -0.14 0.02 -0.12 -0.09 -0.09 -0.01 -0.39 0.15 0.13 positive mentions 0.59 -0.07 0.17 0.79 0.86 0.86 -0.17 0.03 0.14 -0.12 negative mentions -0.22 -0.36 0.18 0.08 0.03 0.03 -0.17 0.07 0.37 -1.00 neutral mentions -0.27 -0.22 0.10 0.08 0.02 0.02 -0.10 0.11 0.20 -0.75 total mentions -0.21 -0.34 0.15 0.11 0.05 0.05 -0.14 0.08 0.34 -0.94 46 Correlation Tables Table A.8: Aggregators correlation for Paulo Portas (CDS) normalized polarity polarity Over Neutral polarity Over Total subjNeu subjSoV subjVol share share Of Neg Distribution normalized negative normalized neutral bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity 1.00 polarityONeutral 0.82 1.00 polarityOTotal 1.00 0.82 1.00 subjNeu -0.81 -0.98 -0.81 1.00 subjSoV -0.17 -0.18 -0.17 0.18 1.00 subjVol -0.36 -0.39 -0.36 0.39 0.20 1.00 share -0.03 -0.03 -0.03 0.02 0.69 0.14 1.00 shareOfNegDistribution -0.10 0.00 -0.10 0.00 0.31 0.00 0.02 1.00 normalized negative -0.99 -0.83 -0.99 0.82 0.17 0.36 0.03 0.10 1.00 normalized neutral 0.96 0.85 0.96 -0.84 -0.15 -0.36 -0.02 -0.06 -0.97 1.00 normalized positive -0.05 -0.15 -0.05 0.17 0.11 0.04 0.11 -0.02 0.07 -0.10 pollEuro 0.00 -0.03 0.00 0.02 -0.05 0.14 0.15 -0.31 0.00 0.01 pollEuro-1 -0.14 -0.12 -0.14 0.12 0.00 -0.14 -0.18 0.32 0.15 -0.15 positive mentions -0.10 -0.19 -0.10 0.21 0.19 0.12 0.19 -0.02 0.11 -0.14 negative mentions -0.36 -0.40 -0.36 0.39 0.19 1.00 0.14 0.00 0.36 -0.37 neutral mentions -0.21 -0.21 -0.21 0.20 0.11 0.75 0.16 -0.05 0.19 -0.20 total mentions -0.34 -0.37 -0.34 0.36 0.16 0.95 0.12 -0.01 0.33 -0.34 47 Correlation Tables Table A.9: Aggregators correlation for Paulo Portas (CDS) normalized positive pollEuro pollEuro-1 positive mentions negative mentions neutral mentions total mentions bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity polarityONeutral polarityOTotal subjNeu subjSoV subjVol share shareOfNegDistribution normalized negative normalized neutral normalized positive 1.00 pollEuro 0.12 1.00 pollEuro-1 -0.07 -0.35 1.00 positive mentions 0.89 0.11 -0.07 1.00 negative mentions 0.04 0.14 -0.13 0.12 1.00 neutral mentions 0.02 0.13 -0.25 0.09 0.75 1.00 total mentions 0.06 0.16 -0.18 0.14 0.94 0.80 1.00 48 Correlation Tables Table A.10: Aggregators correlation for Jerónimo de Sousa (PCP) bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity bermingham2 1.00 normalized bermingham2 0.70 1.00 bermingham (sovn) -0.30 -0.32 1.00 bermingham (sovp) 0.32 0.22 0.26 1.00 connor 0.57 0.54 -0.02 0.59 1.00 normalized connor 0.57 0.54 -0.02 0.59 1.00 1.00 gayo 0.24 0.29 -0.88 -0.23 0.02 0.02 1.00 normalized gayo 0.53 0.69 -0.49 0.04 0.31 0.31 0.47 1.00 ind -0.48 -0.74 0.41 0.00 -0.31 -0.31 -0.40 -0.78 1.00 polarity 0.55 0.49 -0.46 0.10 0.35 0.35 0.46 0.54 -0.46 1.00 normalized polarity 0.67 0.97 -0.29 0.22 0.54 0.54 0.26 0.69 -0.75 0.49 polarityONeutral 0.56 0.86 -0.29 0.19 0.52 0.52 0.32 0.71 -0.79 0.55 polarityOTotal 0.67 0.97 -0.29 0.22 0.54 0.54 0.26 0.69 -0.75 0.49 subjNeu -0.45 -0.74 0.34 -0.07 -0.39 -0.39 -0.38 -0.74 0.90 -0.53 subjSoV -0.28 -0.30 0.96 0.30 0.02 0.02 -0.88 -0.48 0.41 -0.44 subjVol -0.50 -0.44 0.48 -0.06 -0.30 -0.30 -0.49 -0.53 0.45 -0.95 share -0.10 -0.11 0.75 0.36 0.10 0.10 -0.74 -0.26 0.20 -0.31 shareOfNegDistribution -0.54 -0.74 0.47 -0.05 -0.36 -0.36 -0.43 -0.87 0.79 -0.49 normalized negative -0.57 -0.85 0.37 -0.10 -0.43 -0.43 -0.36 -0.78 0.88 -0.51 normalized neutral 0.48 0.74 -0.41 0.00 0.31 0.31 0.40 0.78 -1.00 0.46 normalized positive 0.56 0.44 0.09 0.62 0.87 0.87 -0.10 0.20 -0.20 0.28 pollEuro 0.01 -0.03 -0.02 -0.19 -0.04 -0.04 -0.01 -0.03 -0.07 -0.01 pollEuro-1 0.07 0.18 -0.07 0.03 0.07 0.07 0.09 0.01 -0.01 0.02 positive mentions 0.41 0.35 0.24 0.54 0.64 0.64 -0.26 0.08 -0.09 0.04 negative mentions -0.53 -0.46 0.46 -0.08 -0.32 -0.32 -0.47 -0.54 0.46 -0.98 neutral mentions -0.35 -0.29 0.45 0.05 -0.15 -0.15 -0.44 -0.32 0.25 -0.68 total mentions -0.38 -0.32 0.45 0.02 -0.18 -0.18 -0.43 -0.37 0.30 -0.78 49 Correlation Tables Table A.11: Aggregators correlation for Jerónimo de Sousa (PCP) normalized polarity polarity Over Neutral polarity Over Total subjNeu subjSoV subjVol share share Of Neg Distribution normalized negative normalized neutral bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity 1.00 polarityONeutral 0.90 1.00 polarityOTotal 1.00 0.90 1.00 subjNeu -0.77 -0.87 -0.77 1.00 subjSoV -0.27 -0.26 -0.27 0.34 1.00 subjVol -0.45 -0.50 -0.45 0.52 0.48 1.00 share -0.08 -0.10 -0.08 0.16 0.75 0.35 1.00 shareOfNegDistribution -0.74 -0.77 -0.74 0.74 0.46 0.47 0.24 1.00 normalized negative -0.86 -0.90 -0.86 0.85 0.35 0.47 0.16 0.82 1.00 normalized neutral 0.75 0.79 0.75 -0.90 -0.41 -0.45 -0.20 -0.79 -0.88 1.00 normalized positive 0.45 0.41 0.45 -0.28 0.13 -0.23 0.19 -0.26 -0.31 0.20 pollEuro -0.02 -0.03 -0.02 -0.04 -0.03 -0.03 0.03 -0.04 0.02 0.07 pollEuro-1 0.17 0.11 0.17 -0.04 -0.06 0.02 -0.03 -0.02 -0.07 0.01 positive mentions 0.34 0.28 0.34 -0.14 0.28 0.02 0.30 -0.12 -0.21 0.09 negative mentions -0.47 -0.52 -0.47 0.52 0.46 0.98 0.33 0.48 0.49 -0.46 neutral mentions -0.26 -0.27 -0.26 0.27 0.46 0.71 0.41 0.25 0.27 -0.25 total mentions -0.31 -0.34 -0.31 0.35 0.45 0.82 0.42 0.29 0.32 -0.30 50 Correlation Tables Table A.12: Aggregators correlation for Jerónimo de Sousa (PCP) normalized positive pollEuro pollEuro-1 positive mentions negative mentions neutral mentions total mentions bermingham2 normalized bermingham2 bermingham (sovn) bermingham (sovp) connor normalized connor gayo normalized gayo ind polarity normalized polarity polarityONeutral polarityOTotal subjNeu subjSoV subjVol share shareOfNegDistribution normalized negative normalized neutral normalized positive 1.00 pollEuro 0.00 1.00 pollEuro-1 0.11 -0.31 1.00 positive mentions 0.74 -0.10 0.18 1.00 negative mentions -0.26 -0.01 0.00 -0.01 1.00 neutral mentions -0.08 0.02 -0.02 0.12 0.69 1.00 total mentions -0.13 -0.02 0.02 0.10 0.80 0.90 1.00 51 Graphical Representations Figure B.6: Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP) Figure B.7: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the yt1feature 58 Graphical Representations Figure B.8: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP) Figure B.9: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the yt1feature 59 Graphical Representations Figure B.10: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE) B.1.2 Random Forest Figure B.11: Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the yt1feature. 60 Graphical Representations Figure B.12: Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS) Figure B.13: Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the yt1feature. 61 Graphical Representations Figure B.14: Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD) Figure B.15: Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP), excluding the yt1feature. 62 Graphical Representations Figure B.16: Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP) Figure B.17: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the yt1feature. 63 Graphical Representations Figure B.18: Predicted and real values of vote intention, from January 2013 to June 2013, for Paulo Portas (PP) Figure B.19: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the yt1feature. 64 Graphical Representations Figure B.20: Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) 65 Graphical Representations B.2 Experiment using monthly variation B.2.1 Ordinary Least Squares Figure B.21: Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the D(yt1)feature 66 Graphical Representations Figure B.22: Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS) Figure B.23: Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the D(yt1)feature 67 Graphical Representations Figure B.36: Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP) Figure B.37: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the D(yt1)feature. 74 Graphical Representations Figure B.38: Predicted and real values of vote int[!ht]ention, from January 2013 to June 2013, for Paulo Portas (PP) Figure B.39: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the D(yt1)feature. 75 Graphical Representations Figure B.40: Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) 76 Graphical Representations B.3 Experiment Sentiment vs Buzz B.3.1 Sentiment B.3.1.1 Ordinary Least Squares Figure B.41: Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the D(yt1)feature. 77 Graphical Representations Figure B.42: Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS) Figure B.43: Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the D(yt1)feature. 78 Graphical Representations Figure B.44: Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD) Figure B.45: Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP), excluding the D(yt1)feature. 79 Graphical Representations Figure B.46: Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP) Figure B.47: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the D(yt1)feature. 80 Graphical Representations Figure B.48: Predicted and real values of vote int[!ht]ention, from January 2013 to June 2013, for Paulo Portas (PP) Figure B.49: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the D(yt1)feature. 81 Graphical Representations Figure B.50: Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) B.3.1.2 Random Forest Figure B.51: Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the D(yt1)feature. 82 Graphical Representations Figure B.52: Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS) Figure B.53: Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the D(yt1)feature. 83 Graphical Representations Figure B.64: Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD) Figure B.65: Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP), excluding the D(yt1)feature. 90 Graphical Representations Figure B.66: Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP) Figure B.67: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the D(yt1)feature. 91 Graphical Representations Figure B.68: Predicted and real values of vote int[!ht]ention, from January 2013 to June 2013, for Paulo Portas (PP) Figure B.69: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the D(yt1)feature. 92 Graphical Representations Figure B.70: Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) B.3.2.2 Random Forest Figure B.71: Predicted and real values of vote intention, from January 2013 to June, for António José Seguro (PS), excluding the D(yt1)feature. 93 Graphical Representations Figure B.72: Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS) Figure B.73: Predicted and real values of vote intention, from January 2013 to June, for Pedro Passos Coelho (PSD), excluding the D(yt1)feature. 94 Graphical Representations Figure B.74: Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD) Figure B.75: Predicted and real values of vote intention, from January 2013 to June, for Jerónimo de Sousa (PCP), excluding the D(yt1)feature. 95 Graphical Representations Figure B.76: Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP) Figure B.77: Predicted and real values of vote intention, from January 2013 to June, for Paulo Portas (PP), excluding the D(yt1)feature. 96 Graphical Representations Figure B.78: Predicted and real values of vote int[!ht]ention, from January 2013 to June 2013, for Paulo Portas (PP) Figure B.79: Predicted and real values of vote intention, from January 2013 to June, for Catarina Martins e João Semedo (BE), excluding the D(yt1)feature. 97 Graphical Representations Figure B.80: Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE) 98 Graphical Representations B.4 Experiment Sentiment vs Buzz All B.4.1 Sentiment B.4.1.1 Ordinary Least Squares Figure B.81: Predicted and real values of vote intention, from January 2013 to June 2013, for António José Seguro (PS), including the previous poll variation of all political targets 99 Graphical Representations Figure B.92: Predicted and real values of vote intention, from January 2013 to June 2013, for Pedro Passos Coelho (PSD), including the previous poll variation of all political targets Figure B.93: Predicted and real values of vote intention, from January 2013 to June 2013, for Jerónimo de Sousa (PCP), including the previous poll variation of all political targets 106 Graphical Representations Figure B.94: Predicted and real values of vote intention, from January 2013 to June 2013, for Paulo Portas (PP), including the previous poll variation of all political targets Figure B.95: Predicted and real values of vote intention, from January 2013 to June 2013, for Catarina Martins e João Semedo (BE), including the previous poll variation of all political targets 107