Logistic Regression
1. Problems of Linear Regression When Applied to Classification Problem
1) h(x) may out of range
2) some unusual feature values lead to failure of classification
2. Logistic Regression Model
1 ) h θ ( x ) = g ( θ T x ) = P ( y = 1 ∣ x ; θ ) 1)h_{\theta}(x)=g(\theta^{T}x) = P(y=1| x ; \theta) 1)hθ(x)=g(θTx)=P(y=1∣x;θ)
where g ( z ) = 1 1 + e − z g(z)=\frac{1}{1+e^{-z}} g(z)=1+e−z1 is called Sigmoid Function / Logistic Function
3. Decision Boundary
y=1 → h θ ( x ) > 0.5 h_{\theta}(x)>0.5 hθ(x)>0.5 → θ T x > 0 \theta^{T}x>0 θTx>0
y=0 → h θ ( x ) < 0.5 h_{\theta}(x)<0.5 hθ(x)<0.5 → θ T x < 0 \theta^{T}x<0 θTx<0
decision boundary: h θ ( x ) = 0.5 h_{\theta}(x)=0.5 hθ(x)=0.5 → θ T x = 0 \theta^{T}x=0 θTx=0 (may be nonlinear)
4. Cost Function
C o s t ( h ( x ) , y ) = { − l o g ( h ( x ) ) , y = 1 − l o g ( 1 − h ( x ) ) , y = 0 = − y l o g ( h ( x ) ) − ( 1 − y ) l o g ( 1 − h ( x ) ) Cost(h(x),y)=\begin{cases} -log(h(x)), & y=1\\ -log(1-h(x)), & y=0 \end{cases} =-ylog(h(x))-(1-y)log(1-h(x)) Co