大家好,又见面了,我是你们的朋友全栈君。
# -*- coding: utf-8 -*-
import numpy as np
def readData(file,cols):
file=open(file)
lines=file.readlines()
rows=len(lines)
datamat = np.zeros((rows,cols))
row=0
for line in lines:
line=line.strip().split('\t')
datamat[row,:]=line[::]
row+=1
return datamat
#data = readData("data_train.txt",13)
#data = readData("data_test.txt",13)
#data = readData("data_train_labels.txt",2)
data = readData("data_test_labels.txt",2)
print(data)
print(data.shape)
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/129404.html原文链接:https://javaforall.cn