joel
By: a guest | Feb 20th, 2008 | Syntax:
Python | Size: 0.74 KB | Hits: 82 | Expires: Never
#!/usr/bin/env python
import cPickle
import sys
def print_questions(qlist):
for q,stats in qlist:
times=len(stats[0])
print "%s\t:%d/%d errors, avg time %.2f" % (q[0],(times-sum(stats[0])),times,sum(stats[1])/times)
if len(sys.argv) < 2 : raise "Usage: show_stats.py login"
a=cPickle.load(open('compute_stats_%s.pck'%sys.argv[1]))
b=a.items()
print "showing by score"
b.sort(key=lambda i:sum(i[1][0])/len(i[1][0]),reverse=True) #sort by accuracy score
print_questions(b)
#for i in b: print i
print "showing by average time"
b.sort(key=lambda e:sum(e[1][1])/len(e[1][1]))
print_questions(b[-10:])
print "Overall average answer time: %.2fs" % (sum([sum(stats[1]) for q,stats in b])/sum([len(stats[1]) for q,stats in b]))