其他分享
首页 > 其他分享> > Machine learning (7-Regularization)

Machine learning (7-Regularization)

作者:互联网

1、The Problem of Over-fitting

2、Cost Function

3、Regularized Linear Regression

4、Regularized Logistic Regression

import numpy as np
def costReg(theta, X, y, learningRate):
 theta = np.matrix(theta)
 X = np.matrix(X)
 y = np.matrix(y)
 first = np.multiply(-y, np.log(sigmoid(X*theta.T)))
 second = np.multiply((1 - y), np.log(1 - sigmoid(X*theta.T)))
 reg = (learningRate / (2 * len(X))* np.sum(np.power(theta[:,1:the
ta.shape[1]],2))
 return np.sum(first - second) / (len(X)) + reg

标签:Regularization,matrix,sigmoid,sum,Machine,second,learning,np,theta
来源: https://www.cnblogs.com/wangzheming35/p/14911053.html