Janto Dreijer avatar Janto Dreijer committed 80461b6

misc fixes

Comments (0)

Files changed (11)

event_recorders.py

 				component_type = self.classifier.best(primitives)
 				# rotation
 				classification_primitives = xml_to_primitives(tools.component_files()[component_type])
-				reflection, rotation, position, _ = recognition.rotation_and_position(symbolA=classification_primitives, symbolB=primitives)
-				components.append(Component(component_type, position=position, rotation=rotation, reflection=reflection))
+				if primitives:
+					reflection, rotation, position, _ = recognition.rotation_and_position(symbolA=classification_primitives, symbolB=primitives)
+					components.append(Component(component_type, position=position, rotation=rotation, reflection=reflection))
 		return sorted(components, key=lambda component: component.type)
 
 	def recognize(self, auto_align=True):
 					except SketchingInterrupt:
 						self.SetStatusText("")
 					except Exception, e:
-						logger.getLogger("StopSketching").error(str(e))
+						logging.getLogger("StopSketching").error(str(e))
 						pass
 				else:
 					if self.auto_clustering:

feature_graphs.py

 		savefig(output % i)
 	show()
 
-def primitive_classifier_features(new_cache=True):
+def primitive_classifier_features(new_cache=False):
 	d = {}
 	for primitive_type, x in zip(Primitive.types, count()):
 		primitives = []
 			#~ print len(points)
 			#~ [x, two_line_segment(points, x)[0] for x in range(2, len(points)-2)]
 			error, x, line1, line2 = min(two_line_segment(points, x) for x in range(2, len(points)-2)) #XXX binary search needed
-			times.append(clock())
+			#~ times.append(clock())
 			bad_quality = line1.bad_quality or line2.bad_quality \
 				or line1.intersection_with(line2).type not in ["V", "L"] \
 				or not (0.2 <= line1.curvature_len() / line2.curvature_len() <= 5)
 	logging.root.setLevel(logging.INFO)
 	logging.basicConfig()
 	#~ System.host = "tablet"
-	#~ primitive_recognition_accuracy()
+	primitive_recognition_accuracy()
 	#~ draw_unrecognised_primitives()
-	#~ save_primitive_examples_size()
-	import profile
-	c = None
-	def f():
-		#~ print c
-		return 1
-	profile.run("f()")
+	save_primitive_examples_size()

reports/classifier_accuracy/CombinedClassifier_accuracy.csv

 ,and,bjt,box,buffer,capacitor,dc-source,diode,inductor,junction,nand,nor,not,or,resistor
-and,92,0,0,0,0,2,0,0,0,0,0,0,6,0,0.92
-bjt,2,94,0,0,0,4,0,0,0,0,0,0,0,0,0.94
-box,0,0,78,0,0,10,9,0,0,0,0,3,0,0,0.78
-buffer,3,0,0,96,0,1,0,0,0,0,0,0,0,0,0.96
-capacitor,0,0,0,0,98,1,0,0,1,0,0,0,0,0,0.98
-dc-source,0,0,1,0,0,96,2,0,0,1,0,0,0,0,0.96
-diode,0,0,18,0,0,4,74,0,0,0,0,4,0,0,0.74
-inductor,0,0,0,0,0,0,0,91,0,0,0,0,0,9,0.91
+and,96,0,0,0,0,0,0,0,0,0,0,0,4,0,0.96
+bjt,0,98,1,0,0,1,0,0,0,0,0,0,0,0,0.98
+box,0,0,87,0,0,5,2,0,0,0,0,6,0,0,0.87
+buffer,7,0,0,91,1,1,0,0,0,0,0,0,0,0,0.91
+capacitor,1,0,0,0,95,1,0,0,3,0,0,0,0,0,0.95
+dc-source,0,0,7,0,1,87,0,0,0,4,0,1,0,0,0.87
+diode,0,0,59,0,0,2,29,0,0,0,0,10,0,0,0.29
+inductor,0,0,0,0,0,0,0,96,0,0,0,0,0,4,0.96
 junction,0,0,0,0,0,0,0,0,100,0,0,0,0,0,1.00
-nand,0,0,0,0,0,0,0,0,0,95,4,1,0,0,0.95
-nor,0,0,0,0,0,1,0,0,0,3,96,0,0,0,0.96
-not,0,0,0,0,0,50,2,0,0,5,0,43,0,0,0.43
+nand,0,0,0,0,0,0,0,0,0,85,9,6,0,0,0.85
+nor,0,0,0,0,0,4,1,0,0,3,92,0,0,0,0.92
+not,0,0,6,0,1,50,1,0,0,7,0,35,0,0,0.35
 or,2,0,0,0,0,0,0,0,0,0,0,0,98,0,0.98
-resistor,0,0,0,0,0,0,0,0,0,0,0,0,0,100,1.00
+resistor,0,0,0,0,0,0,0,15,0,0,0,0,0,85,0.85
 
-0.89 total accuracy (1251 out of 1400 tests)
-0.89 average_class_accuracy
-0.88 geometricmean_class_accuracy
-0.43 min_class_accuracy
-0.74 combined_accuracy number
+0.84 total accuracy (1173 out of 1400 tests)
+0.84 average_class_accuracy
+0.79 geometricmean_class_accuracy
+0.29 min_class_accuracy
+0.63 combined_accuracy number

reports/classifier_accuracy/FeaturesBayesianClassifier(FeatureExtractor,diagonal_gaussian_estimate)_accuracy.csv

 ,and,bjt,box,buffer,capacitor,dc-source,diode,inductor,junction,nand,nor,not,or,resistor
-and,8,0,3,7,17,1,9,0,0,17,0,36,2,0,0.08
-bjt,0,100,0,0,0,0,0,0,0,0,0,0,0,0,1.00
-box,1,0,76,14,0,3,6,0,0,0,0,0,0,0,0.76
-buffer,0,0,4,70,10,4,7,0,0,1,0,4,0,0,0.70
-capacitor,3,0,0,15,73,0,0,0,6,1,0,2,0,0,0.73
-dc-source,0,0,0,4,5,79,1,0,0,11,0,0,0,0,0.79
-diode,3,0,21,12,1,3,60,0,0,0,0,0,0,0,0.60
-inductor,0,0,0,0,0,0,0,100,0,0,0,0,0,0,1.00
-junction,0,0,0,0,28,0,0,0,72,0,0,0,0,0,0.72
-nand,6,0,3,5,2,1,3,0,0,67,0,7,6,0,0.67
-nor,7,0,3,0,1,1,0,0,0,6,65,0,17,0,0.65
-not,4,0,2,29,0,15,4,0,0,3,0,42,1,0,0.42
-or,6,0,0,5,4,0,0,0,1,18,23,3,40,0,0.40
-resistor,0,0,0,0,0,0,0,2,0,0,0,0,0,98,0.98
+and,34,0,3,0,8,0,1,0,0,5,1,46,2,0,0.34
+bjt,0,82,10,0,0,0,7,0,0,1,0,0,0,0,0.82
+box,0,1,73,2,0,0,1,0,0,0,0,23,0,0,0.73
+buffer,3,0,0,82,2,0,1,0,0,0,0,12,0,0,0.82
+capacitor,18,0,0,9,67,2,0,0,2,0,0,2,0,0,0.67
+dc-source,0,0,3,2,11,61,0,0,0,2,0,21,0,0,0.61
+diode,3,1,12,7,1,0,39,0,0,0,0,37,0,0,0.39
+inductor,0,0,0,0,0,0,0,98,0,0,0,0,0,2,0.98
+junction,0,0,0,0,41,0,0,0,58,0,0,0,1,0,0.58
+nand,16,0,4,1,1,2,0,0,0,33,3,22,18,0,0.33
+nor,6,0,0,0,3,0,1,0,0,6,74,3,7,0,0.74
+not,2,0,5,32,2,5,2,0,0,1,0,50,1,0,0.50
+or,14,0,0,0,9,2,0,0,3,1,6,2,63,0,0.63
+resistor,0,0,0,0,0,0,0,14,0,0,0,0,0,86,0.86
 
-0.68 total accuracy (950 out of 1400 tests)
-0.68 average_class_accuracy
-0.60 geometricmean_class_accuracy
-0.08 min_class_accuracy
-0.41 combined_accuracy number
+0.64 total accuracy (899 out of 1400 tests)
+0.64 average_class_accuracy
+0.61 geometricmean_class_accuracy
+0.33 min_class_accuracy
+0.54 combined_accuracy number

reports/classifier_accuracy/FeaturesBayesianClassifier(FeatureExtractor,probalistic_discrete_estimate)_accuracy.csv

 ,and,bjt,box,buffer,capacitor,dc-source,diode,inductor,junction,nand,nor,not,or,resistor
-and,93,0,4,3,0,0,0,0,0,0,0,0,0,0,0.93
-bjt,0,99,0,0,0,0,0,0,1,0,0,0,0,0,0.99
-box,0,0,97,0,0,0,3,0,0,0,0,0,0,0,0.97
-buffer,0,0,0,99,0,0,0,0,1,0,0,0,0,0,0.99
-capacitor,0,0,0,0,100,0,0,0,0,0,0,0,0,0,1.00
-dc-source,0,0,0,0,0,100,0,0,0,0,0,0,0,0,1.00
-diode,0,0,33,0,0,0,67,0,0,0,0,0,0,0,0.67
-inductor,0,0,0,0,0,0,0,100,0,0,0,0,0,0,1.00
-junction,0,0,0,0,0,0,0,0,100,0,0,0,0,0,1.00
-nand,0,0,3,0,2,7,4,0,0,75,0,9,0,0,0.75
-nor,0,0,1,1,0,9,3,0,4,11,69,1,1,0,0.69
-not,0,0,0,0,0,53,0,0,0,0,0,47,0,0,0.47
-or,9,0,0,0,0,1,1,0,0,0,0,5,84,0,0.84
-resistor,0,0,0,0,0,0,0,3,0,0,0,0,0,97,0.97
+and,94,0,0,1,0,0,0,0,0,0,0,0,5,0,0.94
+bjt,0,92,0,0,0,2,1,0,4,1,0,0,0,0,0.92
+box,0,0,90,0,0,6,2,0,0,0,0,2,0,0,0.90
+buffer,4,0,0,92,1,1,0,0,1,1,0,0,0,0,0.92
+capacitor,0,0,0,0,95,0,0,2,2,0,0,0,0,1,0.95
+dc-source,0,0,4,0,0,92,1,0,0,2,1,0,0,0,0.92
+diode,0,0,23,0,0,4,65,0,0,0,1,7,0,0,0.65
+inductor,0,0,0,0,0,0,0,98,0,0,0,0,0,2,0.98
+junction,1,0,0,0,0,0,0,0,99,0,0,0,0,0,0.99
+nand,0,0,6,0,0,1,2,0,0,83,4,4,0,0,0.83
+nor,0,0,2,0,0,2,0,0,1,3,92,0,0,0,0.92
+not,0,0,4,0,0,49,2,0,0,6,1,38,0,0,0.38
+or,0,0,0,0,0,0,0,0,0,0,1,0,99,0,0.99
+resistor,0,0,0,0,0,0,0,5,0,0,0,0,0,95,0.95
 
-0.88 total accuracy (1227 out of 1400 tests)
-0.88 average_class_accuracy
-0.86 geometricmean_class_accuracy
-0.47 min_class_accuracy
-0.75 combined_accuracy number
+0.87 total accuracy (1224 out of 1400 tests)
+0.87 average_class_accuracy
+0.85 geometricmean_class_accuracy
+0.38 min_class_accuracy
+0.71 combined_accuracy number

reports/classifier_accuracy/FeaturesBayesianClassifier(SimpleFeatureExtractor,diagonal_gaussian_estimate)_accuracy.csv

 ,and,bjt,box,buffer,capacitor,dc-source,diode,inductor,junction,nand,nor,not,or,resistor
-and,1,0,1,5,0,0,4,0,0,0,0,89,0,0,0.01
+and,89,0,0,0,0,1,0,0,0,2,0,0,8,0,0.89
 bjt,0,100,0,0,0,0,0,0,0,0,0,0,0,0,1.00
-box,0,0,51,0,0,0,49,0,0,0,0,0,0,0,0.51
-buffer,0,0,0,100,0,0,0,0,0,0,0,0,0,0,1.00
-capacitor,0,0,0,0,100,0,0,0,0,0,0,0,0,0,1.00
-dc-source,0,0,0,0,0,100,0,0,0,0,0,0,0,0,1.00
-diode,0,0,50,0,0,0,50,0,0,0,0,0,0,0,0.50
-inductor,0,0,0,0,0,0,0,100,0,0,0,0,0,0,1.00
+box,0,0,46,0,0,0,43,0,0,0,0,11,0,0,0.46
+buffer,5,0,0,1,1,2,0,0,0,0,0,91,0,0,0.01
+capacitor,0,0,0,0,95,0,0,0,5,0,0,0,0,0,0.95
+dc-source,0,0,1,0,0,1,6,0,0,0,0,91,1,0,0.01
+diode,0,0,43,0,0,0,45,0,0,1,0,11,0,0,0.45
+inductor,0,0,0,0,0,0,0,99,0,0,0,0,0,1,0.99
 junction,0,0,0,0,0,0,0,0,100,0,0,0,0,0,1.00
-nand,0,0,0,0,0,7,2,0,0,45,43,3,0,0,0.45
-nor,0,0,0,0,0,0,0,0,0,57,43,0,0,0,0.43
-not,0,0,0,0,0,51,0,0,0,0,0,49,0,0,0.49
-or,0,0,0,0,0,0,0,0,0,4,0,17,79,0,0.79
-resistor,0,0,0,0,0,0,0,2,0,0,0,0,0,98,0.98
+nand,1,0,0,0,0,1,0,0,0,78,4,10,6,0,0.78
+nor,1,0,0,0,0,0,0,0,0,5,56,0,38,0,0.56
+not,0,0,5,0,0,1,1,0,0,7,0,85,1,0,0.85
+or,0,0,0,0,0,0,0,0,0,0,6,0,94,0,0.94
+resistor,0,0,0,0,0,0,0,7,0,0,0,0,0,93,0.93
 
-0.73 total accuracy (1016 out of 1400 tests)
-0.73 average_class_accuracy
-0.54 geometricmean_class_accuracy
+0.70 total accuracy (982 out of 1400 tests)
+0.70 average_class_accuracy
+0.42 geometricmean_class_accuracy
 0.01 min_class_accuracy
-0.41 combined_accuracy number
+0.38 combined_accuracy number

reports/classifier_accuracy/FeaturesBayesianClassifier(SimpleFeatureExtractor,probalistic_discrete_estimate)_accuracy.csv

 ,and,bjt,box,buffer,capacitor,dc-source,diode,inductor,junction,nand,nor,not,or,resistor
-and,93,0,2,2,0,0,3,0,0,0,0,0,0,0,0.93
+and,93,0,0,2,0,0,0,0,0,0,0,0,5,0,0.93
 bjt,0,100,0,0,0,0,0,0,0,0,0,0,0,0,1.00
-box,0,0,46,0,0,0,54,0,0,0,0,0,0,0,0.46
+box,0,0,0,0,0,5,91,0,0,1,0,3,0,0,0.00
 buffer,0,0,0,100,0,0,0,0,0,0,0,0,0,0,1.00
 capacitor,0,0,0,0,100,0,0,0,0,0,0,0,0,0,1.00
-dc-source,0,0,0,0,0,100,0,0,0,0,0,0,0,0,1.00
-diode,0,0,44,0,0,0,56,0,0,0,0,0,0,0,0.56
-inductor,0,0,0,0,0,0,0,100,0,0,0,0,0,0,1.00
+dc-source,0,0,0,0,0,87,6,0,0,7,0,0,0,0,0.87
+diode,0,0,0,0,0,4,89,0,0,1,0,6,0,0,0.89
+inductor,0,0,0,0,0,0,1,98,0,0,0,0,0,1,0.98
 junction,0,0,0,0,0,0,0,0,100,0,0,0,0,0,1.00
-nand,2,0,4,0,0,4,2,0,0,86,0,2,0,0,0.86
-nor,0,0,0,2,0,2,1,0,0,13,80,1,1,0,0.80
-not,0,0,0,0,0,56,0,0,0,0,0,44,0,0,0.44
-or,10,0,1,1,0,0,1,0,0,0,0,7,80,0,0.80
-resistor,0,0,0,0,0,0,0,1,0,0,0,0,0,99,0.99
+nand,0,0,0,0,0,0,0,0,0,90,5,5,0,0,0.90
+nor,0,0,0,0,0,0,1,0,0,3,96,0,0,0,0.96
+not,0,0,0,0,0,42,5,0,0,8,0,45,0,0,0.45
+or,4,0,0,0,0,0,0,0,0,0,0,0,96,0,0.96
+resistor,0,0,0,0,0,0,0,11,0,0,0,0,0,89,0.89
 
-0.85 total accuracy (1184 out of 1400 tests)
-0.85 average_class_accuracy
-0.82 geometricmean_class_accuracy
-0.44 min_class_accuracy
-0.71 combined_accuracy number
+0.84 total accuracy (1183 out of 1400 tests)
+0.84 average_class_accuracy
+0.76 geometricmean_class_accuracy
+0.00 min_class_accuracy
+0.48 combined_accuracy number

reports/primitive_accuracy/primitive_accuracy.tablet.txt

-Circle accuracy = 0.94 (83 out of 88)
-Corner accuracy = 0.98 (49 out of 50)
+Circle accuracy = 0.91 (80 out of 88)
+Corner accuracy = 0.96 (48 out of 50)
 Crescent accuracy = 1.00 (37 out of 37)
-Jagged accuracy = 0.95 (21 out of 22)
+Jagged accuracy = 0.91 (20 out of 22)
 Line accuracy = 0.98 (189 out of 192)
-Spiral accuracy = 0.93 (52 out of 56)
+Spiral accuracy = 1.00 (56 out of 56)
 accumulated accuracy = 0.96 (1.00 of goal[0.85])
 	output.write("&%s&$\\bm{total}$\\\\\n" % "&".join(Symbol.types))
 	output.write("\\hline\n")
 	for author in authors:
-		output.write("%s&%s" % (author, "&".join([str(hist.get((symbol_type, author), 0)) for symbol_type in Symbol.types])))
+		output.write("%s&%s" % (author, "&".join([str(hist.get((symbol_type, author)) or "") for symbol_type in Symbol.types])))
 		output.write("&$\\bm{%s}$" % len([symbol for symbol in all_symbols if symbol.author==author]))
 		output.write("\\\\\n")
 	output.write("$\\bm{total}$&$\\bm{%s}$\\\\\n" % "}$&$\\bm{".join([str(sum([hist.get((symbol_type, author), 0) for author in authors])) for symbol_type in Symbol.types]))
 		return len(correct)/len(symbols)
 	output = file("reports/classifier_accuracy/symbol_examples_accuracy.tex", "w")
 	logger.info("writing %s" % output)
-	output.write("&%s&$\\bm{average}$\\\\\n" % "&".join(Symbol.types))
+	output.write("&%s\\\\\n" % "&".join(Symbol.types))
 	output.write("\\hline\n")
 	the_accuracy = {}
 	for author in authors:
 			else:
 				items.append(str(int(100*a))) # round off
 		output.write("%s&%s" % (author, "&".join(items)))
-		output.write("&$\\bm{%s}$" % str(100*int(tools.average(v for v in d.values() if v != ""))))
+		#~ output.write("&$\\bm{%s}$" % str(100*int(tools.average(v for v in d.values() if v != ""))))
 		output.write("\\\\\n")
 	average_symbol_accuracies = []
 	for symbol_type in Symbol.types:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.