Exemplo n.º 1
0
def repr_feature_default(layer=4, tsne=False):
	convnet = cPickle.load(open('../models/moving_alg_conv.pkl'))
	sharedset = shared_dataset(load_data(load_sample_expId(0, 'vc'), sliding_step=500), convnet.static_sensor)
	return repr_feature(convnet, sharedset, layer, tsne)
Exemplo n.º 2
0
		
	repr_x_all = []
	for layer in [1,2,4,-1]:
		repr_x, repr_y = repr_feature(convnet, sharedset, layer=layer)
		rf_model_name = "moving_rf_layer%i_%s" % (layer,model_name)
		start_time = timeit.default_timer()
		print "start building %s" % rf_model_name
		model = build_rf([repr_x, repr_y[:,0]], "../models/%s.pkl" % rf_model_name)
		end_time = timeit.default_timer()
		print "%f sec elapsed to build random forest for layer%i" % (end_time-start_time, layer)
	
		#repr_x_all.append(repr_x)
	#repr_x_all = numpy.asarray(repr_x_all)
	#model = build_rf([repr_x_all, repr_y[:,0]], "../models/moving_rf_all_layer_%s" % (model_name))	
	"""
	validset = shared_dataset(load_data(load_sample_expId(0, 'vc'), sliding_step=50), convnet.static_sensor)
	for layer in [1,2,4,-1]:
		print "start extracting features of layer%i" % layer
		repr_x, repr_y = repr_feature(convnet, validset, layer=layer)

		rf_model_name = "moving_rf_layer%i_%s" % (layer,model_name)
		model = cPickle.load(open("../models/%s.pkl" % rf_model_name))
		print "model %s loaded" % rf_model_name

		pred_y = model.predict(repr_x)
		real_y = repr_y[:,0]

		import sklearn.metrics
		print 1-sklearn.metrics.accuracy_score(real_y, pred_y)
		print sklearn.metrics.classification_report(real_y, pred_y)
		print sklearn.metrics.confusion_matrix(real_y, pred_y)