Machine learning (7-Regularization)

Posted 我在吃大西瓜呢

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Machine learning (7-Regularization)相关的知识,希望对你有一定的参考价值。

1、The Problem of Over-fitting

  • image.png
  • image.png
  • image.png
  • image.png
  • image.png

2、Cost Function

  • image.png
  • image.png
  • image.png
  • image.png

3、Regularized Linear Regression

  • image.png
  • image.png

4、Regularized Logistic Regression

  • image.png
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

以上是关于Machine learning (7-Regularization)的主要内容,如果未能解决你的问题,请参考以下文章

Machine Learning In Action

Python Machine Learning

Machine_learning--score

COMPSCI 361 Machine Learning 重点解析

An introduction to machine learning with scikit-learn

Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow ——Chapter 1 Machine Learning Land