MCPcopy Index your code
hub / github.com/apachecn/ailearning / loadDataSet

Function loadDataSet

src/python/10.kmeans/kMeans.py:14–21  ·  view source on GitHub ↗
(fileName)

Source from the content-addressed store, hash-verified

12
13# 从文本中构建矩阵,加载文本文件,然后处理
14def loadDataSet(fileName): # 通用函数,用来解析以 tab 键分隔的 floats(浮点数)
15 dataMat = []
16 fr = open(fileName)
17 for line in fr.readlines():
18 curLine = line.strip().split('\t')
19 fltLine = map(float,curLine) # 映射所有的元素为 float(浮点数)类型
20 dataMat.append(fltLine)
21 return dataMat
22
23
24# 计算两个向量的欧式距离(可根据场景选择)

Callers 3

testBasicFuncFunction · 0.70
testKMeansFunction · 0.70
testBiKMeansFunction · 0.70

Calls 1

mapFunction · 0.85

Tested by

no test coverage detected