-
Notifications
You must be signed in to change notification settings - Fork 2
/
Data_load_testdata.py
75 lines (60 loc) · 2.06 KB
/
Data_load_testdata.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
import numpy as np
import os
# 데이터 순서 --> pir , light , temp , humid
def Data_load(exist, X, Y):
current_path = os.getcwd()
classfication = Labeling_tag(exist)
print(classfication)
os.chdir("test_data/" + exist + "/")
typepath = os.getcwd()
os.chdir("PIR/")
for filename in os.listdir("."):
print("filename ::: " + filename)
fdate = filename.split("_")
fpirn = filename
ftempn = ""
flightn = ""
fhumidn = ""
os.chdir(typepath)
os.chdir("TEMP/")
for typelist in os.listdir("."):
filetyname = typelist.split("_")
if filetyname[2:5] == fdate[2:5]:
ftempn = typelist
print(ftempn)
break
os.chdir(typepath)
os.chdir("LIGHT/")
for typelist in os.listdir("."):
filetyname = typelist.split("_")
if filetyname[2:5] == fdate[2:5]:
flightn = typelist
print(flightn)
break
os.chdir(typepath)
os.chdir("HUMID/")
for typelist in os.listdir("."):
filetyname = typelist.split("_")
if filetyname[2:5] == fdate[2:5]:
fhumidn = typelist
print(fhumidn)
break
os.chdir(typepath)
data_pir = np.loadtxt("PIR/" + fpirn, delimiter=",", dtype=np.float32)
data_temp = np.loadtxt("TEMP/" + ftempn, delimiter=",", dtype=np.float32)
data_light = np.loadtxt("LIGHT/" + flightn, delimiter=",", dtype=np.float32)
data_humid = np.loadtxt("HUMID/" + fhumidn, delimiter=",", dtype=np.float32)
for i in range(0, data_pir.__len__()):
X.append(data_pir[i])
X.append(data_light[i])
X.append(data_temp[i])
X.append(data_humid[i])
Y.append(classfication)
os.chdir(current_path)
def Labeling_tag(exist):
if exist == "None":
return [1 , 0]
#elif exist == "Animal":
# return [0, 1, 0]
elif exist == "Human":
return [0 , 1]