예제 #1
0
    def __init__(self,
                 jvid_filename,
                 recording_name,
                 classifier_name=None,
                 save=True,
                 test=False):

        print_status("Trainer", "Starting")

        ### Step 1: get in the original skeletons ###
        self.skeletons_raw = read_in_skeletons(jvid_filename)

        ### Step 2: add derivatives to them (fills skeletons_with_derivs) ###
        self.skeletons_with_derivs = add_derivatives_to_skeletons(
            self.skeletons_raw, self.fd_interval_1, self.fd_interval_2,
            self.fd_interval_1, self.fd_interval_2)

        ### Step 3: put it into training data form ###
        (X, Y) = self.get_training_data()

        ### Step 4: get it in training data form ###
        all_data = zip(X, Y)
        print "	### Number of examples: ", len(all_data)
        random.shuffle(all_data)

        training = all_data
        # training = all_data[:5000]
        # testing = all_data[5000:]
        #--- training ---
        X_train = [t[0] for t in training]
        Y_train = [t[1] for t in training]
        #--- testing ---
        # X_test = [t[0] for t in testing]
        # Y_test = [t[1] for t in testing]

        #--- get the classifier ---
        print_status("Trainer", "Training the classifier")
        self.classifier = LogisticRegression().fit(X_train, Y_train)

        #--- saving data ----
        if save:
            if classifier_name == None:
                classifier_name = recording_name.split('.')[0] + '.obj'
                classifier_name = os.path.join(os.getcwd(),
                                               'python_backend/classifiers',
                                               classifier_name)
            print_status("Trainer",
                         "Pickling the classifier at " + classifier_name)
            self.save_classifier(classifier_name)
예제 #2
0
	def __init__ (self, jvid_filename, recording_name, classifier_name=None, save=True, test=False):

		print_status ("Trainer", "Starting")

		### Step 1: get in the original skeletons ###
		self.skeletons_raw = read_in_skeletons (jvid_filename)

		### Step 2: add derivatives to them (fills skeletons_with_derivs) ###
		self.skeletons_with_derivs = add_derivatives_to_skeletons (self.skeletons_raw, self.fd_interval_1, self.fd_interval_2, self.fd_interval_1, self.fd_interval_2)

		### Step 3: put it into training data form ###
		(X, Y) = self.get_training_data ()

		### Step 4: get it in training data form ###
		all_data = zip(X, Y)
		print "	### Number of examples: ", len(all_data)
		random.shuffle (all_data);

		training = all_data
		# training = all_data[:5000]
		# testing = all_data[5000:]
		#--- training ---
		X_train = [t[0] for t in training]
		Y_train = [t[1] for t in training]
		#--- testing ---
		# X_test = [t[0] for t in testing]
		# Y_test = [t[1] for t in testing]



		#--- get the classifier ---
		print_status ("Trainer", "Training the classifier")
		self.classifier = LogisticRegression().fit(X_train, Y_train)


		#--- saving data ----
		if save:
			if classifier_name == None:
				classifier_name = recording_name.split('.')[0] + '.obj'
				classifier_name = os.path.join (os.getcwd (), 'python_backend/classifiers', classifier_name)
			print_status ("Trainer", "Pickling the classifier at " + classifier_name)
			self.save_classifier (classifier_name)
예제 #3
0
        save = True
    else:
        save = False
    if 'test' in sys.argv:
        test = True
    else:
        test = False

    ### Step 2: read in the skeleton timeseries and add derivatives to them ###
    skeletons = read_in_skeletons(infile_name)
    fd_interval_1 = 5
    fd_interval_2 = 10
    sd_interval_1 = 5
    sd_interval_2 = 10
    skeletons = add_derivatives_to_skeletons(skeletons, fd_interval_1,
                                             fd_interval_2, sd_interval_1,
                                             sd_interval_2)

    ### Step 3: put it into training data form ###
    (X, Y) = get_training_data(skeletons)

    ### Step 4: get it in training data form ###
    all_data = zip(X, Y)
    print "	### Number of examples: ", len(all_data)
    random.shuffle(all_data)

    training = all_data
    # training = all_data[:5000]
    # testing = all_data[5000:]
    #--- training ---
    X_train = [t[0] for t in training]
예제 #4
0
		save = True
	else:
		save = False
	if 'test' in sys.argv:
		test = True
	else:
		test = False


	### Step 2: read in the skeleton timeseries and add derivatives to them ###
	skeletons = read_in_skeletons (infile_name)
	fd_interval_1 = 5
	fd_interval_2 = 10
	sd_interval_1 = 5
	sd_interval_2 = 10
	skeletons = add_derivatives_to_skeletons (skeletons, fd_interval_1, fd_interval_2, sd_interval_1, sd_interval_2)

	### Step 3: put it into training data form ###
	(X, Y) = get_training_data (skeletons)

	### Step 4: get it in training data form ###
	all_data = zip(X, Y)
	print "	### Number of examples: ", len(all_data)
	random.shuffle (all_data);

	training = all_data
	# training = all_data[:5000]
	# testing = all_data[5000:]
	#--- training ---
	X_train = [t[0] for t in training]
	Y_train = [t[1] for t in training]