by Rob Davidson
On Monday, October 27, 2014, the capital city of Canada, Ottawa, conducted a municipal election for Mayor, city Councillors and school board trustees. As part of the Open Data Ottawa initiative, the city made available information about each candidate, including Twitter accounts. The data can be found at OttawaElection2014 . This project seeks to explore the Twitter network of city council candidates and to see if anything can be learned from it. The approach was to get the list of followers for every candidate and create a graph where the nodes are the candidates and the followers and the edges are the following relationship of followers to candidates. Followers names were not captured for privacy purposes. R was used to access the Twitter API and to generate the GraphML file for loading into Gephi for exploratory analysis.
The original idea was to use the number of Twitter followers each Council candidate has collected to predict the winner of the election. The model predicted 17 of 23 ward winners correctly.
The model predicted the following ward council winners incorrectly:
Ward 20 Osgoode
Ward 13 Rideau-Rockcliffe
Ward 18 Alta Vista
Ward 16 River
Ward 22 Gloucester-South Nepean
Ward 19 Cumberland
Possible Reasons for Incorrect Predictions:
Council candidates’ Twitter follower counts impacted by previous election campaigns (Ward 13, Ward 16)
Council candidate member of press (Ward 22)
Twitter Boosting? (as per TwitterAudit) (Ward 19)
Gephi is a graph manipulation and visualization tool. The election data was represented as follows:
Based on the results using the simple Twitter followers model, a deeper look into the incorrect predicts was warranted. Using an R program, data from Ward 16 was written into a GraphML format, with nodes as candidates and their followers and edges as a directed follower relationship to candidates. The GraphML file was then loaded into Gephi and Yifan Hu layout applied.
The model predicted Mike Patton won election but Riley Brockington was the winning candidate. It was clear that Mike Patton had many followers that did not follow any of the other candidates. Using a Gephi filter, only followers with an out-degree greater than one were retained.
The filtered graph shows a much closer race. Using Gephi Data Laboratory to sort candidates by In-Degree, the actual winner Riley Brockington comes out on top.
Given the success of the Out-Degree filter for Ward 16, it was applied to all wards with more than two candidates with Twitter followers (wards with only two candidates with Twitter accounts should have exactly the same number of followers with out-degrees greater than 1). The resulting model predicted 16 out of 18 wards correctly.
Taking a closer look at one of the incorrectly predicted results, ward 18, there is an interesting community in the graph.
The selected community above shared by the two candidates who had a higher In-Degree than the actual winner, is larger than the actual votes the two candidates received. A closer look at this community showed that is mostly comprised not of individuals but nonprofit and charity organizations.
A weakness of this analysis is that Twitter API does not provide information about when a follower began following a candidate. It would also be useful if Twitter provided a flag indicating whether a Twitter account is a branded entity or an individual. Future election analysis would benefit from analysis of follower interaction with candidates, Retweets, Favorites and sentiment analysis of follower direct messages and hashtags relating to candidates and the election.