|
3 | 3 |
|
4 | 4 |  |
5 | 5 |
|
6 | | -## 回归(Regressiovn) 概述 |
| 6 | +## 回归(Regression) 概述 |
7 | 7 |
|
8 | 8 | `我们前边提到的分类的目标变量是标称型数据,而回归则是对连续型的数据做出处理,回归的目的是预测数值型数据的目标值。` |
9 | 9 |
|
@@ -169,6 +169,7 @@ def regression1(): |
169 | 169 | ax.plot(xCopy[:, 1], yHat) |
170 | 170 | plt.show() |
171 | 171 | ``` |
| 172 | +[完整代码地址](https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py): <https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py> |
172 | 173 |
|
173 | 174 | ##### 1.5.3、线性回归 拟合效果 |
174 | 175 |
|
@@ -328,6 +329,7 @@ def regression2(): |
328 | 329 | ax.scatter(xMat[:,1].flatten().A[0], mat(yArr).T.flatten().A[0] , s=2, c='red') |
329 | 330 | plt.show() |
330 | 331 | ``` |
| 332 | +[完整代码地址](https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py): <https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py> |
331 | 333 |
|
332 | 334 | ##### 2.2.3、局部加权线性回归 拟合效果 |
333 | 335 |
|
@@ -416,6 +418,7 @@ def abaloneTest(): |
416 | 418 | standyHat = mat(abX[100:199]) * standWs |
417 | 419 | print "standRegress error Size is:", rssError(abY[100:199], standyHat.T.A) |
418 | 420 | ``` |
| 421 | +[完整代码地址](https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py): <https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py> |
419 | 422 |
|
420 | 423 | 根据我们上边的测试,可以看出: |
421 | 424 |
|
@@ -519,6 +522,7 @@ def regression3(): |
519 | 522 | ax.plot(ridgeWeights) |
520 | 523 | plt.show() |
521 | 524 | ``` |
| 525 | +[完整代码地址](https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py): <https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py> |
522 | 526 |
|
523 | 527 | ##### 4.1.2、岭回归在鲍鱼数据集上的运行效果 |
524 | 528 |
|
@@ -599,6 +603,7 @@ def regression4(): |
599 | 603 | weights = standRegres(xMat, yMat.T) |
600 | 604 | print (weights.T) |
601 | 605 | ``` |
| 606 | +[完整代码地址](https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py): <https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py> |
602 | 607 |
|
603 | 608 | ##### 4.3.2、逐步线性回归在鲍鱼数据集上的运行效果 |
604 | 609 |
|
@@ -772,6 +777,8 @@ def regression5(): |
772 | 777 |
|
773 | 778 | > 使用算法:这次练习的目标就是生成数据模型 |
774 | 779 |
|
| 780 | +[完整代码地址](https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py): <https://github.com/apachecn/MachineLearning/blob/master/src/python/8.PredictiveNumericalDataRegression/regression.py> |
| 781 | + |
775 | 782 | ### 6、附加 权衡偏差和方差 |
776 | 783 |
|
777 | 784 | 任何时候,一旦发现模型和测量值之间存在差异,就说出现了误差。当考虑模型中的 “噪声” 或者说误差时,必须考虑其来源。你可能会对复杂的过程进行简化,这将导致在模型和测量值之间出现 “噪声” 或误差,若无法理解数据的真实生成过程,也会导致差异的产生。另外,测量过程本身也可能产生 “噪声” 或者问题。下面我们举一个例子,我们使用 `线性回归` 和 `局部加权线性回归` 处理过一个从文件导入的二维数据。 |
|
0 commit comments