Commits

Janto Dreijer committed 16a45ea

change: grey histogram

  • Participants
  • Parent commits 8097fa0

Comments (0)

Files changed (1)

File feature_graphs.py

 def symbol_classifier_features():
 	extractor = FeatureExtractor()
 	defs = SymbolDefinitions()
-	#~ components = sorted(tools.component_files().keys())
+	components = sorted(tools.component_files().keys())
 	intersections = ["T", "X", "L", "V", "y"]
-	#~ fig = figure()
+	fig = figure()
 	components = ["box", "diode", "bjt"]
 	d = {}
 	feature_indices = [0]+[6+Intersection.types.index(t) for t in intersections]
 	for component, x in zip(components, count()):
 		feature_vectors = [extractor.features(symbol) for symbol in defs.training_data(component, size=100)]
 		for i, y in zip(feature_indices, count()):
-			#~ subplot(len(feature_indices), len(components), 1+x+y*len(components))
+			subplot(len(feature_indices), len(components), 1+x+y*len(components))
 			h = [features[i] for features in feature_vectors]
 			d.setdefault(i, {})[component] = h
-			#~ for i in h:
-				#~ assert i < 10, h
-			#~ hist(h, bins=range(10), normed=1)
-			#~ axis(ymax=1.0)
-			#~ if y!=len(feature_indices)-1:
-				#~ xticks([], [])
-			#~ if x!=0:
-				#~ yticks([], [])
+			for i in h:
+				assert i < 10, h
+			n, bins, patches = hist(h, bins=range(10), normed=1)
+			for patch in patches:
+				patch.set_facecolor([0.75]*3) # gray
+				patch.set_edgecolor("k") # black border
+			axis(ymax=1.0)
+			if y!=len(feature_indices)-1:
+				xticks([], [])
+			if x!=0:
+				yticks([], [])
 	#~ print d
-	#~ savefig("reports/bayesian_dimensions.eps")
-	#~ show()
-	draw_d(d, feature_indices, components)
+	savefig("reports/bayesian_dimensions.eps")
+	show()
+	#~ draw_d(d, feature_indices, components, "reports/bayesian_dimensions.eps")
 
 def draw_d(d, feature_indices, types, output):
 	for i, y in zip(feature_indices, count()):
 			ax = fig.add_axes([left, bottom, width, height])
 			axes.append(ax)
 			n, bins, patches = ax.hist(d[i][t], normed=1, bins=7)
+			for patch in patches:
+				patch.set_facecolor([0.75]*3) # gray
+				patch.set_edgecolor("k") # black border
 			axis(ymax=sum(n), xmax=max_v, xmin=min_v)
 			ax.set_yticks([0, sum(n)])
 			ax.set_yticklabels(map(str, [0, 1]))
 			ax = fig.add_axes([left, bottom, width, height])
 			axes.append(ax)
 			n, bins, patches = ax.hist(d[i][t], normed=1, bins=7)
+			for patch in patches:
+				patch.set_facecolor([0.75]*3) # gray
+				patch.set_edgecolor("k") # black border
 			axis(ymax=sum(n), xmax=max_v, xmin=min_v)
 			ax.set_yticks([0, sum(n)])
 			ax.set_yticklabels(map(str, [0, 1]))
 if __name__ == '__main__':
 	logging.root.setLevel(logging.DEBUG)
 	logging.basicConfig()
-	#~ symbol_classifier_features()
-	primitive_classifier_features()
+	symbol_classifier_features()
+	#~ primitive_classifier_features()