Machine learning (6-Logistic Regression)

1、Classification

  • image.png
  • image.png
  • image.png
  • However,
  • image.png

2、Hypothesis Representation

  • image.png
  • Python code:
import numpy as np
def sigmoid(z):
 return 1 / (1 + np.exp(-z))
  • image.png
  • 𝜃 (𝑥) = 𝑃(𝑦 = 1|𝑥; 𝜃)
  • 𝜃 (𝑥) = 0.7,表示有 70%的 几率𝑦为正向类,相应地𝑦为负向类的几率为 1-0.7=0.3

3、Decision Boundary

  • image.png
  • image.png
  • We can use very complex models to adapt to the decision boundary of very complex shapes

4、Cost Function

  • image.png
  • image.png
  • image.png
  • image.png
  • Python code:
import numpy as np
def cost(theta, X, y):
 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)))
 return np.sum(first - second) / (len(X))
  • image.png

5、Simplified Cost Function and Gradient Descent

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

6、Advanced Optimization

  • image.png

7、Multi-class Classification_ One-vs-all

  • image.png
  • image.png
  • image.png
  • image.png
posted @ 2021-06-16 10:23  我在吃大西瓜呢  阅读(48)  评论(0编辑  收藏  举报