Mercurial > ift6266
comparison deep/stacked_dae/v_sylvain/nist_apriori_error.py @ 439:5ca2936f2062
Bug fix in per-class a priori error : should be lower than before for both upper and lower
author | Guillaume Sicard <guitch21@gmail.com> |
---|---|
date | Mon, 03 May 2010 09:42:36 -0400 |
parents | fb028b37ce92 |
children | b2a7d93caa0f |
comparison
equal
deleted
inserted
replaced
438:a6d339033d03 | 439:5ca2936f2062 |
---|---|
1 # -*- coding: utf-8 -*- | |
1 __docformat__ = 'restructedtext en' | 2 __docformat__ = 'restructedtext en' |
2 | 3 |
3 import pdb | 4 import pdb |
4 import numpy | 5 import numpy |
5 from numpy import array | 6 from numpy import array |
63 print('Number of layers not implemented yet, please do it') | 64 print('Number of layers not implemented yet, please do it') |
64 | 65 |
65 | 66 |
66 total_error_count=0 | 67 total_error_count=0 |
67 total_exemple_count=0 | 68 total_exemple_count=0 |
69 total_error_count_wap=0 | |
70 | |
68 if part == 0: | 71 if part == 0: |
69 iter = dataset.train(1) | 72 iter = dataset.train(1) |
70 if part == 1: | 73 if part == 1: |
71 iter = dataset.valid(1) | 74 iter = dataset.valid(1) |
72 if part == 2: | 75 if part == 2: |
109 ## for i in xrange(len(out_act[0])): | 112 ## for i in xrange(len(out_act[0])): |
110 ## out[i]=sigmoid(array(out_act[0,i])) | 113 ## out[i]=sigmoid(array(out_act[0,i])) |
111 | 114 |
112 #get grouped based error | 115 #get grouped based error |
113 #with a priori | 116 #with a priori |
114 if(y>9 and y<35): | 117 if(y>9 and y<36): |
115 predicted_class=numpy.argmax(out[0,10:35])+10 | 118 predicted_class=numpy.argmax(out[0,10:36])+10 |
116 if(predicted_class!=y): | 119 if(predicted_class!=y): |
117 total_error_count+=1 | 120 total_error_count+=1 |
118 | 121 |
119 if(y<10): | 122 if(y<10): |
120 predicted_class=numpy.argmax(out[0,0:10]) | 123 predicted_class=numpy.argmax(out[0,0:10]) |
121 if(predicted_class!=y): | 124 if(predicted_class!=y): |
122 total_error_count+=1 | 125 total_error_count+=1 |
123 if(y>34): | 126 if(y>35): |
124 predicted_class=numpy.argmax(out[0,35:])+35 | 127 predicted_class=numpy.argmax(out[0,36:])+36 |
125 if(predicted_class!=y): | 128 if(predicted_class!=y): |
126 total_error_count+=1 | 129 total_error_count+=1 |
127 | 130 #without a priori |
131 predicted_class=numpy.argmax(out) | |
132 if(predicted_class!=y): | |
133 total_error_count_wap+=1 | |
134 | |
128 print '\t total exemples count: '+str(total_exemple_count) | 135 print '\t total exemples count: '+str(total_exemple_count) |
129 print '\t total error count: '+str(total_error_count) | 136 print '\t total error count: '+str(total_error_count) |
130 print '\t percentage of error: '+str(total_error_count*100.0/total_exemple_count*1.0)+' %' | 137 print '\t percentage of error: '+str(total_error_count*100.0/total_exemple_count*1.0)+' %' |
138 print '\t total error count without a priori: '+str(total_error_count_wap) | |
139 print '\t percentage of error without a priori: '+str(total_error_count_wap*100.0/total_exemple_count*1.0)+' %' | |
131 | 140 |
132 | 141 |
133 def sigmoid(value): | 142 def sigmoid(value): |
134 ## if len(value) > 1: | 143 ## if len(value) > 1: |
135 ## retour = numpy.zeros(len(value),float) | 144 ## retour = numpy.zeros(len(value),float) |