본문 바로가기

CS229: Machine Learning

Lecture 4 - Exponential Family & GLM

https://youtu.be/goDDnBbJQ4g?feature=shared


Exponential Family

 

아이디어는 확률 변수가 어떤 확률 분포를 따른다고 할 때, 여러 확률 분포를 우리는 일반화할 수 있을 것이다. 그래서 여러 가지 이점을 얻을 수 있는데, 우리가 사용할 일반화는 바로 Exponential Family이다. 지수족은 다음과 같은 PMF 또는 PDF 식을 가진 확률 분포들의 일반화이다.

 

 $P\left(y; \theta\right) = h\left(x\right)\exp\left[\eta\left(\theta\right)\times T\left(x\right) - A\left(\theta\right)\right]$

 

이런 형태를 가진 식은 많은데, 하나만 들자면 n개 중에 y번 성공할 확률을 보여주는 베르누이 분포이다. 베르누이 분포는 다음과 같은 과정으로 지수족 형태로 표현 가능하다.

 

$P\left(y; \theta\right) = \phi^{y}(1-\phi)^{1-y} = \exp\left(y\log{\phi} + (1-y)\log{\left(1 - \phi\right)}\right) = \exp\left(y\log{\frac{\phi}{1 - \phi}} + \log{\left(1 - \phi\right)}\right)$

 

그리고 지수족의 각 함수는 다음과 같다.

 

$h\left(x\right) = 1, T\left(y\right) = y, \eta = \log{\frac{\phi}{1 - \phi}}, A\left(\theta \right) = -\log\left(1 - \theta\right)$

 

그래서 지수족을 왜 사용하는가?

 

1. 평균과 분산을 계산하기 쉽다.

 

지수족의 평균과 분산은 다음과 같이 계산할 수 있다.

 

$E\left[y;\theta\right] = \frac{\partial}{\partial \theta}A(\theta), Var\left[y;\theta\right] = \frac{\partial^{2}}{\partial^{2}\theta}A(\theta)$

 

2. 지수족의 구조 때문에 최대우도법의 계산이 쉬워진다.

 

$\theta$에 대해서 MLE은 concave하기 때문이다.

 

Generalized Linear Model

 

Generalized Linear Model이란, 정규 분포로 한정된 선형 모델을 지수족의 분포로 일반화한 것이다. GLM은 다음과 같은 조건을 가진다.

 

  1. $y | x; \theta \sim ExponentialFamily$
  2. $\eta = \theta^{T}x$
  3. $E\left[y | x;\theta\right] = \eta$

Multiple Classification Using GLM

 

클래스: $y \in \left\{1, 2, \cdots, n \right\}$

확률 분포: $P\left(y = k | x\right) = \frac{\exp{\left(\theta_{k}x\right)}}{\sum_{i=1}^{n}{\exp\left(\theta_{i}x\right)}}$

손실 함수: $-\sum_{i=1}^{k}P\left(y = k | x\right)\log{\hat{p}} = -\log\left(\hat{p}\left(y_i\right)\right)$ 

 

 

'CS229: Machine Learning' 카테고리의 다른 글

Lecture 7: Kernel Method  (0) 2025.02.19
Lecture 6: Naive Bayes, Laplace smoothing  (0) 2025.02.18
Lecture 5: GDA  (0) 2025.01.30
CS229: Lecture 3  (0) 2025.01.14
CS229: Supervised Learning - Lecture 2  (0) 2025.01.05