goorm 수업 정리/Machine Learning
Logistic Regression
yuuuun
2021. 8. 26. 12:18
반응형
classification task 수행 가능
binary classification, mulit-class classification
Logistic Regression
- 예시
- email: spam? not spam?
- online transaction: Fradudulent? - 카드 lock
- Tumor: Malignant? Benign? - 암 - 양성? 음성?
- $y \in \{ 0, 1\}$ - 0: negative class 1: positive class
- 예측 값이 0.5이상일 경우 1로 예측, 0.5 미만일 경우 0으로 예측
- outlier가 있을 경우 linear regression이 이상하게 되기 때문에 무리가 있음
Logistic Model
- $0 \req h_{\theta} (x) \req 1$ 로 고정시키기 위하여 사용하는 함수: sigmoid function
- sigmoid function: $\frac{1}{1+e^{-\theta ^T x}$
Decision Boundary
- $h \leq 0$
- Linear decision boundaries
- non-linear decision boundaries
Cost Function
- $h_\theta (x^{(1)}) \leq 0.5$: 1
- $h_\theta (x^{(1)}) < 0.5 $ : 0
- logistic regrsesion cost function
- y = 1 ->Cost($h_\theta (x), y) = -log(h_\theta (x)$)
- y = 0 ->Cost($h_\theta (x), y) = -log(1 - h_\theta (x)$)
- --> $-ylog(h_\theta (x)) - (1-y) log(1 - h_\theta (x))$
- $J(\theta) = \frac{1}{m}Cost(h_\theta (x^{(i)}), y^{(i)}) = -\frac{1}{m}[\sum_i y^{(i)} log(h_\theta (x^{(i)}) + (1-y^{(i)})log(1 - h_\theta (x^{(i)}))]$
Gradient Descent in Logistic Regression
- $J(a, b) = -log(\frac{1}{1+e^{-(ax+b)}$
- $\frac{dJ(a,b)}{da} = \frac{-e^{(ax+b)}}{1+e^{-ax+b} \times x$
Multi-class Classification
- target value 값만 True, 나머지를 False로 지정
- softmax 함수로 어느 클래스에 속할지 예측
반응형