Lecture 4-Logistic-Regression
Lecture 4-Logistic-Regression
Hanaa Bayomi
Updated By: Prof Abeer ElKorany
0.5
CLASSIFICATION
∞ ∞
Logistic Regression
∞ ∞
Logistic Regression
Logistic Regression
Logistic regression with two parameters : X1,
X2 Range from 0-3
Logistic regression Using polynomial function
Logistic regression Using polynomial function
Logistic regression Using polynomial function
Logistic regression Using polynomial function
Logistic Regression
Linear Regression VS Logistic Regression
Linear regression:
Logistic Regression
“non-convex”
“convex”
Local Minima
Logistic cost function
Logistic cost function
Logistic cost function
Logistic cost function
Logistic regression cost function
If y = 1
0 1
Logistic cost function
Logistic regression cost function
If y = 0
0 1
Logistic cost function
Logistic regression cost function
When Y=1
When Y=0
Cost Function
Want :
Repeat
▪ in Logistic Regression
{
m 1
j = j + y
i − xij
1 + e − xi
t
i =1
}
We can now use gradient ascent to maximize j(θ) The update rule will be:
repeat until convergence
DEFINITION
▪ Binary Logistic Regression
•We have a set of feature vectors X with corresponding binary
outputs
T
X = {x1,x2 ,....,xn }
T
Y = { y1, y2 ,...., yn } , where yi {0,1}
pi
log = j xij = xi
1 − pi j
This way we map the probabilities from the [0; 1] range to the
entire number line (real value).
LOGISTIC REGRESSION MODEL
Logistic Regression
Linear Regression
1
1, −x
0.5
t 1+ e
h ( x) = x
t g ( x ) = 0, 1-
1
0.5
1+ e -x
1
p ( y i = 1 | xi , ) =
− t x
1+ e
1
p ( y i = 0 | xi , ) = 1 −
− t x
1+ e
yi 1− yi
1 1
p ( y i | xi : ) = 1 −
− t x − t x
1+ e 1+ e
h ( x) = p( y = 1 | x; )
Logistic
Regression
Multi-class
classification: One-vs-all
Multiclass classification
x2 x2
x1 x1
One-vs-all (one-vs-rest): x2
x1
x2 x2
x1 x1
x2
Class 1:
Class 2:
Class 3:
x1
One-vs-all (one-vs-rest): x2
x1
x2 x2
x1 x1
x2
Class 1:
Class 2:
Class 3:
x1