MCPcopy Create free account
hub / github.com/Jack-Cherish/Machine-Learning / loadDataSet

Function loadDataSet

Regression/regression_old.py:6–29  ·  view source on GitHub ↗

函数说明:加载数据 Parameters: fileName - 文件名 Returns: xArr - x数据集 yArr - y数据集 Website: http://www.cuijiahua.com/ Modify: 2017-11-12

(fileName)

Source from the content-addressed store, hash-verified

4import numpy as np
5
6def loadDataSet(fileName):
7 """
8 函数说明:加载数据
9 Parameters:
10 fileName - 文件名
11 Returns:
12 xArr - x数据集
13 yArr - y数据集
14 Website:
15 http://www.cuijiahua.com/
16 Modify:
17 2017-11-12
18 """
19 numFeat = len(open(fileName).readline().split('\t')) - 1
20 xArr = []; yArr = []
21 fr = open(fileName)
22 for line in fr.readlines():
23 lineArr =[]
24 curLine = line.strip().split('\t')
25 for i in range(numFeat):
26 lineArr.append(float(curLine[i]))
27 xArr.append(lineArr)
28 yArr.append(float(curLine[-1]))
29 return xArr, yArr
30
31def standRegres(xArr,yArr):
32 """

Callers 3

plotDataSetFunction · 0.70
plotRegressionFunction · 0.70
plotlwlrRegressionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected