函数说明:绘制数据集 Parameters: 无 Returns: 无 Website: http://www.cuijiahua.com/ Modify: 2017-11-12
()
| 51 | |
| 52 | |
| 53 | def plotDataSet(): |
| 54 | """ |
| 55 | 函数说明:绘制数据集 |
| 56 | Parameters: |
| 57 | 无 |
| 58 | Returns: |
| 59 | 无 |
| 60 | Website: |
| 61 | http://www.cuijiahua.com/ |
| 62 | Modify: |
| 63 | 2017-11-12 |
| 64 | """ |
| 65 | xArr, yArr = loadDataSet('ex0.txt') #加载数据集 |
| 66 | n = len(xArr) #数据个数 |
| 67 | xcord = []; ycord = [] #样本点 |
| 68 | for i in range(n): |
| 69 | xcord.append(xArr[i][1]); ycord.append(yArr[i]) #样本点 |
| 70 | fig = plt.figure() |
| 71 | ax = fig.add_subplot(111) #添加subplot |
| 72 | ax.scatter(xcord, ycord, s = 20, c = 'blue',alpha = .5) #绘制样本点 |
| 73 | plt.title('DataSet') #绘制title |
| 74 | plt.xlabel('X') |
| 75 | plt.show() |
| 76 | |
| 77 | def plotRegression(): |
| 78 | """ |
nothing calls this directly
no test coverage detected