示例#1
0
def get_sampen(arr, i):
    sampen = []

    for data in arr:
        sampen.append(data[i])


    return sampen2(normalize_data(sampen))
def sampEntropy(rawEMGSignal):
    """
    Parameters
    ----------
    rawEMGSignal : ndarray
        an epoch of raw emg-signal

    Returns
    -------
    feature_value : float
        sample entropy calculated from the rawEMGSignal for the parameters m = 2 and r = 0.2 * std

    """
    copy_rawEMGSignal = copy.copy(rawEMGSignal)  # shallow copy
    copy_feature = sampen2(normalize_data(list(copy_rawEMGSignal)))[2][1]
    if copy_feature is None:
        feature_value = 0
    else:
        feature_value = copy_feature

    return feature_value
示例#3
0
testing_folder_names = [
    "jeremie10/", "jeremie11/", "kaan10/", "kaan11/", "ariel7/", "ariel9/",
    "ariel12/", "ariel13/", "ariel14/"
]
train_test_folder_label = [
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 1, 1
]

train_data = collect_data(training_folder_names)
test_data = collect_data(testing_folder_names)

print("training model...")

model = svm.SVC(kernel="rbf", C=100, gamma='scale')
model.fit(train_data, train_test_folder_label)

prediction = model.predict(test_data)

print("Prediction: ")
print(prediction)

true_positive, false_positive = get_performance_of_prediction(
    prediction, [0, 0, 0, 0, 1, 1, 1, 1, 1])
print("True positives: " + str(true_positive) + " over 3")
print("False positives: " + str(false_positive))

x = [2, 3, 4, 5, 'NaN', 'NaN']
print(normalize_data(x))
pickle.dump(model, open("svm.p", "wb"))
示例#4
0
 def test_normalize_data(self):
     data = [2.0, 3.0, 4.0]
     normalized_data = normalize_data(data)
     self.assertEqual(ceil(pvariance(normalized_data)), 1.0)
     self.assertEqual(mean(normalized_data), 0.0)
示例#5
0
 def test_normalize_data(self):
     data = [2.0, 3.0, 4.0]
     normalized_data = normalize_data(data)
     self.assertEqual(ceil(pvariance(normalized_data)), 1.0)
     self.assertEqual(mean(normalized_data), 0.0)