Tuesday, October 27, 2015

Composition of Facebook photos by gender of account holder

I downloaded 2400 profile pics by scraping http://www.facebookrandomusers.com, and then manually sorted them into the various categories. I came up with the categories to reflect the most salient features, e.g. whether they photo had a child in it, regardless of whether it had adults in it too.

The results are about what I would have predicted. Men are more likely to just show themselves, or some image that is not of a human being, or the default photo (presumably by an abandoned account), while women are most likely to show themselves with one other adult (who may or may not be a romantic partner), or a child.

Tuesday, October 20, 2015

Hexmaps of the 2015 Canadian federal election

My apologies, these maps don't display well on mobile devices; I tried to fix it, but then they didn't display well on wide desktop screens. I need JavaScript lessons.

Riding-by-riding hexmap

Last night as of this writing, October 19, 2015, Canadians once again proved how difficult polling is in this country, and tossed the ruling Stephen Harper Conservative government out, to be replaced by the Liberals, led by Justin Trudeau, son of former PM Pierre-Eliot Trudeau. The left-learning New Democratic Party (NDP), elected in 2011 to be official opposition for the first time in what was called the 'Orange Wave', suffered an 'Orange Crush'.

It's hard to make maps of Canadian elections, because each riding has approximately the same number of electors, yet are of vastly different sizes due to particular geography of Canada. The smallest riding, at 6 square kilometers, is Toronto Centre; the largest, over 300,000 TIMES LARGER, is Nunavut (1.8 million sq. km.).

Therefore I made a hex grid of Canadian ridings (since the ridings are of equal population, it's technically a cartogram), which was a challenge. I used Spatialite to calculate shared borders and distances between riding centers, and Gephi to create network graphs. I tried to preserve, as much as possible, the local features (so that ridings which have neighboring borders and/or are close together will be in nearby hexes) and global features (the overall shape of Canada). It was hard, and I had to make lots of judgment calls; I leave it to others to judge the results.

The most striking part of this election as a spectator was on the right; the Liberals won every single one of the 33 seats in the Atlantic and Newfoundland time zones. These results were being released while the polls were still open in the West, an odd feature of Canadian politics. I can't help but think that has some effect.

Overall election results

I know, they're pie charts, which professionals hate, but they have two overwhelming virtues: everyone knows what they are when they look at them, and they (mostly) unambiguously show parts of a whole. The liberals outperformed the Conservatives by a factor of 1.24 in terms of votes, but 1.86 in terms of seats, and with a majority government end up with 100% of the power, which is why there are those who call for an end to first-part-the-post elections and the institution for some sort of more proportional representation scheme.

Traditional election map, for comparison

Here's a traditional map that preserves riding sizes. The smaller ridings are, of course, invisible, so it's hard to get an accurate picture. This is a screenshot from one of Canada's national newspapers, The Globe and Mail, and of course it's zoomable on their website; plus, I suppose I shouldn't criticize them too much since theirs was the only site nice enough to present election data in a form that I could scrape it at 4:00 a.m. the next day.

Hexmap of 2011 election (redistributed to 2015 ridings)

Canada was redistricted to have 338 ridings two years ago instead of the previous 308 (to the consternation of Canadian political statistics website www.threehundredeight.com, I'm sure), and the official government body Elections Canada was nice enough to show what the results of that election would have been with polling stations redistributed to the ridings they fall in now. You can see the Orange Wave in Quebec, and the Conservative majority government led by Ontario and the West, and the non-unanimously red East.

Second-place finishes

You can see most of the two-way battles were between Liberal and Conservative in Ontario and Alberta, NDP and Conservative in the rest of the prairies, Liberal-NDP or Bloc-NDP in most of Quebec, and Con-NDP or Con-Lib in the Atlantic. BC, as usual, has a bit of everything. The lone 'Other' second-place finish in Newfoundland is a former Liberal MP who was kicked out of the caucus amid sexual harrassment allegations and ran as an independent.

Margin of victory

Most of the landslides were in the Atlantic and Prairies, and most of the close finishes were in Ontario and Quebec.

Winners shaded by margin of victory

This allows us to see that the most of the landslides were Conservative in the Prairies, and Liberal elsewhere.

Voter turnout

Turnout was 68-69% (depending on whose numbers you use), far higher than the 61% in the 2011 election. The clusters of high turnout are in Ottawa (a political town), Vancouver Island (lots of old folks who like to vote), the Prairies (lots of dedicated Conservative voters) and the Atlantic provinces (who, it appears, were pissed off enough at the Conservatives to turn out in drovers). The lower vote turnouts seem to happen most often in rural ridings, where it's a longer driver to the polling stations.

Sources: Elections Canada (riding geography and statistics), The Globe and Mail (elections results)
Tools: Python, Chorogrid, JavaScript, Raphael.js, Gephi, Spatialite, Excel

Popular Posts

Scroll To Top