Created
December 7, 2011 21:22
-
-
Save joelthelion/1444728 to your computer and use it in GitHub Desktop.
What language do the best AI programmers use?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# coding: utf-8 | |
import json | |
a=json.load(open("ranking_json.php")) # get at http://aichallenge.org/ranking_json.php | |
print a.keys() | |
#print a["values"][8] | |
#print a["values"][8][18] # skill | |
#print a["values"][8][22] # games | |
#print a["values"][8][7] # language | |
#print a["values"][8][3] # country | |
#print a["values"][8][12] # ranking | |
def dic_append(dic,key,value): | |
if not dic.has_key(key): | |
dic[key] = [] | |
dic[key].append(value) | |
keys = { "language" : 7, "country" : 3 } | |
for key_name, key_index in keys.items(): | |
groups={} | |
for p in a["values"]: | |
try: | |
if int(p[22]) > 10: | |
dic_append(groups,p[key_index],(p[12],p[18],p[3],p[22],p[1])) | |
except TypeError: | |
pass | |
from matplotlib import pylab as pl | |
for language,players in groups.items(): | |
ranks = [] | |
for ranking,skill,country,games,login in players: | |
ranks.append(int(ranking)) | |
#ranks.append(float(skill)) | |
if len(ranks) > 10: | |
pl.figure() | |
pl.hist(ranks,bins=max(10,len(ranks)/20),label=language) | |
pl.legend() | |
pl.xlabel("Rank") | |
pl.ylabel("Number of players") | |
pl.savefig("figs/%s_%s.png" % (key_name,language)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment