Ejemplo n.º 1
0
def testing_4():
    global clfback, clfarm, clfleg
    trial_list = p.TrialList()
    data = trial_list.readFile('test.txt')
    test_back = (f.Features(data, 'k')).feature
    test_leg = (f.Features(data, 'g')).feature
    test_arm = (f.Features(data, 'm')).feature
    res1 = clfback.test(test_back, 5)
    res2 = clfleg.test(test_leg, 5)
    res3 = clfarm.test(test_arm, 5)
    s = 0
    #s = 'back: ' + str(res1) + '	leg: '+ str(res2)+ '	arm: '+str(res3) + '\n'
    if res1 < -0.5:
        #s += "You're hunching your back.\n"
        s += 4
    if res2 < -0.5:
        #s += "You're crossing your leg.\n"
        s += 1
    if res3 < -0.5:
        #s += "Your arms are too close to your body.\n"
        s += 2
    if res1 > -0.5 and res2 > -0.5 and res3 > -0.5:
        #s += "You have perfect posture!\n"
        s = 0
    return s
Ejemplo n.º 2
0
def getTrainingData():
    l = p.trial_list.getTrials()
    for x in l:
        features = f.Features(x)
        data.append(features.feature)
        if x.head.target == 'good':
            label.append(1)
        else:
            label.append(0)
Ejemplo n.º 3
0
def setupClassifier(path):
	l = p.getTrialList(path)
	for x in l:
		features = f.Features(x)
		data.append(features.feature)
		if x.head.target == 'good':
			label.append(1)
		else:
			label.append(0)
Ejemplo n.º 4
0
def getTestingData(path):
	l = p.getTrialList(path)
	for x in l:
		features = f.Features(x, path[-2])
		data_test.append(features.feature)
		if x.head.target == 'good':
			label_test.append(1)
		else:
			label_test.append(0)
	 	print data_test[-1], label_test[-1]
Ejemplo n.º 5
0
def getTrainingData(path):
    l = p.getTrialList(path)
    for x in l:
        features = f.Features(x)
        data.append(features.feature)
        if x.head.target == 'good' or path[-2] != 'k':
            label.append(1)
        else:
            label.append(0)
        print data[-1], label[-1]
Ejemplo n.º 6
0
def testing():
    trial_list = p.TrialList()
    data = trial_list.readFile('test.txt')
    test_data = (f.Features(data)).feature
    res = ''
    #print test_data
    for clf in classifiers:
        #	print clf
        res += clf[0] + ' '
        res += str(clf[1].predict(test_data)[0]) + '\n'
    return res
Ejemplo n.º 7
0
def setupClassifier(path):
    data = []
    label = []
    l = p.getTrialList(path)
    for x in l:
        features = f.Features(x, path[-2])
        data.append(features.feature)
        if x.head.target == 'good':
            label.append(1)
        else:
            label.append(0)
    return knn.knn(data, label)
Ejemplo n.º 8
0
def testing_3():
    global clfback, clfarm, clfleg
    trial_list = p.TrialList()
    data = trial_list.readFile('test.txt')
    test_data = (f.Features(data)).feature
    res1 = clfback.test(test_data, 10)
    res2 = clfleg.test(test_data, 10)
    res3 = clfarm.test(test_data, 10)

    print res1, res2, res3
    minres = min(res1, res2, res3)
    if minres < -1.0:
        if minres == res1:
            s = "You're hunching your back.\n"
        elif minres == res2:
            s = "You're crossing your leg.\n"
        else:
            s = "Your arms are too close to your body.\n"
    else:
        s = "You have perfect posture!\n"
    return s
Ejemplo n.º 9
0
def testing_4():
    global clf1, clf2, clf3, clf4
    trial_list = p.TrialList()
    data = trial_list.readFile('test.txt')
    test_data = (f.Features(data)).feature
    res1 = clf1.test(test_data, 10)
    res2 = clf2.test(test_data, 10)
    res3 = clf3.test(test_data, 10)
    res4 = clf4.test(test_data, 10)

    str1, str2, str3 = "", "", ""
    if res1 == 0:
        str1 = "You're hunching your back"
    if res2 + res3 == 1:
        str2 = "You're leaning to the left/right."
    if res4 == 0:
        str3 = "Your arms are too close to your body."

    if res1 + res2 + res3 + res4 == 4:
        return "You have perfect posture!\n-------------------------------------------\n"
    return str1 + "\n" + str2 + "\n" + str3 + "\n-------------------------------------------\n"
Ejemplo n.º 10
0
def testing():
    global classifier1
    trial_list = p.TrialList()
    data = trial_list.readFile('test.txt')
    test_data = (f.Features(data)).feature
    return classifier1.test(test_data, 10)