Twitter Sentiment Analysis: Major Candidates of the 2019 Nigeria Presidential Elections.

Twitter Sentiment Analysis: Major Candidates of the 2019 Nigeria Presidential Elections.

Sometime in October 2018, I was thinking about the frontiers of data science and how it is so cool to talk of data science and all things data. There has been talk of how it changes how people and organisations view things. I decided it would be interesting to see how data science can be used to look into one of the hottest topics in town: politics. I am a Nigerian living in the country at the moment so I decided to look at what people thought about the major candidates in the forthcoming election and how it would eventually relate to the result that will be announced by the national electoral body, INEC.

No alt text provided for this image

Project Team: I assembled a team of young men and women. I told them I had no monetary reward to offer but I was willing to give them what I can hoping that it matters: an opportunity to learn the python programming language. We met towards the end of October 2018 and I put them through on the project, helped them get equipped and handed them the python script for data gathering on twitter. Three months later and hours away from the 2019 presidential election in Nigerian, I am excitedly tapping away on my laptop. I hope this would not be too long and that it shows as much as we have been able to glean.


Some Considerations: The backdrop of this project revolves around the unsubstantiated claim that social media in Nigeria has no relationship with what happens at our elections. It is strange how most seem to buy it whereas there is abundant reason to think otherwise. I have several numbers I would love to throw around here but for the desire to be brief, suffice it to say that on the average, majority of social media users especially Facebook and Twitter, are between the ages of 18 and 34. Compare this with the Nigerian population age median of 17.9 years and 51.11% of the 84m registered voters being between 18 and 34 years. There is no gainsaying the place of social media pulse in the scheme of things in this our awesomely young nation.

More so, as I am an avid agent and fan of natural language processing, I thought the body of data from tweets about the Nigeria presidential election, which will arguably be predominantly contributed by Nigerians, will go a long way into building a dictionary of Nigerian speak with all its uniqueness. Finally, why Twitter? Well, like I answered a member of the team, it is because of the level of anonymity that Twitter engenders with its use of @handles. This seems to promote high octane frankness. You are just your handle. It could be xyz! If you have noticed, Nigerians are good at 'trailer jams' on this network: they let their hearts out on topics close to their heart and are not afraid to vent their frustration as frank as they come. What better platform than this? On the technical side, the twitter API is more straightforward and signing up for a developer account is not as blood sucking as say Facebook. Yea.


Down to Business: I will go straight to the point. The team collected a couple thousand tweets shy of 500k on the main aspirants: Atiku and the incumbent Buhari. 'Main' simply because they fly the flag of the two biggest parties with the muscle to go countrywide. The collection was divided into the three parts of the day: morning, afternoon, night. This is to ensure the best possible distribution of the feed. They streamed live tweets with tweepy in python. In a WhatsApp group and with Dropbox and WeTransfer, we were able to move data around. For the most part of 5 days, I was collating and cleaning the data. From the 34 or so columns that each tweet comes with (the 'user' column of the json file returned comes further nested with a dictionary of another 30 or so keys) I was able to take it all down to 6 and built two more to parse information from one that was needed in separate columns.

No alt text provided for this image

Summary of Insights: The overall sentiment of all 222,709 tweets (minus the neutral ones) on 'Buhari' showed that 58% and 42% were positive and negative respectively. Of the 275,576 about Atiku, it was 67% and 33% respectively. Each tweet is very rich with information ranging from the text/tweet itself to number of friends, followers, location and so on. Furthermore, it is instructive to note that some of the negative and positive lines have both names in it. This would be as a result of a comparison. Who gets positive from it and who takes the negative without having to go through one by one? As I did not do subject based analysis, I decided to remove all lines of the mention of candidate a in the positive group of candidate b and same in the negative group, then vice versa. The result is the adjusted positive and negative for each candidate.

No alt text provided for this image


Location information is not always available on all of them but from those that had, I decided to pick out the major states of the federation as well as the states of the candidates and their running mates. It was interesting that in Kaduna, candidate Atiku at 77.1%, had more positive sentiment than Buhari's 73.3 being that it is the latter's home state. In Adamawa, Atiku's home state, he had 62.2% while Buhari had 53.9%.

No alt text provided for this image

More information is available from our work but this the major thrust of it. There are metrics like the single most prolific tweep on each candidate as well as those with very wide reach: having hundreds of thousands of followers. Users like this will arguably sway sentiments on the candidates more the average Joe. In keeping with Twitter terms and in good faith, I am not going to put those out here. There are also things that the most favorable time for each candidates as well the traffic on them on certain days. These might be priceless brand managers and others like that who are interested in making that their 'market' is selling.

No alt text provided for this image

Tools used for this project include predominantly the python programming language which went into data gathering, cleaning, structuring and eventual analysis. Members of the team have also created Power BI dashboards and working on something with Tableau.

No alt text provided for this image

Limitations. I tried as much as possible to guide the team towards getting data three different parts of the day. So, although this might be fair, it does not cover all tweets for 24 hours of the day during this period. Location information is only available for some tweets. The location specific sentiments captured here are from the tweets that bore a valid location tag.

Finally, I want to specially thank the members of this team for their selfless sacrifice. Nathan Clifford did one of the dashboards on Power BI; and the rest of the team starting from the ladies: Grace Aina, Chinasa Ezeoke, Haleemah Oyindamola OLANASE, Taiwo Jackson and the guys: Francis Obasi (the inquisitioner), Adafin Joseph (the spark bulb), Ayodele Osho (with an eye for detail), Onipede Emmanuel, Bamise Olowookere, Chigozie Njoku, Olamide (not badoo) Onakoya, Ahmed Salau (with the smile, hehe), Valentine Ezeja, Tooritsemoshe Ojei, Michael Obiora. Thanks for your time and data, two precious commodities in Nigeria.

Footnote: This is not an attempt to predict the outcome of the 2019 Nigeria presidential election. It is an attempt to see how the sentiment of Nigerians relate to the eventual outcome of the election.

Ciao.

Herbert Nnadi

Researcher, writer and social affairs analyst

4 年

This is highly data-specific survey, with objectivity and has the natural information flow. The electoral system of Nigeria could go better if IT processed. There is a positive political economy in having a better electoral outcome.

Adedeji Adegoke

Data Analyst | Data Scientist

5 年

Brilliant man

Ighodaro Emwinghare

Senior Data Scientist

5 年

Wonderful!!! Will you commit the code to open source like github? I will really be grateful if I can get a hold of it.. Meanwhile I would love to be part of any data science project pro-bono. Great work sir!

要查看或添加评论,请登录

Paschal Chukwuemeka Amah的更多文章

社区洞察

其他会员也浏览了