機器學習——k鄰近演算法的資料解析
阿新 • • 發佈:2019-01-07
def file2matrix(filename): #????? fr = open(filename) #?????????? arrayOLines = fr.readlines() #?????????? numberofLines = len(arrayOLines) #????numberofLines?????��?????? returnMat = zeros((numberofLines,3)) classLabelVector = [] index = 0 #for??????????????��????? for line in arrayOLines: #??line????????? line = line.strip() #?????????\t??? listFormLine = line.split('\t') #??????? ?????��?????????? returnMat [index,:] = listFormLine[0:3] #??listFormLine???????�՛�??classLabelVector????? ???????int classLabelVector.append(int(listFormLine[-1])) index+=1 #??????????????????????? return returnMat,classLabelVector