Discriminative vs Generative Learning
Discriminative learning : How do I separate the classes
Estimate parameters of decision boundary directly from labeled examples.
→ We can make model p(y∣x) directly by using datasets
Generative learning : What does each class look like
Model the distribution of inputs characteristic of the class
→ Ultimately, we want to find p(y∣x,θ) (If supervised learning)
But, in generative learning, we want to find it by modeling p(x∣y)
and p(y) (p(y) : class prior
)
yargmaxp(y∣x)=yargmaxp(x)p(x∣y)p(y)=yargmaxp(x∣y)p(y) Likelihood for Discriminative learning
L(θ;D)=i=1∏mp(y(i)∣x(i);θ) Likelihood for Generative learning
L(θ;D)=i=1∏mp(x(i),y(i);θ)=i=1∏mp(x(i)∣y(i);θ)p(y(i);θ) 💡
Discriminative learning과 Generative learning의 cost function이 다름을 매우 주의해야 한다.
Gaussian Discriminant Analysis (GDA) : continuous-value case
가우시안 분포와 분별 함수 (선형 분별 분석(LDA), 2차 분별 분석(QDA))
gaussian37's blog

https://gaussian37.github.io/ml-concept-gaussian_discriminant/

Condition for use GDA
x : continuous-valued random variables일 때 GDA 사용가능
It models p(y) and p(x∣y) using Bernoulli and a multivariable Gaussian respectively.
- Class prior : y ~ Bernoulli(ϕ)
p(y)=ϕy(1−ϕ)1−y
- Class-conditional distribution : Multivariable Gaussian
p(x∣y=0)=(2π)d/2∣∑∣1/21exp(−21(x−μo)T∑−1(x−μ0))p(x∣y=1)=(2π)d/2∣∑∣1/21exp(−21(x−μ1)T∑−1(x−μ1))
(Mathematical simplicity때문에 covariance matrix가 동일하다고 가정. Mean만 다름. 즉 평행이동적 관점)

GDA의 목적이 f(y|x) 즉 distribution을 구하고 싶은 것!
→ 즉, 각각의 클래스에 들어갈 확률을 구하고 싶은 것!
Discriminantive learning의 경우는 직접적으로 바로 해당 class에 들어갈 확률을 도출함
→ 반면 generative learning의 경우에는 그렇게 하지 않음
만약 covariance matrix가 서로 다른 경우라면?
It has a quadratic function in x, so the decision boundary is a conic section

GDA vs Logistic Regression
The quantity p(y=1∣x,ϕ,∑,μ0,μ1) can be expressed as a function of x
p(y=1∣x,ϕ,∑,μ0,μ1)=1+exp(−wTx+b)1 → 역은 성립하지 않음
GDA makes a stronger
Assumption : class-conditional density is Gaussian
→ GDA is more data efficient when the modeling assumptions are correct or at least approximately correct
즉, 예상이 맞는다면 데이터가 적어도 잘 먹힘.
Logistic regression makes weaker
assumptions
→ When the data is indeed non-Gaussian, logistic regression will almost always do better than GDA.
→ more robust to deviations from modeling assumptions.
Naive Bayes : discrete-value case
Naive Bayes’ assumes that ∀i=j,xi and xj are conditionally independent
given y
💡
Conditionally independent is different from independent

여기서 x가 n-dimensional이라고 생각해주면 됨. 즉, feature이 총 n개가 있고, 각각의 feature별로 xi가 되는 확률이랑 연관되어있는 것
Parameters
ϕi∣y=1=p(xi=1∣y=1)ϕi∣y=1=p(xi=1∣y=1)ϕy=p(y=1) Log-likelihood
L(ϕy,ϕj∣y=0,ϕj∣y=1)=i=1∏mp(x(i),y(j)) Naive Bayes Classifier
데이터들을 이용해서 πk and θijk 를 추정
ynew=ykargmaxπki∏θijk where xij=xinew Subtlety of Naive Bayes
만약 데이터에 xij가 없으면 θijk가 0이 될 수 있다. (Unseen feature problem)
해결 방법
- Laplace smoothing
- MAP estimate with prior
Laplace Smoothing
적어도 1번 일어나게끔 보정
→ 단순히 1씩 더하는 것이 아니라 prior에 의해서 0이 되지 않게끔 조정하는 것도 가능하다.
Example
어떻게 text를 representation할 것인가

→ Back-of-Words
단, 이렇게 될 경우에는 sequential order가 무시된다는 단점이 존재한다. 단순히 빈도만 고려하므로.
각 단어마다 1개의 dimension으로 취급된다.
어떻게 각 단어의 단어의 class conditional probability를 구할 것인가?
∣V∣ : dictionary의 cardinality
w : 해당 단어