Commits

Janto Dreijer  committed 10abcd8

change: snapping not done on small primitives
add: undo button
change: symbol example accuracy report table leaves gaps if no examples for category

  • Participants
  • Parent commits 16a45ea

Comments (0)

Files changed (7)

File fc_interface.py

 		button = wx.Button(item, wx.NewId(), "Capture")
 		self._pnl.AddFoldPanelWindow(item, button)
 		button.Bind(wx.EVT_BUTTON, capture)
+		## undo button
+		button = wx.Button(item, wx.NewId(), "Undo")
+		self._pnl.AddFoldPanelWindow(item, button)
+		button.Bind(wx.EVT_BUTTON, lambda event: self.pen_recorder.undo())
 
 		# commands foldpanel
 		item = self._pnl.AddFoldPanel("Commands", collapsed=False, foldIcons=Images)

File feature_graphs.py

 		savefig(output % i)
 	show()
 
-def primitive_classifier_features(new_cache=False):
+def primitive_classifier_features(new_cache=True):
 	d = {}
 	for primitive_type, x in zip(Primitive.types, count()):
 		primitives = []
 if __name__ == '__main__':
 	logging.root.setLevel(logging.DEBUG)
 	logging.basicConfig()
-	symbol_classifier_features()
-	#~ primitive_classifier_features()
+	#~ symbol_classifier_features()
+	primitive_classifier_features()

File linetools.py

 	return [abs(angle(dp)) for dp in dpos]
 
 def snap_primitive_points(points, snap_points=set()):
+	if Primitive(points).curvature_len() < 40: #XXX magic number
+		# do not snap small primitives
+		return points
 	startpoint, endpoint = points[0], points[-1]
 	# snap endpoints
 	new_startpoint = snap_point(startpoint, snap_points)
 
 @export
 def xml_to_primitives(filename, _primitives_cache={}):
-	Arc = points_to_arc #XXX backwards compat with test data
 	try:
 		try:
 			return copy.copy(_primitives_cache[filename]) # return copy of cached version for safety

File reports/classifier_accuracy/CombinedClassifier_accuracy.csv

 ,and,bjt,box,buffer,capacitor,dc-source,diode,inductor,junction,nand,nor,not,or,resistor
-and,87,0,0,0,0,0,0,0,0,0,0,0,13,0,0.87
-bjt,2,95,0,0,0,2,0,0,0,1,0,0,0,0,0.95
-box,0,0,78,0,0,7,4,0,0,1,0,10,0,0,0.78
-buffer,6,0,0,93,0,1,0,0,0,0,0,0,0,0,0.93
-capacitor,0,0,0,0,99,0,0,0,0,1,0,0,0,0,0.99
-dc-source,0,0,8,0,0,82,1,0,0,8,0,1,0,0,0.82
-diode,0,0,44,0,0,3,37,0,0,2,0,14,0,0,0.37
-inductor,0,0,0,0,0,0,0,100,0,0,0,0,0,0,1.00
+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
 junction,0,0,0,0,0,0,0,0,100,0,0,0,0,0,1.00
-nand,0,0,1,0,0,0,0,0,0,83,8,8,0,0,0.83
-nor,0,0,5,0,0,1,3,0,0,5,86,0,0,0,0.86
-not,0,0,3,0,0,44,1,0,0,15,1,36,0,0,0.36
-or,3,0,0,1,0,0,0,0,0,0,0,0,96,0,0.96
+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
+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
 
-0.84 total accuracy (1172 out of 1400 tests)
-0.84 average_class_accuracy
-0.80 geometricmean_class_accuracy
-0.36 min_class_accuracy
-0.67 combined_accuracy number
+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

File reports/primitive_accuracy/primitive_accuracy.tablet.txt

-Circle accuracy = 0.91 (53 out of 58)
-Corner accuracy = 1.00 (50 out of 50)
+Circle accuracy = 0.94 (83 out of 88)
+Corner accuracy = 0.98 (49 out of 50)
 Crescent accuracy = 1.00 (37 out of 37)
-Jagged accuracy = 0.91 (20 out of 22)
-Line accuracy = 0.96 (90 out of 94)
+Jagged accuracy = 0.95 (21 out of 22)
+Line accuracy = 0.98 (189 out of 192)
 Spiral accuracy = 0.93 (52 out of 56)
-accumulated accuracy = 0.95 (1.00 of goal[0.85])
+accumulated accuracy = 0.96 (1.00 of goal[0.85])
 	data_files = [
 		("components", component_files),
 		("", ["component_properties.xml"]),
-		("", ["primitives_accuracy_graph.janto.pickle", "primitive_classifier.janto.pickle"]),
+		("", ["primitives_accuracy_graph.tablet.pickle", "primitive_classifier.tablet.pickle"]),
 	],
 
 	# targets to build

File test_accuracy.py

 		symbols = [s for s in symbols if s.author==author]
 		correct = [classifier.best(s) for s in symbols]
 		correct = [c for c in correct if c==symbol_type]
-		try:
-			return len(correct)/len(symbols)
-		except ZeroDivisionError:
-			return 0 # no symbols
+		if len(symbols) == 0:
+			return ""
+		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))
 	for author in authors:
 		d = dict([((symbol_type, author), accuracy(symbol_type, author)) for symbol_type in Symbol.types])
 		the_accuracy.update(d)
-		output.write("%s&%s" % (author, "&".join([str(int(100*the_accuracy.get((symbol_type, author), 0))) for symbol_type in Symbol.types])))
-		output.write("&$\\bm{%s}$" % str(100*int(tools.average(d.values()))))
+		items = []
+		for symbol_type in Symbol.types:
+			a = the_accuracy.get((symbol_type, author), "")
+			if a == "":
+				items.append(a)
+			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("\\\\\n")
-	output.write("$\\bm{average}$&$\\bm{%s}$\\\\\n" % "}$&$\\bm{".join([str(int(100*tools.average([the_accuracy.get((symbol_type, author)) for author in authors]))) for symbol_type in Symbol.types]))
+	average_symbol_accuracies = []
+	for symbol_type in Symbol.types:
+		accuracies = filter(lambda a: a != "", [the_accuracy.get((symbol_type, author)) for author in authors])
+		average_symbol_accuracies.append(accuracies and str(int(100*tools.average(accuracies))) or "")
+	output.write("$\\bm{average}$&$\\bm{%s}$\\\\\n" % "}$&$\\bm{".join(average_symbol_accuracies))
 	output.write("\\hline\n")
 	output.close()
 
 if __name__ == '__main__':
 	logging.root.setLevel(logging.INFO)
 	logging.basicConfig()
-	generate_reports()
+	#~ generate_reports()
 	#~ generate_distance_report()
 	symbol_tests_report()