Firefox visualization competition submission description

Firefox has a competition to visualize some data they’ve collected (found through this FlowingData.com post). After a week and a half of intense work, I have finished and submitted a visualization. Links are below, but first: Special thanks to Rob Ploutz-Snyder and Sheila Moore for some very helpful suggestions, and Phillip Fiedler for helping me get the visualization online. And thanks to the maker of the JavaScript library raphael.js.

If you use Internet Explorer, you can see a static version of the visualization here. I don’t think the dynamic version will work for you. Also, the dynamic version won’t work if you have JavaScript disabled.

Everyone else (hopefully) can see the visualization, here. As you look over the visualization, keep in mind this rule: If your cursor changes from the default arrow, this indicates there is some kind of interactivity available. The histograms can be dragged left and right to move them in their viewing windows. The proportion graphs on the right hand side have even more interactivity, but they come with their own explanation, which can be accessed by clicking on the “?” at the top.

Background info and details

Below, I’ll lay out exactly which data set I’m using, explain how I made my visualization, and give some code I used.

Dataset

I am using data from the study titled “A Week in the Life of a Browser – Version 2“. Specifically, I am using data from “witl_large.tar.gz”, which contains three files. One file, users.csv, has info for all (?) 27,000-some users in the study. From this file I only use the number of extensions (programs that users can install to add functionality to Firefox) and the operating system.

A second file, events.csv, contains event data for some 26,000 of the 27,000 users. From this file I only use events pertaining to the number of open tabs and the number of bookmarks. The last file, survey.csv, contains survey info for 4,000 users who completed a survey.

Issues

There were no issues with the users.csv file. In the events.csv file, there were a few anomalies that forced me to exclude a few users from consideration:

users 752, 15757, and 19054 do not have any tab or bookmark events,

users 4378 and 5022 sometimes have “NaN” as the number of tabs,

another 104 survey participants do not have any event data, and

another 16 users have tab data, but no bookmark data.

One of the dropped survey participants actually did not answer any of the survey questions. I did not screen for this so there might still be non-participants in the “survey participants”.

Code

Part 1. Getting the data

I used Python to pull out the data I wanted and to compute the stats. At first (not knowing how long this would take) I thought I was going to make a series of three visualizations, so I wanted to put the relevant tab and bookmark events into separate files to make them more convenient to work with. The code below does this, putting the events into tabEvents.csv and bmkEvents.csv.

Next, I am going to make mini data tables for three of the parameters of interest: number of extensions, number of tabs, and number of bookmarks. I’m going to treat the operating system data a little different. This isn’t necessarily a good idea; it’s just how I did it. The mini data tables will be lists. Each entry of this list will be a 2-element list with ID and data value.

For number of tabs and number of bookmarks I’m going to use a kind of per-user average. Ideally, I would have a time-weighted average, so if a user had 1 tab open for 1 hour and 2 tabs open for 9 hours that person’s average number of tabs would be . The unweighted average would be . Now, Firefox has provided some timestamp data, so it might be possible to do a time-weighted average, but I don’t trust the timestamps provided. (I would say more about this, but WordPress is already draining all desire to write anything more than necessary. I have a window to type in that is literally less than 1.5 inches tall. I could type this blog post out somewhere else and import it but WordPress removes whitespace when you copy and paste. Formatting the code below was painful. I can’t guarantee it’s correct.) Anyway, I am going to compute the unweighted average number of tabs and bookmarks. (Actually, one could argue that there is s little bit of weighting due to how I make the averages, sort of a startup-weighted average.) Here is the code:

The second-to-last last line made a list of all event users. I will use this later to exclude the survey participants that don’t have event data.

Next I need to make the data table for the number of extensions, and a list that groups users’ IDs together by operating system. All flavors of Windows XP will be considered one group. Likewise for Vista, Windows 7, OS X, and Linux. The lone user of Sun OS is the last group.

The above mini data tables were the versions will “all users”. I need versions with just survey partipants.

sTabData = [x for x in bmkData if x[0] in survID]
sBmkData = [x for x in tabData if x[0] in survID]
sExtData = [x for x in extData if x[0] in survID]
sOSsData = []
for l in OSsData:
sOSsData.append([x for x in l if x in survID])

Part 2. Getting medians, maxima, and histograms

The median is easy; it’s just the middle data value. So here’s a function to get the median.

Proportion graphs (the graphs on the right)

First, I want to divide up the data into the categories. I’m going to create a list for each variable, where each position of the list corresponds to one of the categories. Each position will be filled with a list of all of the IDs of users whose data falls in that category. (I could just count the number of users, rather than store the IDs, but the stored IDs will be useful in minute.) Then, I’ll calculate what per cent of the total is in each category, and convert that into a bar width.

In the last line , the “-3.5*(len(thisbox)-1)” leaves room for the gaps between the bars. (This introduces a tiny amount (1%) of distortion when comparing any of the first three graphs with the last one.)

The very last thing to do is to calculate the intersections of all of these sets of user IDs. All of the interactivity in the right section of the graph is based on intersections of categories. The following messy bit of code calculates the sizes of these intersections.

It would take a lot of work to explain the code in detail. I’ll just point out that each g*Effect contains multiple images of the entire graph. Also, “g0″ refers to the “Number of extensions” section, “g1″ refers to the tab section, and so on. The “all user” graphs are the first half of g*Effect, and the “survey” graphs are the second half. Here is the code for the first version of graphs on the right-hand side.

The code for the second version of the graphs is similar. In the above, just replace (*BoxID[]) by len(idBox0[i]) or len(idBox0[i]), whichever is appropriate. I would just put the code below, but WordPress sucks for trying to write out code, and I’m.