Skip to content

Instantly share code, notes, and snippets.

@rsivapr
rsivapr / make_completer.py
Created June 25, 2012 15:20 — forked from ajschumacher/make_completer.py
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])
@rsivapr
rsivapr / map.py
Created June 23, 2012 03:47 — forked from ajschumacher/map.py
Calculates the Mean Average Precision, as in: http://www.kaggle.com/c/FacebookRecruiting/details/Evaluation
#!/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(" "))