Esempio n. 1
0
def compare_across_all_tasks(tasks, subject, position, sessionnum="", sq=""):
    print('For subject ' + str(subject) + ':')
    for i in range(len(tasks)):
        taskX = feature_vector_generator(tasks[i], subject, position, sessionnum, sq)

        def f():
            return
            yield
        g = f()
        for j in range(i):
            # print(tasks[j])
            taskA = feature_vector_generator(tasks[j], subject, position, sessionnum, sq)
            g = chain(g, taskA)
        for k in range(i+1, len(tasks)):
            # print(tasks[k])
            taskB = feature_vector_generator(tasks[k], subject, position, sessionnum, sq)
            g = chain(g, taskB)
        X, y = labeler.vectorsAndLabels([taskX, g])
        comparison = tasks[i] + " vs. others cross-validation is: " + str(labeler.crossValidate(X, y))
        print(comparison)
Esempio n. 2
0
def make_svm_classifier(tasks, subject, position, sessionnum="", sq=""):
    for i in range(len(tasks)):
        print('For subject ' + str(subject) + ', task ' + str(tasks[i]) + ':')
        taskX = feature_vector_generator(tasks[i], subject, position, sessionnum, sq)
        def f():
            return
            yield
        g = f()
        for j in range(i):
            # print(tasks[j])
            taskA = feature_vector_generator(tasks[j], subject, position, sessionnum, sq)
            g = chain(g, taskA)
        for k in range(i+1, len(tasks)):
            # print(tasks[k])
            taskB = feature_vector_generator(tasks[k], subject, position, sessionnum, sq)
            g = chain(g, taskB)
        X, y = labeler.vectorsAndLabels([taskX, g])
        '''Toggle the following for learner function or cross-validation.'''
        # lin_clf = LinearSVC()
        # target = lin_clf.fit(X, y)
        # return target
        comparison = tasks[i] + " vs. others cross-validation is: " + str(labeler.crossValidate(X, y))
        print(comparison)
Esempio n. 3
0
def compare_by_subject(tasks, subjects, position, sessionnum=""):
    for i in range(len(tasks)):
        print('For task ' + tasks[i] + ', position ' + str(position) + ':')
        for j in range(len(subjects)):
            for k in range(j+1, len(subjects)):
                subA = feature_vector_generator(tasks[i], subjects[j], position, sessionnum)
                subB = feature_vector_generator(tasks[i], subjects[k], position, sessionnum)
                X, y = labeler.vectorsAndLabels([subA, subB])
                comparison = 'subject' + str(subjects[j]) + " vs. subject" + str(subjects[k]) + " cross-validation is: " + str(labeler.crossValidate(X, y))
                print(comparison)
Esempio n. 4
0
def compare_by_task(tasks, subject1, position, sessionnum="", sq=""):
    print('For subject ' + str(subject1) + ', position ' + str(position) + ':')
    for i in range(len(tasks)):
        for j in range(i+1, len(tasks)):
            for k in range(j+1, len(tasks)):
                for l in range(k+1, len(tasks)):
                    taskA = feature_vector_generator(tasks[i], subject1, position, sessionnum, sq)
                    taskB = feature_vector_generator(tasks[j], subject1, position, sessionnum, sq)
                    taskC = feature_vector_generator(tasks[k], subject1, position, sessionnum, sq)
                    taskD = feature_vector_generator(tasks[l], subject1, position, sessionnum, sq)
                    X, y = labeler.vectorsAndLabels([taskA, taskB, taskC, taskD])
                    comparison = tasks[i] + " vs. " + tasks[j] + " vs. " + tasks[k] + " vs. " + tasks[l] + " cross-validation is: " + str(labeler.crossValidate(X, y))
                    print(comparison)