函数说明:绘制岭回归系数矩阵 Website: http://www.cuijiahua.com/ Modify: 2017-11-20
()
| 78 | return wMat |
| 79 | |
| 80 | def plotwMat(): |
| 81 | """ |
| 82 | 函数说明:绘制岭回归系数矩阵 |
| 83 | Website: |
| 84 | http://www.cuijiahua.com/ |
| 85 | Modify: |
| 86 | 2017-11-20 |
| 87 | """ |
| 88 | font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=14) |
| 89 | abX, abY = loadDataSet('abalone.txt') |
| 90 | redgeWeights = ridgeTest(abX, abY) |
| 91 | fig = plt.figure() |
| 92 | ax = fig.add_subplot(111) |
| 93 | ax.plot(redgeWeights) |
| 94 | ax_title_text = ax.set_title(u'log(lambada)与回归系数的关系', FontProperties = font) |
| 95 | ax_xlabel_text = ax.set_xlabel(u'log(lambada)', FontProperties = font) |
| 96 | ax_ylabel_text = ax.set_ylabel(u'回归系数', FontProperties = font) |
| 97 | plt.setp(ax_title_text, size = 20, weight = 'bold', color = 'red') |
| 98 | plt.setp(ax_xlabel_text, size = 10, weight = 'bold', color = 'black') |
| 99 | plt.setp(ax_ylabel_text, size = 10, weight = 'bold', color = 'black') |
| 100 | plt.show() |
| 101 | |
| 102 | |
| 103 | def regularize(xMat, yMat): |
nothing calls this directly
no test coverage detected