Logistic Regression
Logistic Regression
Machine Learning
Classification
Machine Learning
Classification
Malignant ?
(No) 0
Tumor Size Tumor Size
If , predict “y = 1”
If , predict “y = 0”
Classification: y = 0 or 1
Logistic Regression:
Logistic
Regression
Hypothesis
Representation
Machine Learning
Logistic Regression Model
Want
0.5
Sigmoid function 0
Logistic function
Interpretation of Hypothesis Output
Example: If
Decision boundary
Machine Learning
Logistic regression 1
Suppose predict “ “ if
predict “ “ if
Decision Boundary
x2
3
1 2 3 x1
Predict “ “ if
Non-linear decision boundaries
x2
-1 1 x1
-1
Predict “ “ if
x2
x1
Logistic
Regression
Cost function
Machine Learning
Training set:
m examples
Linear regression:
“non-convex” “convex”
Logistic regression cost function
If y = 1
0 1
Logistic regression cost function
If y = 0
0 1
Logistic
Regression
Simplified cost function
and gradient descent
Machine Learning
Logistic regression cost function
Logistic regression cost function
To fit parameters :
Output
Gradient Descent
Want :
Repeat
Want :
Repeat
Advanced
optimization
Machine Learning
Optimization algorithm
Gradient descent:
Repeat
Optimization algorithm
Given , we have code that can compute
-
-
(for )
Machine Learning
Multiclass classification
x2 x2
x1 x1
x2
One-vs-all (one-vs-rest):
x1
x2 x2
x1
x1
x2
Class 1:
Class 2:
Class 3:
x1
One-vs-all