1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def loadData(path):
data=list()
with open(path,"r") as fileReader:
lines = fileReader.readlines() # 讀取全部內容
for line in lines:
line = line.strip()
line = line.split("\t")#根據資料間的分隔符切割行資料
data.append(line[:])
data=np.array(data)
data = data.astype(float)
np.random.shuffle(data)
label=data[:,0]
features=data[:,1:]
print("data loaded!")
return features,label-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def loadData(path):
data=list()
with open(path,"r") as fileReader:
lines = fileReader.readlines() # 讀取全部內容
for line in lines:
line = line.strip()
line = line.split("\t")#根據資料間的分隔符切割行資料
data.append(line[:])
data=np.array(data)
data = data.astype(float)
np.random.shuffle(data)
label=data[:,0]
features=data[:,1:]
print("data loaded!")
return features,label-1