Changeset 14
- Timestamp:
- 07/22/15 19:38:49 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/graph
r13 r14 74 74 #longs = [s['packet_rtt'] for s in samples.values() if s['test_case']=='long'] 75 75 76 short_overtime = [(sample['time_of_day'],sample['short']) for sample in timeSeries(db,'train','short')] 77 long_overtime = [(sample['time_of_day'],sample['long']) for sample in timeSeries(db,'train','long')] 78 diff_overtime = [(sample['time_of_day'],sample['long']-sample['other_cases']) for sample in timeSeries(db,'train','long')] 79 short_overtime.sort() 80 long_overtime.sort() 81 diff_overtime.sort() 82 83 print('packet_rtt diff mean: %f' % statistics.mean(diffs)) 84 print('packet_rtt diff median: %f' % statistics.median(diffs)) 85 print('packet_rtt diff midhinge: %f' % midsummary(diffs)) 86 print('packet_rtt diff trimean: %f' % trimean(diffs)) 87 print('packet_rtt diff quadsummary: %f' % quadsummary(diffs)) 88 print('packet_rtt diff ubersummary: %f' % ubersummary(diffs)) 89 print('packet_rtt diff septasummary: %f' % septasummary(diffs)) 90 print('packet_rtt diff MAD: %f' % mad(diffs)) 91 try: 92 print('reported diff trimean: %f' % trimean(reported_diffs)) 93 print('reported diff quadsummary: %f' % quadsummary(reported_diffs)) 94 print('reported diff ubersummary: %f' % ubersummary(reported_diffs)) 95 print('reported diff septasummary: %f' % septasummary(reported_diffs)) 96 print('reported diff MAD: %f' % mad(reported_diffs)) 97 98 #import cProfile 99 #start = time.time() 100 #kresults = kfilter({},diffs) 101 #print('packet_rtt diff kfilter: ', numpy.mean(kresults['est']), kresults['var']) 102 #print('packet_rtt diff kfilter: ', kresults['est'][-1], kresults['var'][-1]) 103 #kresults = kfilter({},reported_diffs) 104 #print('reported diff kfilter: ', numpy.mean(kresults['est']), kresults['var'][-1]) 105 #print('reported diff kfilter: ', kresults['est'][-1], kresults['var'][-1]) 106 #print("kfilter time: %f" % (time.time()-start)) 107 except: 108 pass 109 110 #print('tsval diff mean: %f' % numpy.mean(differences(db, 'long', 'tsval'))) 111 #print('tsval null diff mean: %f' % numpy.mean(null_differences(db, 'long', 'tsval'))) 112 #print('tsval diff weighted mean: %f' % tsvalwmean(db.subseries('train','long')+db.subseries('test','long'))) 113 #print('tsval null diff weighted mean: %f' % tsvalwmean(db.subseries('train_null','long'))) 114 115 76 77 def basicStatistics(): 78 print('packet_rtt diff mean: %f' % statistics.mean(diffs)) 79 print('packet_rtt diff median: %f' % statistics.median(diffs)) 80 print('packet_rtt diff midhinge: %f' % midsummary(diffs)) 81 print('packet_rtt diff trimean: %f' % trimean(diffs)) 82 print('packet_rtt diff quadsummary: %f' % quadsummary(diffs)) 83 print('packet_rtt diff ubersummary: %f' % ubersummary(diffs)) 84 print('packet_rtt diff septasummary: %f' % septasummary(diffs)) 85 print('packet_rtt diff MAD: %f' % mad(diffs)) 86 try: 87 print('reported diff trimean: %f' % trimean(reported_diffs)) 88 print('reported diff quadsummary: %f' % quadsummary(reported_diffs)) 89 print('reported diff ubersummary: %f' % ubersummary(reported_diffs)) 90 print('reported diff septasummary: %f' % septasummary(reported_diffs)) 91 print('reported diff MAD: %f' % mad(reported_diffs)) 92 93 #import cProfile 94 #start = time.time() 95 #kresults = kfilter({},diffs) 96 #print('packet_rtt diff kfilter: ', numpy.mean(kresults['est']), kresults['var']) 97 #print('packet_rtt diff kfilter: ', kresults['est'][-1], kresults['var'][-1]) 98 #kresults = kfilter({},reported_diffs) 99 #print('reported diff kfilter: ', numpy.mean(kresults['est']), kresults['var'][-1]) 100 #print('reported diff kfilter: ', kresults['est'][-1], kresults['var'][-1]) 101 #print("kfilter time: %f" % (time.time()-start)) 102 except: 103 pass 104 105 #print('tsval diff mean: %f' % numpy.mean(differences(db, 'long', 'tsval'))) 106 #print('tsval null diff mean: %f' % numpy.mean(null_differences(db, 'long', 'tsval'))) 107 #print('tsval diff weighted mean: %f' % tsvalwmean(db.subseries('train','long')+db.subseries('test','long'))) 108 #print('tsval null diff weighted mean: %f' % tsvalwmean(db.subseries('train_null','long'))) 109 110 111 112 def exampleBoxTestHistogram(low,high): 113 num_bins = 300 114 all = db.subseries('train','long')+db.subseries('test','long') 115 s = [s['other_packet'] for s in all] 116 l = [s['unusual_packet'] for s in all] 117 118 s_low,s_high = numpy.percentile(s, (low,high)) 119 l_low,l_high = numpy.percentile(l, (low,high)) 120 121 s.sort() 122 cut_off_low = s[int(len(diffs)*0.002)] 123 cut_off_high = s[int(len(diffs)*0.998)] 124 125 plt.clf() 126 # the histogram of the data 127 #n, bins, patches = plt.hist(s, num_bins, normed=1, color='blue', histtype='step', alpha=0.8, 128 # label='Test Case 1') 129 #n, bins, patches = plt.hist(l, num_bins, normed=1, color='red', histtype='step', alpha=0.8, 130 # label='Test Case 2') 131 # 132 n, bins, patches = plt.hist((s,l), num_bins, normed=1, color=('blue','red'), histtype='step', alpha=0.8, 133 label=('Test Case 1','Test Case 2'), range=(cut_off_low,cut_off_high)) 134 135 from matplotlib.patches import FancyBboxPatch 136 currentAxis = plt.gca() 137 currentAxis.add_patch(FancyBboxPatch((s_low, 0), s_high-s_low, 0.0001, boxstyle='square', facecolor="blue", alpha=0.4)) 138 currentAxis.add_patch(FancyBboxPatch((l_low, 0), l_high-l_low, 0.0001, boxstyle='square', facecolor="red", alpha=0.4)) 139 140 141 plt.xlabel('RTT Difference') 142 plt.ylabel('Probability') 143 #plt.title(r'Box Test Example - Overlapping Boxes') 144 145 # Tweak spacing to prevent clipping of ylabel 146 plt.subplots_adjust(left=0.15) 147 plt.legend() 148 plt.show() 149 #plt.savefig('paper/graphs/dists-vs-dist-of-diffs2.svg') 150 151 152 #exampleBoxTestHistogram(6,8) 116 153 117 154 … … 200 237 201 238 202 203 echo_vm_5k={'initial_state_covariance': [[33599047.5,204 -18251285.25,205 3242535690.59375,206 -8560730487.84375],207 [-18251285.25,208 9914252.3125,209 -1761372688.59375,210 4650260880.1875],211 [3242535690.59375,212 -1761372688.59375,213 312926663745.03125,214 -826168494791.7188],215 [-8560730487.84375,216 4650260880.1875,217 -826168494791.7188,218 2181195982530.4688]],219 'initial_state_mean': [12939012.5625,220 12934563.71875,221 13134751.608,222 13138990.9985],223 'observation_covariance': [[11960180434.411114,224 4760272534.795976,225 8797551081.431936,226 6908794128.927051],227 [4760272534.795962,228 12383598172.428213,229 5470747537.2599745,230 11252625555.297853],231 [8797551081.431955,232 5470747537.2601185,233 1466222848395.7058,234 72565713883.12643],235 [6908794128.927095,236 11252625555.297981,237 72565713883.12654,238 1519760903943.507]],239 'observation_matrices': [[1.4255288693095167,240 -0.4254638445329988,241 0.0003406844036817347,242 -0.0005475021956726778],243 [-0.46467270827589857,244 1.4654311778340343,245 -0.0003321330280128265,246 -0.0002853945703691352],247 [-0.2644570970067974,248 -0.33955835481495455,249 1.7494161615202275,250 -0.15394117603733548],251 [-0.3419097544041847,252 -0.23992883666045373,253 -0.15587790880447727,254 1.7292393175137022]],255 'observation_offsets': [165.2279084503762,256 157.76807691937614,257 168.4235495099334,258 225.33433430227353],259 'transition_covariance': [[2515479496.145993,260 -401423541.70620924,261 1409951418.1627903,262 255932902.74454522],263 [-401423541.706214,264 2744353887.676857,265 1162316.2019491254,266 1857251491.3987627],267 [1409951418.1628358,268 1162316.2020361447,269 543279068599.8229,270 -39399311190.5746],271 [255932902.74459982,272 1857251491.398838,273 -39399311190.574585,274 537826124257.5266]],275 'transition_matrices': [[0.52163952865412,276 0.47872618354122665,277 -0.0004322286766109684,278 0.00017293351811531466],279 [0.5167436693545113,280 0.48319044922845933,281 7.765428142114672e-05,282 -0.00021518950285326355],283 [0.2091705950622469,284 0.41051399729482796,285 0.19341113299389256,286 0.19562916616052917],287 [0.368592004009912,288 0.22263632461118732,289 0.20756792378812872,290 0.20977025833570906]],291 'transition_offsets': [592.5708159274,292 583.3804671015271,293 414.4187239098291,294 562.166786712371]}295 296 echo_vm_5k={'initial_state_covariance': [[0.375, 0.0, 0.0, 0.0],297 [0.0, 0.375, 0.0, 0.0],298 [0.0, 0.0, 0.375, 0.0],299 [0.0, 0.0, 0.0, 0.375]],300 'initial_state_mean': [15997944.198361743,301 16029825.435899183,302 17093077.26228404,303 17524263.088803563],304 'observation_covariance': [[36572556646.179054,305 21816054953.37006,306 31144379008.310543,307 19651005729.823025],308 [21816054953.372543,309 440428106325.20325,310 41103447776.740585,311 427146570672.51227],312 [31144379008.31037,313 41103447776.74027,314 3280009435458.6953,315 458734528073.65686],316 [19651005729.82234,317 427146570672.5109,318 458734528073.6557,319 3769493190697.773]],320 'observation_matrices': [[1.0248853427592337,321 -0.031198859962501047,322 0.001613706836380402,323 0.004720209443291878],324 [-0.8604422900368718,325 1.8583369609057172,326 -0.0022646214457040514,327 0.004437933935378169],328 [-0.5814771409524866,329 0.22228184387142846,330 1.6259599749174072,331 -0.271594798325566],332 [-0.5862601003257453,333 0.2598285939005791,334 -0.28286590143513024,335 1.604087079832425]],336 'observation_offsets': [1979.4518332096984,337 1889.3380163762793,338 2132.9112026744906,339 1750.7759421584785],340 'transition_covariance': [[6176492087.271547,341 762254719.4171592,342 4584288694.652873,343 3044796192.4357214],344 [762254719.4185101,345 173302376079.4761,346 5261303152.757347,347 167562483383.9925],348 [4584288694.651718,349 5261303152.755746,350 1056156956874.4131,351 -115859156952.07962],352 [3044796192.434162,353 167562483383.9901,354 -115859156952.08018,355 1225788436266.3086]],356 'transition_matrices': [[0.9673912485796876,357 0.03252962227543321,358 0.0006756067792537124,359 -0.0006566638567164773],360 [0.9548761966068113,361 0.03841774395880293,362 0.00426067282319309,363 0.002303362691861821],364 [0.6215040230859188,365 -0.2584476837756142,366 0.3176491193420503,367 0.3241682768126566],368 [0.6634028281470279,369 -0.33548335246018723,370 0.3298144902195048,371 0.3475836278392421]],372 'transition_offsets': [1751.3049487348183,373 1764.989515773476,374 1986.8405778425586,375 2232.830254345267]}376 239 #testKalman4D(echo_vm_5k) 377 240 … … 429 292 430 293 431 five_iter = {'observation_offsets': [-54.53185823, -55.25219184],432 'observation_covariance': [[ 1.15059170e+10, 4.36743765e+09],433 [ 4.36743765e+09, 1.19410313e+10]],434 'initial_state_mean': [ 12939012.5625 , 12934563.71875],435 'transition_covariance': [[ 2.98594543e+09, 6.86355073e+07],436 [ 6.86355073e+07, 3.21368699e+09]],437 'initial_state_covariance': [[ 2.36836696e+09, 1.63195635e+09],438 [ 1.63195635e+09, 1.12452233e+09]],439 'transition_offsets': [ 343.69740217, 338.5042467 ],440 'observation_matrices': [[ 1.42539895, -0.4255261 ],441 [-0.46280375, 1.46295189]],442 'transition_matrices': [[ 0.56151623, 0.4385931 ],443 [ 0.47309189, 0.52673508]]}444 ten_iter = {'initial_state_covariance': [[229936928.28125, 41172601.0],445 [41172601.0, 7372383.46875]],446 'initial_state_mean': [12939012.5625, 12934563.71875],447 'observation_covariance': [[11958914107.88334, 4761048283.066559],448 [4761048283.066557, 12388186543.42032]],449 'observation_matrices': [[1.4258395826727792, -0.42598392357467674],450 [-0.4647443890462455, 1.4648767294384015]],451 'observation_offsets': [165.409715349344, 157.96206130876212],452 'transition_covariance': [[2515594742.7187943, -401728959.41375697],453 [-401728959.41375697, 2743831805.402682]],454 'transition_matrices': [[0.521306461057975, 0.47879632652984583],455 [0.5167881285851763, 0.483006520280469]],456 'transition_offsets': [592.4419187566978, 583.2272403965366]}457 294 #testKalman(ten_iter) 458 295 … … 475 312 diffs = [s['unusual_packet']-s['other_packet'] for s in all] 476 313 ts0_diffs = [s['unusual_packet']-s['other_packet'] for s in all if s['unusual_tsval']-s['other_tsval'] == 0] 477 ts1_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(s['unusual_tsval']-s['other_tsval']) > 0] 478 ts2_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(round((s['unusual_tsval']-s['other_tsval'])/tcpts_precision)) <= 1.0] 479 480 ts_mode = statistics.mode([s['unusual_tsval'] for s in all]+[s['other_tsval'] for s in all]) 481 ts_diff_mode = statistics.mode([s['unusual_tsval']-s['other_tsval'] for s in all]) 482 ts_common_mode = [s['unusual_packet']-s['other_packet'] for s in all if s['unusual_tsval']<=ts_mode and s['other_tsval']<=ts_mode] 483 ts_common_diff_mode = [s['unusual_packet']-s['other_packet'] for s in all if s['unusual_tsval']-s['other_tsval']==ts_diff_mode] 484 485 print('packet_rtt diff quadsummary: %f' % quadsummary(diffs)) 486 print('packet_rtt tsval diff=0 quadsummary: %f' % quadsummary(ts0_diffs)) 487 print('packet_rtt tsval diff>0 quadsummary: %f' % quadsummary(ts1_diffs)) 488 print('packet_rtt tsval diff<=1 quadsummary: %f' % quadsummary(ts2_diffs)) 489 print('packet_rtt tsval mode quadsummary: %f' % quadsummary(ts_common_mode)) 490 print(len(diffs), len(ts0_diffs)+len(ts1_diffs)) 314 #ts1_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(s['unusual_tsval']-s['other_tsval']) > 0] 315 #ts2_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(round((s['unusual_tsval']-s['other_tsval'])/tcpts_precision)) <= 1.0] 316 ts1_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(int(round((s['unusual_tsval']-s['other_tsval'])/tcpts_precision))) == 1] 317 ts2_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(int(round((s['unusual_tsval']-s['other_tsval'])/tcpts_precision))) >= 2] 318 #ts3_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(int(round((s['unusual_tsval']-s['other_tsval'])/tcpts_precision))) == 3] 319 #ts4_diffs = [s['unusual_packet']-s['other_packet'] for s in all if abs(int(round((s['unusual_tsval']-s['other_tsval'])/tcpts_precision))) == 4] 320 321 #ts_mode = statistics.mode([s['unusual_tsval'] for s in all]+[s['other_tsval'] for s in all]) 322 #ts_diff_mode = statistics.mode([s['unusual_tsval']-s['other_tsval'] for s in all]) 323 #ts_common_mode = [s['unusual_packet']-s['other_packet'] for s in all if s['unusual_tsval']<=ts_mode and s['other_tsval']<=ts_mode] 324 #ts_common_diff_mode = [s['unusual_packet']-s['other_packet'] for s in all if s['unusual_tsval']-s['other_tsval']==ts_diff_mode] 325 326 #print('packet_rtt diff quadsummary: %f' % quadsummary(diffs)) 327 #print('packet_rtt tsval diff=0 quadsummary: %f' % quadsummary(ts0_diffs)) 328 #print('packet_rtt tsval diff>0 quadsummary: %f' % quadsummary(ts1_diffs)) 329 #print('packet_rtt tsval diff<=1 quadsummary: %f' % quadsummary(ts2_diffs)) 330 #print('packet_rtt tsval mode quadsummary: %f' % quadsummary(ts_common_mode)) 331 #print(len(diffs), len(ts0_diffs)+len(ts1_diffs)) 491 332 diffs.sort() 492 cut_off_low = diffs[int(len(diffs)*0.00 5)]493 cut_off_high = diffs[int(len(diffs)*0.99 5)]333 cut_off_low = diffs[int(len(diffs)*0.008)] 334 cut_off_high = diffs[int(len(diffs)*0.992)] 494 335 495 336 plt.clf() 496 337 # the histogram of the data 497 338 n, bins, patches = plt.hist(diffs, num_bins, normed=0, color='black', histtype='step', alpha=0.8, 498 range=(cut_off_low,cut_off_high), label=' all')339 range=(cut_off_low,cut_off_high), label='All Packets') 499 340 n, bins, patches = plt.hist(ts0_diffs, num_bins, normed=0, color='blue', histtype='step', alpha=0.8, 500 range=(cut_off_low,cut_off_high), label='tsval diff=0') 501 n, bins, patches = plt.hist(ts1_diffs, num_bins, normed=0, color='red', histtype='step', alpha=0.8, 502 range=(cut_off_low,cut_off_high), label='tsval diff>0') 503 n, bins, patches = plt.hist(ts2_diffs, num_bins, normed=0, color='orange', histtype='step', alpha=0.8, 504 range=(cut_off_low,cut_off_high), label='tsval diff<=1') 341 range=(cut_off_low,cut_off_high), label='TSval Difference == 0') 342 n, bins, patches = plt.hist(ts1_diffs, num_bins, normed=0, color='orange', histtype='step', alpha=0.8, 343 range=(cut_off_low,cut_off_high), label='TSval Difference == 1') 344 n, bins, patches = plt.hist(ts2_diffs, num_bins, normed=0, color='red', histtype='step', alpha=0.8, 345 range=(cut_off_low,cut_off_high), label='TSval Difference >= 2') 346 #n, bins, patches = plt.hist(ts3_diffs, num_bins, normed=0, color='red', histtype='step', alpha=0.8, 347 # range=(cut_off_low,cut_off_high), label='tsval diff == 3') 348 #n, bins, patches = plt.hist(ts4_diffs, num_bins, normed=0, color='brown', histtype='step', alpha=0.8, 349 # range=(cut_off_low,cut_off_high), label='tsval diff == 4') 505 350 #n, bins, patches = plt.hist(ts_common_mode, num_bins, normed=0, color='green', histtype='step', alpha=0.8, 506 351 # range=(cut_off_low,cut_off_high), label='tsval common mode') 507 n, bins, patches = plt.hist(ts_common_diff_mode, num_bins, normed=0, color='green', histtype='step', alpha=0.8,508 range=(cut_off_low,cut_off_high), label='tsval common diff mode')352 #n, bins, patches = plt.hist(ts_common_diff_mode, num_bins, normed=0, color='green', histtype='step', alpha=0.8, 353 # range=(cut_off_low,cut_off_high), label='tsval common diff mode') 509 354 plt.xlabel('RTT Difference') 510 plt.ylabel('Probability')511 plt.title(r'Histogram - distribution of differences by tsval')355 #plt.ylabel('Probability') 356 #plt.title(r'Histogram - distribution of differences by tsval') 512 357 513 358 # Tweak spacing to prevent clipping of ylabel … … 520 365 521 366 367 def exampleSummaryHistogram(): 368 num_bins = 300 369 all = db.subseries('train','long')+db.subseries('test','long') 370 diffs = [s['unusual_packet']-s['other_packet'] for s in all] 371 372 diffs.sort() 373 cut_off_low = diffs[int(len(diffs)*0.003)] 374 cut_off_high = diffs[int(len(diffs)*0.997)] 375 376 plt.clf() 377 # the histogram of the data 378 n, bins, patches = plt.hist(diffs, num_bins, normed=0, color='black', histtype='step', alpha=0.8, 379 range=(cut_off_low,cut_off_high), label='all') 380 381 plt.xlabel('RTT Difference') 382 plt.ylabel('Probability') 383 #plt.title(r'Histogram - distribution of differences by tsval') 384 385 w = 25 386 l1,r1,l2,r2,l3,r3 = numpy.percentile(diffs, (50-w,50+w,50-w/2,50+w/2,(50-w)/2,(50+w)/2+50)) 387 #plt.plot([l1, 0], [l1, 0.0001], "k--") 388 #plt.plot([r1, 0], [r1, 0.0001], "k--") 389 from matplotlib.patches import FancyBboxPatch 390 currentAxis = plt.gca() 391 currentAxis.add_patch(FancyBboxPatch((l1, 0), 2500, 5000, boxstyle='square', facecolor="blue", alpha=0.4, edgecolor='none')) 392 currentAxis.add_patch(FancyBboxPatch((r1, 0), 2500, 5000, boxstyle='square', facecolor="blue", alpha=0.4, edgecolor='none')) 393 currentAxis.add_patch(FancyBboxPatch((l2, 0), 2500, 5000, boxstyle='square', facecolor="green", alpha=0.4, edgecolor='none')) 394 currentAxis.add_patch(FancyBboxPatch((r2, 0), 2500, 5000, boxstyle='square', facecolor="green", alpha=0.4, edgecolor='none')) 395 currentAxis.add_patch(FancyBboxPatch((l3, 0), 2500, 5000, boxstyle='square', facecolor="green", alpha=0.4, edgecolor='none')) 396 currentAxis.add_patch(FancyBboxPatch((r3, 0), 2500, 5000, boxstyle='square', facecolor="green", alpha=0.4, edgecolor='none')) 397 currentAxis.add_patch(FancyBboxPatch((50, 0), 2500, 5000, boxstyle='square', facecolor="black", alpha=0.4, edgecolor='none')) 398 currentAxis.add_patch(FancyBboxPatch((numpy.mean((l1,r1,l2,r2)), 0), 2500, 5000, boxstyle='square', facecolor="red", alpha=0.4, edgecolor='none')) 399 #currentAxis.add_patch(FancyBboxPatch((numpy.mean((1000)), 0), 1500, 5000, boxstyle='square', facecolor="black", alpha=0.4, edgecolor='none')) 400 401 # Tweak spacing to prevent clipping of ylabel 402 plt.subplots_adjust(left=0.15) 403 #plt.legend() 404 plt.show() 405 #plt.savefig('paper/graphs/dists-vs-dist-of-diffs2.svg') 406 407 #exampleSummaryHistogram() 522 408 523 409 … … 569 455 570 456 def graphTestResults(): 457 basename = os.path.basename(options.db_file) 458 basename,ext = os.path.splitext(basename) 459 460 chartname = "/home/tim/blindspot/research/timing-analysis/paper/figures/results/%s.svg" % (basename) 461 print(chartname) 462 571 463 plt.clf() 572 464 plt.title("Test Results") … … 586 478 classifiers.append(c[0]) 587 479 480 best_obs = [] 481 best_error = [] 588 482 max_obs = 0 589 483 for classifier in classifiers: 590 484 query=""" 591 SELECT params FROM classifier_results485 SELECT params,num_observations FROM classifier_results 592 486 WHERE trial_type='test' 593 487 AND classifier=:classifier … … 600 494 if row == None: 601 495 query=""" 602 SELECT params FROM classifier_results496 SELECT params,(false_positives+false_negatives)/2 FROM classifier_results 603 497 WHERE trial_type='test' and classifier=:classifier 604 498 ORDER BY (false_positives+false_negatives),num_observations … … 610 504 sys.stderr.write("WARN: couldn't find test results for classifier '%s'.\n" % classifier) 611 505 continue 506 507 best_error.append((row[1], classifier)) 508 else: 509 best_obs.append((row[1], classifier)) 612 510 613 511 best_params = row[0] … … 633 531 color_id = (color_id+1) % len(colors) 634 532 635 plt.legend([l[1] for l in legend], [l[0] for l in legend], scatterpoints=1, fontsize='xx-small') 533 best_obs.sort() 534 best_error.sort() 535 winner = None 536 for bo in best_obs: 537 sys.stdout.write("%d obs / %s" % bo) 538 if winner == None: 539 sys.stdout.write(" (winner)") 540 winner = bo 541 print() 542 543 for be in best_error: 544 sys.stdout.write("%f%% error / %s" % be) 545 if winner == None: 546 sys.stdout.write(" (winner)") 547 winner = be 548 print() 549 550 plt.legend([l[1] for l in legend], [l[0] for l in legend], scatterpoints=1, fontsize='x-small') 636 551 plt.plot([0, max_obs], [5.0, 5.0], "k--") 637 plt.show() 638 552 plt.xlabel('Number of Observations') 553 plt.ylabel('Error Rate') 554 plt.savefig(chartname) 555 #plt.show() 556 639 557 graphTestResults() 640 558 641 559 sys.exit(0) 560 561 short_overtime = [(sample['time_of_day'],sample['short']) for sample in timeSeries(db,'train','short')] 562 long_overtime = [(sample['time_of_day'],sample['long']) for sample in timeSeries(db,'train','long')] 563 diff_overtime = [(sample['time_of_day'],sample['long']-sample['other_cases']) for sample in timeSeries(db,'train','long')] 564 short_overtime.sort() 565 long_overtime.sort() 566 diff_overtime.sort() 642 567 643 568 plt.clf()
Note: See TracChangeset
for help on using the changeset viewer.