[ML] Logistic Regression

김선형·2025년 9월 19일

ML

목록 보기
4/6

Logistic Function (=Sigmoid Function)

입력값을 0과 1 사이의 확률로 변환한다.

y(z)=11+exp(z)y(z)=\frac{1}{1+\exp(-z)}

Logistic Regression

Feature 변환

Logistic Regression에서 Logistic Function의 입력인 zz는 feature x\mathbf{x}의 가중합이다.

z=w1x1+w2x2++wnxn=wTx\mathbf{z}=w_1x_1+w_2x_2+\cdots+w_nx_n=\mathbf{w}^T\mathbf{x}

주어진 데이터를 선형 변환만으로 완벽하게 목적하는 공간으로 매핑하는 것은 어렵기 때문에, 일반적으로 bias를 식에 추가해 사용한다.

z=w0+w1x1+w2x2++wnxn=wTx\mathbf{z}=w_0+w_1x_1+w_2x_2+\cdots+w_nx_n=\mathbf{w}^T\mathbf{x}

분류

Logistic Function을 통해 Feature Vector x\mathbf{x}의 클래스를 판별한다.

y^=11+exp(wTx)\hat{y}=\frac{1}{1+\exp\left(-\mathbf{w}^T\mathbf{x}\right)}

Logistic Function의 출력이 0과 1 사이의 값을 가지기 때문에 y^\hat{y}P(y=1x)P\left(y=1|\mathbf{x}\right)로 생각할 수 있다.

학습

Logistic Regression에서 학습은 Feature를 잘 변환해줄 수 있는 가중치 w\mathbf{w}를 찾는 것이다. 좋은 가중치일수록 음성 클래스의 입력은 0에, 양성 클래스의 입력은 1에 가깝게 예측한다.

Multinomial Logistic Regression (Softmax Regression)

클래스가 3개 이상일 때 사용하는 Logistic Regression의 확장형이다.
Binary Classification에서 Logistic Function을 사용하는 것과 달리, Softmax Function을 사용한다.
KK개의 클래스가 존재할 때 Feature Vector x\mathbf{x}에 대해 클래스 kk일 확률은 아래와 같다.

y^k=exp(wkTx)j=1Kexp(wjTx)\hat{y}_k=\frac{\exp{\left(\mathbf{w}_k^T\mathbf{x}\right)}}{\sum_{j=1}^K{\exp{\left(\mathbf{w}_j^T\mathbf{x}\right)}}}
profile
선형의 비선형적 기록 🐜

0개의 댓글