def loadDataSet(filename): f = open(filename) numFeatures = len(f.readline().split(‘\t‘)) - 1 dataMat = [] labelMat = [] for line in f.readlines(): lineArr=[] curLine=line.strip().split(‘\t‘) for i in range(0,numFeatures): lineArr.append(float(curLine[i])) dataMat.append(lineArr) labelMat.append(float(curLine[-1])) return dataMat,labelMat
原文地址:https://www.cnblogs.com/zhhy236400/p/9923870.html
时间: 2024-10-09 12:37:37