[구름_자연어처리 _4기]logistic regression
logistic regression: 기존의 선형회귀처럼 값을 예측하는 것이 아니라
메일로 치면 spam/ non spam 같은 분류를 위해 사용
Threshold clssifiter output h_theta(x) at 0.5
if h_theta(x) >=0.5, predict y=1
if h_theta(x) <=0.5, predict y=0
Logistic Regression : 0 <= h_theta(x) <= 1
Binary clssfication(이진분류) : 0이나 1 두가지로 분류
스팸/일반메일 양성/음성 남자/여자 등등
Logistic Regression hypothesis
ax+b 라는 모델이 있을 때 range를 원하는 곳([0,1])으로 mapping시키기 위해서
sin같이 범위를 가지는 함수에 넣어줌 -> x가 아무리 작거나 커도 범위를 안넘어가게
h_theta(x) =g(z) ( z = dot( tran.theta , x) )
Sigmoid!
Input feature가 두개인경우 (혹은 이상)
h_theta(x) = g(theta_0 + theta_1 x_1 + theta_2 x_2) 같이 표현
linear decision boundaries
ex) Predict y = 1 if -3+ x_1 + x_2 >=0 -> 어떤 직선 선을 기준으로!
Non-linear decision boundaries
Cost function
h_theta 값이 0.51이 나온다고 가정해보자 (1이면 Class A 이고 0이면 Class B)
이 경우 Class A로 분류가 되겠지만 이걸 1까지 높히고 싶음
그러면 손실함수를 이렇게 쓸 수 있다. 위의 식의 if문을 제거하고 다시 쓰면 아래 식과 같다
Gradient Descent
Want min_theta J(theta)
Cost(a,b)의 a와 b에 대해서 편미분 계산!