forked from hcilabusf/language_learning_app_hci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrediction.py
32 lines (28 loc) · 1.05 KB
/
Prediction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
A class that saves the prediction received from Matlab PC
"""
class Prediction:
time = 0 # system's time in milliseconds
pred = "" # h (hard) or e (easy)
predClassOne = 0.0 #high cog workload
predClassTwo = 0.0 #low cog workload
trueClass = "" # represents the current trial
""" Constructor """
def __init__(self, pred, classOne, classTwo):
self.pred = pred
self.predClassOne = classOne
self.predClassTwo = classTwo
def parseString(string):
'''Parses string and uses Dr. Beste\'s alogrithm to see which prediction is sent'''
try:
preds = string.split(";")
if len(preds) == 3:
predClassOne = float(preds[1])
predClassTwo = float(preds[2])
if (preds[0] == "h" and predClassOne > 50) or (preds[0] == "e" and predClassTwo > 50):
return Prediction(preds[0], predClassOne, predClassTwo)
else:
return Prediction(preds[0], predClassTwo, predClassOne)
except Exception as e:
print(e)
return None