def ridgeRegres(xMat, yMat, lam=0.2):
xTx = xMat.T*xMat
denom = xTx+np.eye(np.shape(xMat)[1])*lam
if np.linalg.det(denom) == 0.0:
print 'This matrix is singular, cannot do inverse'
return
ws = denom.I*(xMat.T*yMat)
return ws
LinearRegressionTest.py 文件源码
python
阅读 41
收藏 0
点赞 0
评论 0
评论列表
文章目录