-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities.py
More file actions
52 lines (38 loc) · 1.36 KB
/
utilities.py
File metadata and controls
52 lines (38 loc) · 1.36 KB
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
import re
import numpy as np
import keras.backend.tensorflow_backend as tb
class dataProcessing:
def __init__(self,ml):
self.model = ml
def regxProcess(self,data):
regex = r"[\d|\-]{1,}\.[\d]{2}"
matches = re.findall(regex, data, re.MULTILINE)
return matches
def sensorMotionData(self,rawData,typ):
collectData = []
for each in rawData:
collectData.extend(each[typ])
x = [];y = [];z = []
pkg=[]
for each in collectData:
eachAxisData = self.regxProcess(each)
x.append(eachAxisData[0])
y.append(eachAxisData[1])
z.append(eachAxisData[2])
pkg.append([eachAxisData[0],eachAxisData[1],eachAxisData[2]])
ts = np.array([pkg])
tb._SYMBOLIC_SCOPE.value = True
ind = np.argmax(self.model.predict(ts))
return [[x,y,z],ind]
def sensorMotionDatForAssist(self,rawData,typ):
collectData = []
for each in rawData:
collectData.extend(each[typ])
pkg=[]
for each in collectData:
eachAxisData = self.regxProcess(each)
pkg.append([eachAxisData[0],eachAxisData[1],eachAxisData[2]])
ts = np.array([pkg])
tb._SYMBOLIC_SCOPE.value = True
ind = np.argmax(self.model.predict(ts))
return ind