-
Notifications
You must be signed in to change notification settings - Fork 2
/
plot.py
executable file
·84 lines (58 loc) · 1.44 KB
/
plot.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import numpy as np
from numpy import genfromtxt as gft
import matplotlib.pyplot as plt
import pickle
from sklearn.cluster import KMeans
from sklearn.svm import SVC
import os
file = open("classifier.pkl","rb")
clf = pickle.load(file)
file.close()
data = gft("./Dataset.csv", delimiter = ',')
mydata = data[2:,1:9]
time = []
value1 = []
value2 = []
value3 = []
value4 = []
value5 = []
value6 = []
value7 = []
value8 = []
fig = plt.figure()
for f in range(len(data)):
time.append(f)
value1.append(mydata[f,0])
value2.append(mydata[f,1])
value3.append(mydata[f,2])
value4.append(mydata[f,3])
value5.append(mydata[f,4])
value6.append(mydata[f,5])
value7.append(mydata[f,6])
value8.append(mydata[f,7])
sample = mydata[f].reshape(1,-1)
predicted = clf.predict(sample)
displayText = "Attentive"
if(predicted[0] == 0):
displayText = "Distracted"
if f % 2000 == 0:
os.system("clear")
plt.subplot(3,3,1)
plt.plot(time,value1, color = 'red')
plt.subplot(3,3,2)
plt.plot(time,value2, color = 'green')
plt.subplot(3,3,3)
plt.plot(time,value3, color = 'yellow')
plt.subplot(3,3,4)
plt.plot(time,value4, color = 'blue')
plt.subplot(3,3,5)
plt.plot(time,value5, color = 'cyan')
plt.subplot(3,3,6)
plt.plot(time,value6, color = 'maroon')
plt.subplot(3,3,7)
plt.plot(time,value7, color = 'black')
plt.subplot(3,3,8)
plt.plot(time,value8, color = 'orange')
print(displayText)
plt.draw()
plt.pause(0.0001)