Logistic Regression :
예측하는 값을 확률적으로 접근
Classification 장점 + Regression 장점
Linear Classification
: Signal is thresholded at zero to produce +-1 output
For binary decisions
➡️

Linear Regression
: Signal itself = output
For predicting real(unbounded) response
➡️

Heart Attack Prediction based on cholesterol level, blood pressure, age, weight, ...
Cannot predict a heart attack with any certainty
Linear Classification에서는
심장마비가 "0.8만큼 일어났다" 는 없고,
심장마비가 "일어났다(1)?" 또는 "일어나지 않았다(0)?"로만 관찰하게 된다.
하지만 Logistic Regression은 심장마비가 얼마나 일어날 것인지([0, 1])를 예측할 수 있다.
즉, hard classification이 아니라 soft label(probability)을 갖는다.
heart attack or not, dead or alive ➡️ Linear Classification
Returns soft labels(probability) ➡️ Logistic Regression
Output : real(like regression) but bounded(like classification)
Comparison : Linear Regression vs Logistic Regression
probability of default : 어떤 사람이 채무 불이행을 했냐? 안했냐?에 대한 확률
두 개의 class를 분류하기 위해서는 구분이 잘 되는 feature를 사용하여 구분해야 한다.

Balance(통장잔고)라는 feature를 사용해야 분류가 잘 될 것이다.Balance가 주어졌을 때, 그 사람이 채무불이행을 했을 확률P[defualt = yes|balance] : probability of default given balance
특정 사람의 Balance 정보가 주어졌을 때, 그 사람이 채무 불이행을 했을 확률을 구해보자.

Linear Classification : Hard Threshold on
Linear Regression : No Threshold
Logistic Regression : Output to probability range [0, 1]
, called logistic function == sigmoid function



Prediction of heart attacks
Linear ClassificationLinear RegressionLogistic Regression


actual data는 "심장마비가 일어났다(+1)" 또는 "일어나지 않았다(-1)"라는ideal data(model) 을 활용하는 것.We will use cross-entropy error measure

Standard error measure in logistic regression : based on likelihood

➡️ data 하나하나마다 likelihood 정의.
N개 data가 있으니까, N개의 Likelihood 정의
주어진 data를 모두 올바르게 분류하는 Probability를 계산해볼 것이다.
N명이라는 사람이 있다고 가정하면, 각 사람에 대한 Likelihood는 다음과 같다.


Consider two pmfs , with binary outcomes
Cross entropy for these two pmfs : defined by
Let.
Observed == True Distribution :
Fitted == Predicted Distribution :
서로 다른 두 분포에 대한 불확실성.
Cross Entropy를 줄여야 가 분포에 가까워짐

Negative log-likelihood(NLL)


Iterative Optimization (e.g. Gradient Descent)General technique for minimizing twice-differentiable function (2번 미분 가능한 함수에 적용)

Weight Update할 때, Two things to decide :


Batch gradient descent
: Use all examples in each interation
Stochastic gradient descent
: Use 1 example in each iteration
Mini-batch gradient descent
: Use examples in each iteration ( : mini-batch size (typically 2~100))