comparison scripts/stat_graph.py @ 451:227ebc0be7ae

Add a graph for the NIST training set and normalize the values.
author Arnaud Bergeron <abergeron@gmail.com>
date Mon, 10 May 2010 13:44:11 -0400
parents c1df23c98eb6
children
comparison
equal deleted inserted replaced
450:c1df23c98eb6 451:227ebc0be7ae
5 from scipy import stats 5 from scipy import stats
6 import numpy 6 import numpy
7 from ift6266 import datasets 7 from ift6266 import datasets
8 8
9 nistp_valid = stats.itemfreq(datasets.PNIST07().valid(10000000).next()[1]) 9 nistp_valid = stats.itemfreq(datasets.PNIST07().valid(10000000).next()[1])
10 nistp_valid[:,1] /= sum(nistp_valid[:,1])
10 nist_valid = stats.itemfreq(datasets.nist_all().valid(10000000).next()[1]) 11 nist_valid = stats.itemfreq(datasets.nist_all().valid(10000000).next()[1])
12 nist_valid[:,1] /= sum(nist_valid[:,1])
11 nist_test = stats.itemfreq(datasets.nist_all().test(10000000).next()[1]) 13 nist_test = stats.itemfreq(datasets.nist_all().test(10000000).next()[1])
12 print 'nistp_valid', sum(nistp_valid[:,1]) 14 nist_test[:,1] /= sum(nist_test[:,1])
13 print 'nist_valid', sum(nist_valid[:,1]) 15 nist_train = stats.itemfreq(datasets.nist_all().train(100000000).next()[1])
14 print 'nist_test', sum(nist_test[:,1]) 16 nist_train[:,1] /= sum(nist_train[:,1])
15 17
16 xloc = numpy.arange(62)+0.5 18 xloc = numpy.arange(62)+0.5
17 19
18 labels = map(str, range(10)) + map(chr, range(65,91)) + map(chr, range(97,123)) 20 labels = map(str, range(10)) + map(chr, range(65,91)) + map(chr, range(97,123))
19 21
21 figure(figsize=(8,6)) 23 figure(figsize=(8,6))
22 # clf() 24 # clf()
23 bar(xloc, data, width=width) 25 bar(xloc, data, width=width)
24 xticks([]) 26 xticks([])
25 for x, l in zip(xloc, labels): 27 for x, l in zip(xloc, labels):
26 text(x+width/2, -250, l, horizontalalignment='center', verticalalignment='baseline') 28 text(x+width/2, -0.004, l, horizontalalignment='center', verticalalignment='baseline')
27 # xticks(xloc+width/2, labels, verticalalignment='bottom') 29 # xticks(xloc+width/2, labels, verticalalignment='bottom')
28 xlim(0, xloc[-1]+width*2) 30 xlim(0, xloc[-1]+width*2)
29 ylim(0, 7000) 31 ylim(0, 0.1)
30 32
31 savefig(fname) 33 savefig(fname)
32 34
33 35
34 makegraph(nistp_valid[:,1], 'nistpvalidstats.png') 36 makegraph(nistp_valid[:,1], 'nistpvalidstats.png')
35 makegraph(nist_valid[:,1], 'nistvalidstats.png') 37 makegraph(nist_valid[:,1], 'nistvalidstats.png')
36 makegraph(nist_test[:,1], 'nistteststats.png') 38 makegraph(nist_test[:,1], 'nistteststats.png')
39 makegraph(nist_train[:,1], 'nisttrainstats.png')