@@ -0,0 +1,1688 @@
+%22%22%22%0A@PRATHAM DESAI%0Alda test file%0A%22%22%22%0Aimport numpy as np%0Afrom sklearn.discriminant_analysis import LinearDiscriminantAnalysis%0A%0A# Given data will be an array with length N containing N tuples of size 2%0A# First entry of each tuple will be the target value, to be appended.%0A# Second entry will be an array of size M x 4 (M = 40)%0A%0A%0Adef create_input_target_np(data):%0A    # may have to change specifications based on input data streamed in%0A%0A    N = len(data)%0A    M = data%5B0%5D%5B1%5D.shape%5B0%5D%0A    targets = np.zeros((N, 1))%0A    inputs = np.zeros((N, M, 4))%0A%0A    for i in range(N):%0A%0A        targets%5Bi%5D = data%5Bi%5D%5B0%5D%0A        inputs%5Bi%5D = data%5Bi%5D%5B1%5D%0A%0A    return inputs, targets%0A%0A%0Adef create_input_target(data):%0A%0A    N = len(data)%0A%0A    targets = %5B%5D%0A    inputs = %5B%5D%0A%0A    for i in range(N):%0A        M = len(data%5Bi%5D%5B1%5D)%0A        for j in range(M):%0A%0A            targets.append(data%5Bi%5D%5B0%5D)%0A            inputs.append(data%5Bi%5D%5B1%5D%5Bj%5D)%0A%0A    return inputs, targets%0A%0A%0Adef lda_train(inputs, targets):%0A    # uses sklearn to fit a model given inputs and targets%0A%0A    classifier = LinearDiscriminantAnalysis(solver='svd')%0A    classifier.fit(inputs, targets)%0A%0A    return classifier%0A%0A%0Adef predict(x, classifier):%0A    # x is an array with 4 features: x = %5Be1, e2, e3, e4%5D%0A%0A    return classifier.predict(%5Bx%5D)%0A%0A%0Adef main():%0A    # Random test%0A    data1 = %5B1, 2, 3, 4%5D%0A%0A    data2 = %5B0, 1, -4, 0%5D%0A%0A    data3 = %5B4, 5, 7, 90%5D%0A%0A    data_with_markers = %5B(1, %5Bdata1, data2%5D), (0, %5Bdata2, data3%5D), (0, %5Bdata3, data2%5D)%5D%0A%0A    inputs, targets = create_input_target(data_with_markers)%0A    print(inputs)%0A    print(targets)%0A%0A    clf = lda_train(inputs, targets)%0A%0A    print(clf.predict((%5B%5B1, 2, 3, 4%5D%5D)))%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

add lda functions for P300 classification; not yet working