-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframe.py
More file actions
46 lines (33 loc) · 978 Bytes
/
frame.py
File metadata and controls
46 lines (33 loc) · 978 Bytes
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 numpy as np
class Frame:
def __init__(self, file_path):
self.file_path = file_path
self.x = []
self.y = []
def transform(self, input_idx, output_from_idx=0):
file = open(self.file_path, 'r')
c = 0
temp_y = []
while True:
c += 1
line = file.readline()
line_split = line.split(',')
if not line:
break
self.x.append([int(i) for i in line_split[output_from_idx:]])
temp_y.append(int(line_split[input_idx]))
self.y = temp_y
def get_max(self):
max = 0
for i in self.x:
for j in i:
if j > max:
max = j
return max
def normalize(self):
max = self.get_max()
self.x = [[i / max for i in j] for j in self.x]
def get_x(self):
return np.array(self.x)
def get_y(self):
return np.array(self.y)