Skip to content

Instantly share code, notes, and snippets.

View ajschumacher's full-sized avatar

Aaron Schumacher ajschumacher

View GitHub Profile
@ajschumacher
ajschumacher / README.md
Created April 25, 2013 15:49
NYC schools
@ajschumacher
ajschumacher / README.md
Last active December 14, 2015 18:09 — forked from mbostock/.block
NYC Subway Usage

This shows New York City subway usage based on turnstile data. Hovering over a day shows the number of entries through subway turnstiles in that day.

Notice the clear effects of hurricanes Irene and Sandy.

More details and source code available. Visualization based (heavily) on Mike Bostock's excellent example.

#!/usr/bin/env python
import sys
import csv
def MeanAveragePrecision(valid_filename, attempt_filename, at=10):
at = int(at)
valid = dict()
for line in csv.DictReader(open(valid_filename,'r')):
valid.setdefault(line['source_node'],set()).update(line['destination_nodes'].split(" "))
@ajschumacher
ajschumacher / make_completer.py
Created June 7, 2012 01:01
This code generates a file that gets a score of 0.61758 at http://www.kaggle.com/c/FacebookRecruiting/
import csv
r = csv.reader(open('train.csv','r'))
r.next()
edges = set()
#commutative_graph = dict()
for edge in r:
edges.add((edge[0], edge[1]))
# commutative_graph.setdefault(edge[0], set()).add(edge[1])