Machine learning (6-Logistic Regression)

时间:2023-03-09 09:35:32
Machine learning (6-Logistic Regression)

1、Classification

  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • However,
  • Machine learning (6-Logistic Regression)

2、Hypothesis Representation

  • Machine learning (6-Logistic Regression)
  • Python code:
import numpy as np
def sigmoid(z):
return 1 / (1 + np.exp(-z))
  • Machine learning (6-Logistic Regression)
  • () = ( = 1|; )
  • () = 0.7,表示有 70%的 几率为正向类,相应地为负向类的几率为 1-0.7=0.3

3、Decision Boundary

  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • We can use very complex models to adapt to the decision boundary of very complex shapes

4、Cost Function

  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • 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))
  • Machine learning (6-Logistic Regression)

5、Simplified Cost Function and Gradient Descent

  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)

6、Advanced Optimization

  • Machine learning (6-Logistic Regression)

7、Multi-class Classification_ One-vs-all

  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)
  • Machine learning (6-Logistic Regression)