Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,793 members, 7,813,625 topics. Date: Tuesday, 30 April 2024 at 03:09 PM

Data Science Project: Twitter Sentiment Analysis On Presidential Election '19 - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Data Science Project: Twitter Sentiment Analysis On Presidential Election '19 (914 Views)

Can I Do Data Analysis On An Android Phone / Can I Write A Computer Science Project Without Design And Implementation? / Computer Science Project Materials And Topics (2) (3) (4)

(1) (Reply) (Go Down)

Data Science Project: Twitter Sentiment Analysis On Presidential Election '19 by sleemfesh: 8:28pm On Feb 15, 2019
"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 Nigeria 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.

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 be 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 reach 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 headers) 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.

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, the vice versa. the result is the adjusted positive and negative for each candidate.

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

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 who with very wide reach having hundreds of thousands of. 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.

Tools [/b]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.

[b]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.

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."

Source: https://www./twitter-sentiment-analysis-major-candidates-2019-nigeria-amah/

Re: Data Science Project: Twitter Sentiment Analysis On Presidential Election '19 by lahp(m): 12:41am On Feb 16, 2019
Re: Data Science Project: Twitter Sentiment Analysis On Presidential Election '19 by talk2hb1(m): 6:41am On Feb 16, 2019
Good Work Man, Why not publish your result in a visual (Charts, bar, table, etc) for end users maybe we could encourage Nairaland to push it to the frontpage.
Great work you have done, keep it up.
Re: Data Science Project: Twitter Sentiment Analysis On Presidential Election '19 by sleemfesh: 9:40pm On Feb 16, 2019

(1) (Reply)

Katie Bouman, Lady Who Helped Capture The First Image Of A Black Hole / How Do I Solve This Python (anaconda) Problem / ALX Data Science & Data Analyst Program Whatsapp Group Link

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 30
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.