diff --git a/docs/8.预测数值型数据:回归.md b/docs/8.预测数值型数据:回归.md index 1e3fe942..2da3904d 100644 --- a/docs/8.预测数值型数据:回归.md +++ b/docs/8.预测数值型数据:回归.md @@ -3,7 +3,7 @@ ![预测数值型数据回归首页](../images/8.Regression/预测数值型数据回归首页.png "回归Regression首页") -## 回归(Regression) 概述 +## 回归(Regressiovn) 概述 `我们前边提到的分类的目标变量是标称型数据,而回归则是对连续型的数据做出处理,回归的目的是预测数值型数据的目标值。` @@ -608,7 +608,7 @@ def regression4(): #### 4.4、小结 -当应用缩减方法(如逐步线性回归或岭回归)时,模型也就增加了偏差(bias),与此同时却见笑了模型的方差。 +当应用缩减方法(如逐步线性回归或岭回归)时,模型也就增加了偏差(bias),与此同时却减小了模型的方差。 ### 5、回归 项目案例 diff --git a/src/python/8.PredictiveNumericalDataRegression/regression.py b/src/python/8.PredictiveNumericalDataRegression/regression.py index 11ea93be..1f865e47 100644 --- a/src/python/8.PredictiveNumericalDataRegression/regression.py +++ b/src/python/8.PredictiveNumericalDataRegression/regression.py @@ -369,6 +369,7 @@ gt56 trainY.append(yArr[indexList[j]]) # python setup.py build # python setup.py install # +''' from numpy import * from bs4 import BeautifulSoup @@ -481,7 +482,7 @@ def crossValidation(xArr,yArr,numVal=10): # 输出构建的模型 print "the best model from Ridge Regression is:\n",unReg print "with constant term: ",-1*sum(multiply(meanX,unReg)) + mean(yMat) - +''' #test for standRegression @@ -491,9 +492,9 @@ def regression1(): yMat = mat(yArr) ws = standRegres(xArr, yArr) fig = plt.figure() - ax = fig.add_subplot(111) #add_subplot(349)函数的参数的意思是,将画布分成3行4列图像画在从左到右从上到下第9块 - ax.scatter(xMat[:, 1].flatten(), yMat.T[:, 0].flatten().A[0]) #scatter 的x是xMat中的第二列,y是yMat的第一列 - xCopy = xMat.copy() + ax = fig.add_subplot(111) # add_subplot(349)函数的参数的意思是,将画布分成3行4列图像画在从左到右从上到下第9块 + ax.scatter([xMat[:, 1].flatten()], [yMat.T[:, 0].flatten().A[0]]) # scatter 的x是xMat中的第二列,y是yMat的第一列 + xCopy = xMat.copy() xCopy.sort(0) yHat = xCopy * ws ax.plot(xCopy[:, 1], yHat) @@ -512,7 +513,7 @@ def regression2(): fig = plt.figure() ax = fig.add_subplot(111) ax.plot(xSort[:,1], yHat[srtInd]) - ax.scatter(xMat[:,1].flatten().A[0], mat(yArr).T.flatten().A[0] , s=2, c='red') + ax.scatter([xMat[:,1].flatten().A[0]], [mat(yArr).T.flatten().A[0]] , s=2, c='red') plt.show() @@ -576,17 +577,17 @@ def regression4(): # predict for lego's price def regression5(): - lgX = [] - lgY = [] + lgX = [] + lgY = [] - setDataCollect(lgX, lgY) - crossValidation(lgX, lgY, 10) + setDataCollect(lgX, lgY) + crossValidation(lgX, lgY, 10) if __name__ == "__main__": - regression1() + # regression1() # regression2() - # abaloneTest() + abaloneTest() # regression3() # regression4() - # regression5() \ No newline at end of file + # regression5()