SlideShare a Scribd company logo
1 of 24
Probability for Machine learning
MinGuk Kang
July 18, 2018
first287@naver.com
사진: https://medium.com/@startuphackers/building-a-deep-learning-neural-network-startup-7032932e09c 1
1. MLE
2. MAP
3. Naïve Bayes Classifier
4. Logistic Regression
2
Contents
Maximum Likelihood Estimation
3
Contents
4
1. Maximum Likelihood Estimation
1. Likelihood 란?
사진: https://wikidocs.net/9088
동전을 던지는 Bernoulli 시행을 예로 들면,
Probability 𝐩(𝐦 ; 𝒏, 𝒑) 는 시행할 횟수(n)과 성공확률 (p)가 모수(Parameter)로 주어지고, 성공 횟수(m)가
Random Variable일 때, 사건이 일어날 가능성이고,
Likelihood 𝓛(𝒑 |𝒏, 𝒎) 는 성공한 횟수(m)와 시행한 횟수(n)가 모수(Parameter)로 주어지고,
성공할 확률이 Random Variable일 때, 이러한 사건이 일어날 가능성을 일컬는다.
5
1. Maximum Likelihood Estimation
2. Maximum Likelihood Estimation 란?
최대우도추정이란 모수(Parameter)가 미지의 𝜃인 확률분포에서 뽑은 표본(관측치)𝑥들을 바탕으로 𝜃를 추정하는 기법입니다.
여기에서 우도(Likelihood)란 이미 주어진 표본 𝑥들에 비추어 봤을 때 모집단의 모수 𝜃에 대한 추정이 그럴듯한 정도를 가르키는데,
우도 ℒ 𝜃 𝑥 는 𝜃가 전제되었을 때 표본 𝑥가 등장할 확률인 𝑝(𝑥|𝜃)에 비례한다.
https://ratsgo.github.io/statistics/2017/09/23/MLE/
6
1. Maximum Likelihood Estimation
최대우도추정이란 모수(Parameter)가 미지의 𝜃인 확률분포에서 뽑은 표본(관측치)𝑥들을 바탕으로 𝜃를 추정하는 기법입니다.
여기에서 우도(Likelihood)란 이미 주어진 표본 𝑥들에 비추어 봤을 때 모집단의 모수 𝜃에 대한 추정이 그럴듯한 정도를 가르키는데,
우도 ℒ 𝜃 𝑥 는 𝜃가 전제되었을 때 표본 𝑥가 등장할 확률인 𝑝(𝑥|𝜃)에 비례한다.
→ 우도에 관한 식을 세운 후, 미분 또는 Gradient Descent Algorithm을 사용하여 최대 우도를 만드는 Parameter를 찾아준다.
2. Maximum Likelihood Estimation 란?
https://ratsgo.github.io/statistics/2017/09/23/MLE/
7
최대우도추정이란 모수(Parameter)가 미지의 𝜃인 확률분포에서 뽑은 표본(관측치)𝑥들을 바탕으로 𝜃를 추정하는 기법입니다.
여기에서 우도(Likelihood)란 이미 주어진 표본 𝑥들에 비추어 봤을 때 모집단의 모수 𝜃에 대한 추정이 그럴듯한 정도를 가르키는데,
우도 ℒ 𝜃 𝑥 는 𝜃가 전제되었을 때 표본 𝑥가 등장할 확률인 𝑝(𝑥|𝜃)에 비례한다.
→ 우도에 관한 식을 세운 후, 미분 또는 Gradient Descent Algorithm을 사용하여 최대 우도를 만드는 Parameter를 찾아준다.
Equation : 𝜃∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝐿 𝜃
∴
𝜕𝐿 𝜃
𝜕𝜃
= 0 인 𝜃를 찾아주면 𝜃∗
가 된다.
1. Maximum Likelihood Estimation
2. Maximum Likelihood Estimation 란?
https://ratsgo.github.io/statistics/2017/09/23/MLE/
Maximum A Posteriori Estimation
8
Contents
9
2. Maximum A Posteriori Estimation
1. Maximum A Posteriori Estimation 이란?
Bayes’s Theorem 은 다음과 같다.
𝑝 𝑦 𝑥 =
𝑝(𝑥|𝑦) × 𝑝(𝑦)
𝑝(𝑥)
Posterior =
Likelihood × Prior
Normalization Term
10
1. Maximum A Posteriori Estimation 이란?
2. Maximum A Posteriori Estimation
Bayes’s Theorem 은 다음과 같다.
𝑝 𝑦 𝑥 =
𝑝(𝑥|𝑦) × 𝑝(𝑦)
𝑝(𝑥)
Posterior =
Likelihood × Prior
Normalization Term
위의 베이즈 공식을 이용하여 우도를 사후확률로 바꾸어,
사후확률이 최댓값을 가지게 되는 Parameter를 찾는 방법을 MAP라고 한다.
11
2. Maximum A Posteriori Estimation
2. MLE vs MAP
MLE의 경우, 모수(Parameter)를 결정하기 위해 사전정보(Prior)를 사용하지 않는다.
따라서 새로운 정보에 대한 일반화 성능이 좋지 못하다.
MAP의 경우, 모수(Parameter)를 결정하기 위해 사전정보(Prior)를 사용한다.
따라서 새로운 정보에 대한 일반화 성능이 좋지만, 잘못된 사전정보를 사용할 시 MLE보다 나쁜 결과를 얻을 수 도 있다.
Naïve Bayes Classifier
12
Contents
13
3. Naïve Bayes Classifier
1. Naïve Bayes Classifier
총 10개의 Label을 가진 필기체 분류(MNIST) 문제를 해결해야 한다고 생각하면 Function Approximation관점에서 다음과 같이 요약 가능하다.
𝑓∗
= 𝑎𝑟𝑔𝑚𝑖𝑛 𝑓 𝑝(𝑓 𝑋 ≠ 𝑌)
하지만, 적절한 라벨을 찾는다는 관점에서는 아래와 같은 수식으로 요약가능하다.
𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝(𝑌𝑘|𝑋)
14
3. Naïve Bayes Classifier
1. Naïve Bayes Classifier
𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…,9} 𝑝 𝑌𝑘 𝑋
위의 식을 계산하기 위해 Bayes Theorem을 적용하면, 𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝 𝑋 𝑌𝑘 × 𝑝 𝑌𝑘 이다.
MNIST 데이터의 경우 768차원의 데이터이므로, 위의 식은 아래와 같이 정리할 수 있다.
𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝 𝑋1 = 𝑥1, 𝑋2 = 𝑥2, 𝑋3 = 𝑥3, … , 𝑋768 = 𝑥768 𝑌𝑘 × 𝑝 𝑌𝑘
15
3. Naïve Bayes Classifier
1. Naïve Bayes Classifier
𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝 𝑋1 = 𝑥1, 𝑋2 = 𝑥2, 𝑋3 = 𝑥3, … , 𝑋768 = 𝑥768 𝑌𝑘 × 𝑝 𝑌𝑘
위의 식은 Intractable하기에 계산을 편하게 만들어 줄 필요가 있다.
따라서, 비록 정확하지는 않겠지만 순진하게(Naïve) 위 식에 Conditional Independence Assumption를 적용하여 정리하면 다음과 같다.
𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑖=1
768
𝑝(𝑋𝑖|𝑌𝑘) × 𝑝 𝑌𝑘
마지막으로 곱셈항을 더욱 효율적으로 다루기 위해 log를 씌워주면 다음과 같고 이를 Naïve Bayes Classifier라고 한다.
𝑌∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑖=1
768
log(𝑝(𝑋𝑖|𝑌𝑘) × 𝑝 𝑌𝑘 ) ∙∙∙ Naïve Bayes Classifier
Logistic Regression
Contents
16
17
4. Logistic Regression
1. Definition
Sigmoid Function = P(Y|X) =
1
1+𝑒𝑥𝑝−𝑋 이다.
위 함수의 역함수를 취해주면 다음와 같은데, 𝑋 = log(
𝑝(𝑌|𝑋)
1−𝑝(𝑌|𝑋)
)
여기에 𝜃라는 Parameters를 곱해주어 입력 값(X)이 Sigmoid Function에 인가되기 전
평행 이동 및 스케일 조정을 할 수 있게 해주면 다음과 같이 식 전개가 가능한다.
𝜃𝑋 = log
P(Y|X)
1 − P(Y|X)
→ 𝑒𝑥𝑝 𝜃𝑋
=
P(Y|X)
1 − P(Y|X)
→ P(Y|X; 𝜃) =
𝑒𝑥𝑝 𝜃𝑋
1 + 𝑒𝑥𝑝 𝜃𝑋
<Sigmoid 함수 그래프>
Logistic Regression
18
4. Logistic Regression
2. How to find the optimal 𝜽(Maximum Conditional Likelihood Estimation)
P(Y|X; 𝜃) =
𝑒𝑥𝑝 𝜃𝑋
1 + 𝑒𝑥𝑝 𝜃𝑋 ∙∙∙ Equation for Logistic Regression
𝜃∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1
𝑁
𝑝(𝑌𝑖|𝑋𝑖; 𝜃) = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 log 𝑖=1
𝑁
𝑝 𝑌𝑖 𝑋𝑖; 𝜃
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1
𝑁
log(𝑝(𝑌𝑖|𝑋𝑖; 𝜃)) …… eq(1)
생각하기 편하도록 위의 경우가 Binary Classification이라고 가정하면, 아래와 같이 정리할 수 있다.
𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝜇(𝑋𝑖) 𝑌 𝑖(1 − 𝜇(𝑋𝑖))1−𝑌 𝑖
log 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑌𝑖log(𝜇(𝑋𝑖)) + (1 − 𝑌𝑖)log(1 − 𝜇(𝑋𝑖)) = 𝑌𝑖(log(
𝜇(𝑋𝑖)
1−𝜇(𝑋𝑖)
)) + log(1 − 𝜇(𝑋𝑖))
19
4. Logistic Regression
2. How to find the optimal 𝜽(Maximum Conditional Likelihood Estimation)
log 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑌𝑖(log(
𝜇(𝑋𝑖)
1−𝜇(𝑋𝑖)
)) + log(1 − 𝜇(𝑋𝑖)) …… eq(2)
이 때 𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 = 𝜇(𝑋𝑖) =
1
1+𝑒𝑥𝑝−Θ𝑋 𝑖
, 이고 𝑋𝑖Θ = log(
𝑃(𝑌 𝑖|𝑋𝑖)
1−𝑃(𝑌 𝑖|𝑋 𝑖)
) 이므로 위의 eq(2)은 아래와 같이 정리가능하다.
log 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑌𝑖 𝑋𝑖Θ + log(1 − 𝜇(𝑋𝑖)) = 𝑌𝑖 𝑋𝑖Θ − log(1 + 𝑒𝑥𝑝 𝑋𝑖Θ
)
이를 eq(1)에 대입하여 정리하면 최종적으로 다음과 같은 식을 얻을 수 있다.
𝜃∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃
𝑖=1
𝑁
log(𝑝(𝑌𝑖|𝑋𝑖; 𝜃)) = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃
𝑖=1
𝑁
(𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ
)
20
4. Logistic Regression
2. How to find the optimal 𝜽(Maximum Conditional Likelihood Estimation)
𝜃∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃
𝑖=1
𝑁
log(𝑝(𝑌𝑖|𝑋𝑖; 𝜃)) = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃
𝑖=1
𝑁
(𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ
)
최적의 𝜃를 찾기위해 위의 식을 𝜃에 대해 미분한 값이 0이 되도록 방정식을 세우면 다음과 같다.
𝜕 𝑖=1
𝑁
(𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ
)
𝜕Θ
=
𝑖=1
𝑁
(𝑌𝑖 𝑋𝑖 −
𝑒𝑥𝑝 𝑋𝑖Θ
1 + 𝑒𝑥𝑝 𝑋𝑖Θ
) =
𝑖=1
𝑁
(𝑌𝑖 𝑋𝑖 − 𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 ) = 0
하지만 위의 식을 좀더 전개하여, 방정식을 만족하는 𝜃를 분석적으로 구할 수 없으므로 근사방법(Gradient Descent)를 이용하여
최적의 𝜃를 구해주게 된다.
21
4. Logistic Regression
3. Gradient Descent Algorithm
1) Taylor Expansion
𝑓 𝑥 = 𝑛=0
∞ 𝑓 𝑛 (𝑎)
𝑛!
(𝑥 − 𝑎) 𝑛
2) Gradient Descent Algorithm 증명
𝑥 𝑛𝑒𝑤 = 𝑥 𝑜𝑙𝑑 + ℎ𝑢, 𝑤ℎ𝑒𝑟𝑒 ℎ 𝑖𝑠 속도, 𝑢 is 방향 벡터
이라고 할 시, Taylor Expansion을 이용하여 다음과 같이 수식 전개가 가능하다.
𝑓 𝑥1 + ℎ𝑢 =
𝑓(𝑥1) × 1
0!
+
𝑓`
(𝑥1) × ℎ𝑢
1!
+
𝑓``
(𝑥1) × (ℎ𝑢)2
2!
…
≈
𝑓(𝑥1) × 1
0!
+
𝑓`
(𝑥1) × ℎ𝑢
1!
22
4. Logistic Regression
3. Gradient Descent Algorithm
𝑓 𝑥1 + ℎ𝑢 ≈
𝑓(𝑥1)×1
0!
+
𝑓`(𝑥1)×ℎ𝑢
1!
의 오른쪽 첫 항을 왼쪽으로 이항하면 다음과 같다.
𝑓 𝑥1 + ℎ𝑢 − 𝑓(𝑥1) ≈ 𝑓`
(𝑥1) × ℎ𝑢
위의 식의 𝑓 𝑥1 + ℎ𝑢 − 𝑓(𝑥1)를 최소화 하는 𝑢(방향)벡터를 구한다는 말은 𝑓(𝑥)가 볼록함수라고 가정했을 때,
가장 급한 경사(Gradient)를 구한다는 말과 동치이고 수식으로는 아래와 같이 표현할 수 있다.
𝑢∗
= 𝑎𝑟𝑔𝑚𝑖𝑛 𝑢 𝑓 𝑥1 + ℎ𝑢 − 𝑓 𝑥1 = 𝑎𝑟𝑔𝑚𝑖𝑛 𝑢(ℎ𝑓`
𝑥1 𝑢) = −
𝑓` 𝑥1
|𝑓` 𝑥1 |
( 𝑎 ∙ 𝑏 의 최소값이 – | 𝑎 || 𝑏 | 이기에 𝑢∗
= −
𝑓` 𝑥1
|𝑓` 𝑥1 |
이다. )
따라서 Gradient Descent 식 𝑥 𝑛𝑒𝑤 = 𝑥 𝑜𝑙𝑑 + ℎ𝑢은 다음과 같이 정리 가능하다.
𝑥 𝑛𝑒𝑤 = 𝑥 𝑜𝑙𝑑 − ℎ
𝑓`
𝑥1
|𝑓` 𝑥1 |
23
4. Logistic Regression
4. Gradient Descent Algorithm to find optimal 𝜽
앞에서 증명했듯이 슬라이드 20
𝜃∗
= 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1
𝑁
(𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ
) = 𝑎𝑟𝑔𝑚𝑖𝑛 𝜃 𝑖=1
𝑁
(−𝑌𝑖 𝑋𝑖Θ + log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ
) 를 만족한다.
𝜕 𝑖=1
𝑁
(−𝑌 𝑖 𝑋𝑖Θ+log 1+𝑒𝑥𝑝 𝑋 𝑖Θ )
𝜕Θ
= 𝑖=1
𝑁
(−𝑌𝑖 𝑋𝑖 + 𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 )이므로 −𝑌𝑖 𝑋𝑖Θ + log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ
가 볼록 함수라고 했을 시,
Optimal한 Θ를 구하기 위한 Gradient Descent 식은 아래와 같다.
Θ 𝑛𝑒𝑤 = Θ 𝑜𝑙𝑑 − ℎ
𝑖=1
𝑁
−𝑌 𝑖 𝑋𝑖+𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃
𝑖=1
𝑁 −𝑌 𝑖 𝑋𝑖+𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃
= Θ 𝑜𝑙𝑑 + ℎ 𝑖=1
𝑁
(𝑌 𝑖 𝑋𝑖−𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 )
| 𝑖=1
𝑁
(𝑌 𝑖 𝑋𝑖−𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 )|
END
24
Contents

More Related Content

What's hot

08. spectal clustering
08. spectal clustering08. spectal clustering
08. spectal clusteringJeonghun Yoon
 
파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강Woong won Lee
 
가깝고도 먼 Trpo
가깝고도 먼 Trpo가깝고도 먼 Trpo
가깝고도 먼 TrpoWoong won Lee
 
강화학습의 흐름도 Part 1
강화학습의 흐름도 Part 1강화학습의 흐름도 Part 1
강화학습의 흐름도 Part 1Dongmin Lee
 
Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Jeonghun Yoon
 
Association rule mining
Association rule miningAssociation rule mining
Association rule miningJeonghun Yoon
 
Random walk, brownian motion, black scholes equation
Random walk, brownian motion, black scholes equationRandom walk, brownian motion, black scholes equation
Random walk, brownian motion, black scholes equation창호 손
 
0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vectorJeonghun Yoon
 
0124 2 linear_algebra_basic_matrix
0124 2 linear_algebra_basic_matrix0124 2 linear_algebra_basic_matrix
0124 2 linear_algebra_basic_matrixJeonghun Yoon
 
05. k means clustering ( k-means 클러스터링)
05. k means clustering ( k-means 클러스터링)05. k means clustering ( k-means 클러스터링)
05. k means clustering ( k-means 클러스터링)Jeonghun Yoon
 
0131 2 spectral_theorem_eigenvalue
0131 2 spectral_theorem_eigenvalue0131 2 spectral_theorem_eigenvalue
0131 2 spectral_theorem_eigenvalueJeonghun Yoon
 
RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기Woong won Lee
 
0228 2 sample_distribution
0228 2 sample_distribution0228 2 sample_distribution
0228 2 sample_distributionJeonghun Yoon
 

What's hot (20)

08. spectal clustering
08. spectal clustering08. spectal clustering
08. spectal clustering
 
0207 1 gradient
0207 1 gradient0207 1 gradient
0207 1 gradient
 
파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강파이썬과 케라스로 배우는 강화학습 저자특강
파이썬과 케라스로 배우는 강화학습 저자특강
 
Number theory
Number theoryNumber theory
Number theory
 
가깝고도 먼 Trpo
가깝고도 먼 Trpo가깝고도 먼 Trpo
가깝고도 먼 Trpo
 
강화학습의 흐름도 Part 1
강화학습의 흐름도 Part 1강화학습의 흐름도 Part 1
강화학습의 흐름도 Part 1
 
Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)Ensemble Model (Hybrid model)
Ensemble Model (Hybrid model)
 
06. graph mining
06. graph mining06. graph mining
06. graph mining
 
Generative adversarial network
Generative adversarial networkGenerative adversarial network
Generative adversarial network
 
Association rule mining
Association rule miningAssociation rule mining
Association rule mining
 
Random walk, brownian motion, black scholes equation
Random walk, brownian motion, black scholes equationRandom walk, brownian motion, black scholes equation
Random walk, brownian motion, black scholes equation
 
0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector0124 1 linear_algebra_basic_vector
0124 1 linear_algebra_basic_vector
 
0124 2 linear_algebra_basic_matrix
0124 2 linear_algebra_basic_matrix0124 2 linear_algebra_basic_matrix
0124 2 linear_algebra_basic_matrix
 
SVM
SVMSVM
SVM
 
05. k means clustering ( k-means 클러스터링)
05. k means clustering ( k-means 클러스터링)05. k means clustering ( k-means 클러스터링)
05. k means clustering ( k-means 클러스터링)
 
Decision tree
Decision treeDecision tree
Decision tree
 
0131 2 spectral_theorem_eigenvalue
0131 2 spectral_theorem_eigenvalue0131 2 spectral_theorem_eigenvalue
0131 2 spectral_theorem_eigenvalue
 
RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기RLCode와 A3C 쉽고 깊게 이해하기
RLCode와 A3C 쉽고 깊게 이해하기
 
0228 2 sample_distribution
0228 2 sample_distribution0228 2 sample_distribution
0228 2 sample_distribution
 
07. PCA
07. PCA07. PCA
07. PCA
 

Similar to [Probability for machine learning]

Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
02.09 naive bayesian classifier
02.09 naive bayesian classifier02.09 naive bayesian classifier
02.09 naive bayesian classifierDea-hwan Ki
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised LearningSang Jun Lee
 
Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersJinho Lee
 
Control as Inference.pptx
Control as Inference.pptxControl as Inference.pptx
Control as Inference.pptxssuserbd1647
 
Deep learning study 1
Deep learning study 1Deep learning study 1
Deep learning study 1San Kim
 
Gaussian Mixture Model
Gaussian Mixture ModelGaussian Mixture Model
Gaussian Mixture ModelKyeongUkJang
 
Chapter 19 Variational Inference
Chapter 19 Variational InferenceChapter 19 Variational Inference
Chapter 19 Variational InferenceKyeongUkJang
 
선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)AHRA CHO
 
3.neural networks
3.neural networks3.neural networks
3.neural networksHaesun Park
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML희수 박
 
Optimization algorithms in machine learning
Optimization algorithms in machine learningOptimization algorithms in machine learning
Optimization algorithms in machine learningYonsei University
 
2019 ppc answers
2019 ppc answers2019 ppc answers
2019 ppc answers승혁 조
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningSang Jun Lee
 
패턴인식-베이즈결정이론기반 분류기 part1
패턴인식-베이즈결정이론기반 분류기 part1패턴인식-베이즈결정이론기반 분류기 part1
패턴인식-베이즈결정이론기반 분류기 part1jdo
 
패턴 인식 2 classifiers based on bayes decision theory part 1
패턴 인식 2 classifiers based on bayes decision theory part 1패턴 인식 2 classifiers based on bayes decision theory part 1
패턴 인식 2 classifiers based on bayes decision theory part 1jdo
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagationJinSooKim80
 
해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3Haesun Park
 
Probability with MLE, MAP
Probability with MLE, MAPProbability with MLE, MAP
Probability with MLE, MAPJunho Lee
 

Similar to [Probability for machine learning] (20)

Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
02.09 naive bayesian classifier
02.09 naive bayesian classifier02.09 naive bayesian classifier
02.09 naive bayesian classifier
 
Lecture 2: Supervised Learning
Lecture 2: Supervised LearningLecture 2: Supervised Learning
Lecture 2: Supervised Learning
 
Auto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-EncodersAuto-Encoders and Variational Auto-Encoders
Auto-Encoders and Variational Auto-Encoders
 
Vae
VaeVae
Vae
 
Control as Inference.pptx
Control as Inference.pptxControl as Inference.pptx
Control as Inference.pptx
 
Deep learning study 1
Deep learning study 1Deep learning study 1
Deep learning study 1
 
Gaussian Mixture Model
Gaussian Mixture ModelGaussian Mixture Model
Gaussian Mixture Model
 
Chapter 19 Variational Inference
Chapter 19 Variational InferenceChapter 19 Variational Inference
Chapter 19 Variational Inference
 
선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)선형대수 08. 선형 변환 (Linear Transformation)
선형대수 08. 선형 변환 (Linear Transformation)
 
3.neural networks
3.neural networks3.neural networks
3.neural networks
 
Multinomial classification and application of ML
Multinomial classification and application of MLMultinomial classification and application of ML
Multinomial classification and application of ML
 
Optimization algorithms in machine learning
Optimization algorithms in machine learningOptimization algorithms in machine learning
Optimization algorithms in machine learning
 
2019 ppc answers
2019 ppc answers2019 ppc answers
2019 ppc answers
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised Learning
 
패턴인식-베이즈결정이론기반 분류기 part1
패턴인식-베이즈결정이론기반 분류기 part1패턴인식-베이즈결정이론기반 분류기 part1
패턴인식-베이즈결정이론기반 분류기 part1
 
패턴 인식 2 classifiers based on bayes decision theory part 1
패턴 인식 2 classifiers based on bayes decision theory part 1패턴 인식 2 classifiers based on bayes decision theory part 1
패턴 인식 2 classifiers based on bayes decision theory part 1
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagation
 
해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3해커에게 전해들은 머신러닝 #3
해커에게 전해들은 머신러닝 #3
 
Probability with MLE, MAP
Probability with MLE, MAPProbability with MLE, MAP
Probability with MLE, MAP
 

More from 강민국 강민국

More from 강민국 강민국 (10)

PR-190: A Baseline For Detecting Misclassified and Out-of-Distribution Examp...
PR-190: A Baseline For Detecting Misclassified and Out-of-Distribution  Examp...PR-190: A Baseline For Detecting Misclassified and Out-of-Distribution  Examp...
PR-190: A Baseline For Detecting Misclassified and Out-of-Distribution Examp...
 
Deeppermnet
DeeppermnetDeeppermnet
Deeppermnet
 
[Pr12] deep anomaly detection using geometric transformations
[Pr12] deep anomaly detection using geometric transformations[Pr12] deep anomaly detection using geometric transformations
[Pr12] deep anomaly detection using geometric transformations
 
[Pr12] self supervised gan
[Pr12] self supervised gan[Pr12] self supervised gan
[Pr12] self supervised gan
 
Ebgan
EbganEbgan
Ebgan
 
Anomaly detection
Anomaly detectionAnomaly detection
Anomaly detection
 
Deep Feature Consistent VAE
Deep Feature Consistent VAEDeep Feature Consistent VAE
Deep Feature Consistent VAE
 
Deep learning overview
Deep learning overviewDeep learning overview
Deep learning overview
 
Restricted boltzmann machine
Restricted boltzmann machineRestricted boltzmann machine
Restricted boltzmann machine
 
Backpropagation
BackpropagationBackpropagation
Backpropagation
 

[Probability for machine learning]

  • 1. Probability for Machine learning MinGuk Kang July 18, 2018 first287@naver.com 사진: https://medium.com/@startuphackers/building-a-deep-learning-neural-network-startup-7032932e09c 1
  • 2. 1. MLE 2. MAP 3. Naïve Bayes Classifier 4. Logistic Regression 2 Contents
  • 4. 4 1. Maximum Likelihood Estimation 1. Likelihood 란? 사진: https://wikidocs.net/9088 동전을 던지는 Bernoulli 시행을 예로 들면, Probability 𝐩(𝐦 ; 𝒏, 𝒑) 는 시행할 횟수(n)과 성공확률 (p)가 모수(Parameter)로 주어지고, 성공 횟수(m)가 Random Variable일 때, 사건이 일어날 가능성이고, Likelihood 𝓛(𝒑 |𝒏, 𝒎) 는 성공한 횟수(m)와 시행한 횟수(n)가 모수(Parameter)로 주어지고, 성공할 확률이 Random Variable일 때, 이러한 사건이 일어날 가능성을 일컬는다.
  • 5. 5 1. Maximum Likelihood Estimation 2. Maximum Likelihood Estimation 란? 최대우도추정이란 모수(Parameter)가 미지의 𝜃인 확률분포에서 뽑은 표본(관측치)𝑥들을 바탕으로 𝜃를 추정하는 기법입니다. 여기에서 우도(Likelihood)란 이미 주어진 표본 𝑥들에 비추어 봤을 때 모집단의 모수 𝜃에 대한 추정이 그럴듯한 정도를 가르키는데, 우도 ℒ 𝜃 𝑥 는 𝜃가 전제되었을 때 표본 𝑥가 등장할 확률인 𝑝(𝑥|𝜃)에 비례한다. https://ratsgo.github.io/statistics/2017/09/23/MLE/
  • 6. 6 1. Maximum Likelihood Estimation 최대우도추정이란 모수(Parameter)가 미지의 𝜃인 확률분포에서 뽑은 표본(관측치)𝑥들을 바탕으로 𝜃를 추정하는 기법입니다. 여기에서 우도(Likelihood)란 이미 주어진 표본 𝑥들에 비추어 봤을 때 모집단의 모수 𝜃에 대한 추정이 그럴듯한 정도를 가르키는데, 우도 ℒ 𝜃 𝑥 는 𝜃가 전제되었을 때 표본 𝑥가 등장할 확률인 𝑝(𝑥|𝜃)에 비례한다. → 우도에 관한 식을 세운 후, 미분 또는 Gradient Descent Algorithm을 사용하여 최대 우도를 만드는 Parameter를 찾아준다. 2. Maximum Likelihood Estimation 란? https://ratsgo.github.io/statistics/2017/09/23/MLE/
  • 7. 7 최대우도추정이란 모수(Parameter)가 미지의 𝜃인 확률분포에서 뽑은 표본(관측치)𝑥들을 바탕으로 𝜃를 추정하는 기법입니다. 여기에서 우도(Likelihood)란 이미 주어진 표본 𝑥들에 비추어 봤을 때 모집단의 모수 𝜃에 대한 추정이 그럴듯한 정도를 가르키는데, 우도 ℒ 𝜃 𝑥 는 𝜃가 전제되었을 때 표본 𝑥가 등장할 확률인 𝑝(𝑥|𝜃)에 비례한다. → 우도에 관한 식을 세운 후, 미분 또는 Gradient Descent Algorithm을 사용하여 최대 우도를 만드는 Parameter를 찾아준다. Equation : 𝜃∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝐿 𝜃 ∴ 𝜕𝐿 𝜃 𝜕𝜃 = 0 인 𝜃를 찾아주면 𝜃∗ 가 된다. 1. Maximum Likelihood Estimation 2. Maximum Likelihood Estimation 란? https://ratsgo.github.io/statistics/2017/09/23/MLE/
  • 8. Maximum A Posteriori Estimation 8 Contents
  • 9. 9 2. Maximum A Posteriori Estimation 1. Maximum A Posteriori Estimation 이란? Bayes’s Theorem 은 다음과 같다. 𝑝 𝑦 𝑥 = 𝑝(𝑥|𝑦) × 𝑝(𝑦) 𝑝(𝑥) Posterior = Likelihood × Prior Normalization Term
  • 10. 10 1. Maximum A Posteriori Estimation 이란? 2. Maximum A Posteriori Estimation Bayes’s Theorem 은 다음과 같다. 𝑝 𝑦 𝑥 = 𝑝(𝑥|𝑦) × 𝑝(𝑦) 𝑝(𝑥) Posterior = Likelihood × Prior Normalization Term 위의 베이즈 공식을 이용하여 우도를 사후확률로 바꾸어, 사후확률이 최댓값을 가지게 되는 Parameter를 찾는 방법을 MAP라고 한다.
  • 11. 11 2. Maximum A Posteriori Estimation 2. MLE vs MAP MLE의 경우, 모수(Parameter)를 결정하기 위해 사전정보(Prior)를 사용하지 않는다. 따라서 새로운 정보에 대한 일반화 성능이 좋지 못하다. MAP의 경우, 모수(Parameter)를 결정하기 위해 사전정보(Prior)를 사용한다. 따라서 새로운 정보에 대한 일반화 성능이 좋지만, 잘못된 사전정보를 사용할 시 MLE보다 나쁜 결과를 얻을 수 도 있다.
  • 13. 13 3. Naïve Bayes Classifier 1. Naïve Bayes Classifier 총 10개의 Label을 가진 필기체 분류(MNIST) 문제를 해결해야 한다고 생각하면 Function Approximation관점에서 다음과 같이 요약 가능하다. 𝑓∗ = 𝑎𝑟𝑔𝑚𝑖𝑛 𝑓 𝑝(𝑓 𝑋 ≠ 𝑌) 하지만, 적절한 라벨을 찾는다는 관점에서는 아래와 같은 수식으로 요약가능하다. 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝(𝑌𝑘|𝑋)
  • 14. 14 3. Naïve Bayes Classifier 1. Naïve Bayes Classifier 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…,9} 𝑝 𝑌𝑘 𝑋 위의 식을 계산하기 위해 Bayes Theorem을 적용하면, 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝 𝑋 𝑌𝑘 × 𝑝 𝑌𝑘 이다. MNIST 데이터의 경우 768차원의 데이터이므로, 위의 식은 아래와 같이 정리할 수 있다. 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝 𝑋1 = 𝑥1, 𝑋2 = 𝑥2, 𝑋3 = 𝑥3, … , 𝑋768 = 𝑥768 𝑌𝑘 × 𝑝 𝑌𝑘
  • 15. 15 3. Naïve Bayes Classifier 1. Naïve Bayes Classifier 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑝 𝑋1 = 𝑥1, 𝑋2 = 𝑥2, 𝑋3 = 𝑥3, … , 𝑋768 = 𝑥768 𝑌𝑘 × 𝑝 𝑌𝑘 위의 식은 Intractable하기에 계산을 편하게 만들어 줄 필요가 있다. 따라서, 비록 정확하지는 않겠지만 순진하게(Naïve) 위 식에 Conditional Independence Assumption를 적용하여 정리하면 다음과 같다. 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑖=1 768 𝑝(𝑋𝑖|𝑌𝑘) × 𝑝 𝑌𝑘 마지막으로 곱셈항을 더욱 효율적으로 다루기 위해 log를 씌워주면 다음과 같고 이를 Naïve Bayes Classifier라고 한다. 𝑌∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑘∈{0,1,2,…9} 𝑖=1 768 log(𝑝(𝑋𝑖|𝑌𝑘) × 𝑝 𝑌𝑘 ) ∙∙∙ Naïve Bayes Classifier
  • 17. 17 4. Logistic Regression 1. Definition Sigmoid Function = P(Y|X) = 1 1+𝑒𝑥𝑝−𝑋 이다. 위 함수의 역함수를 취해주면 다음와 같은데, 𝑋 = log( 𝑝(𝑌|𝑋) 1−𝑝(𝑌|𝑋) ) 여기에 𝜃라는 Parameters를 곱해주어 입력 값(X)이 Sigmoid Function에 인가되기 전 평행 이동 및 스케일 조정을 할 수 있게 해주면 다음과 같이 식 전개가 가능한다. 𝜃𝑋 = log P(Y|X) 1 − P(Y|X) → 𝑒𝑥𝑝 𝜃𝑋 = P(Y|X) 1 − P(Y|X) → P(Y|X; 𝜃) = 𝑒𝑥𝑝 𝜃𝑋 1 + 𝑒𝑥𝑝 𝜃𝑋 <Sigmoid 함수 그래프> Logistic Regression
  • 18. 18 4. Logistic Regression 2. How to find the optimal 𝜽(Maximum Conditional Likelihood Estimation) P(Y|X; 𝜃) = 𝑒𝑥𝑝 𝜃𝑋 1 + 𝑒𝑥𝑝 𝜃𝑋 ∙∙∙ Equation for Logistic Regression 𝜃∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 𝑝(𝑌𝑖|𝑋𝑖; 𝜃) = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 log 𝑖=1 𝑁 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 log(𝑝(𝑌𝑖|𝑋𝑖; 𝜃)) …… eq(1) 생각하기 편하도록 위의 경우가 Binary Classification이라고 가정하면, 아래와 같이 정리할 수 있다. 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝜇(𝑋𝑖) 𝑌 𝑖(1 − 𝜇(𝑋𝑖))1−𝑌 𝑖 log 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑌𝑖log(𝜇(𝑋𝑖)) + (1 − 𝑌𝑖)log(1 − 𝜇(𝑋𝑖)) = 𝑌𝑖(log( 𝜇(𝑋𝑖) 1−𝜇(𝑋𝑖) )) + log(1 − 𝜇(𝑋𝑖))
  • 19. 19 4. Logistic Regression 2. How to find the optimal 𝜽(Maximum Conditional Likelihood Estimation) log 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑌𝑖(log( 𝜇(𝑋𝑖) 1−𝜇(𝑋𝑖) )) + log(1 − 𝜇(𝑋𝑖)) …… eq(2) 이 때 𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 = 𝜇(𝑋𝑖) = 1 1+𝑒𝑥𝑝−Θ𝑋 𝑖 , 이고 𝑋𝑖Θ = log( 𝑃(𝑌 𝑖|𝑋𝑖) 1−𝑃(𝑌 𝑖|𝑋 𝑖) ) 이므로 위의 eq(2)은 아래와 같이 정리가능하다. log 𝑝 𝑌𝑖 𝑋𝑖; 𝜃 = 𝑌𝑖 𝑋𝑖Θ + log(1 − 𝜇(𝑋𝑖)) = 𝑌𝑖 𝑋𝑖Θ − log(1 + 𝑒𝑥𝑝 𝑋𝑖Θ ) 이를 eq(1)에 대입하여 정리하면 최종적으로 다음과 같은 식을 얻을 수 있다. 𝜃∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 log(𝑝(𝑌𝑖|𝑋𝑖; 𝜃)) = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 (𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ )
  • 20. 20 4. Logistic Regression 2. How to find the optimal 𝜽(Maximum Conditional Likelihood Estimation) 𝜃∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 log(𝑝(𝑌𝑖|𝑋𝑖; 𝜃)) = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 (𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ ) 최적의 𝜃를 찾기위해 위의 식을 𝜃에 대해 미분한 값이 0이 되도록 방정식을 세우면 다음과 같다. 𝜕 𝑖=1 𝑁 (𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ ) 𝜕Θ = 𝑖=1 𝑁 (𝑌𝑖 𝑋𝑖 − 𝑒𝑥𝑝 𝑋𝑖Θ 1 + 𝑒𝑥𝑝 𝑋𝑖Θ ) = 𝑖=1 𝑁 (𝑌𝑖 𝑋𝑖 − 𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 ) = 0 하지만 위의 식을 좀더 전개하여, 방정식을 만족하는 𝜃를 분석적으로 구할 수 없으므로 근사방법(Gradient Descent)를 이용하여 최적의 𝜃를 구해주게 된다.
  • 21. 21 4. Logistic Regression 3. Gradient Descent Algorithm 1) Taylor Expansion 𝑓 𝑥 = 𝑛=0 ∞ 𝑓 𝑛 (𝑎) 𝑛! (𝑥 − 𝑎) 𝑛 2) Gradient Descent Algorithm 증명 𝑥 𝑛𝑒𝑤 = 𝑥 𝑜𝑙𝑑 + ℎ𝑢, 𝑤ℎ𝑒𝑟𝑒 ℎ 𝑖𝑠 속도, 𝑢 is 방향 벡터 이라고 할 시, Taylor Expansion을 이용하여 다음과 같이 수식 전개가 가능하다. 𝑓 𝑥1 + ℎ𝑢 = 𝑓(𝑥1) × 1 0! + 𝑓` (𝑥1) × ℎ𝑢 1! + 𝑓`` (𝑥1) × (ℎ𝑢)2 2! … ≈ 𝑓(𝑥1) × 1 0! + 𝑓` (𝑥1) × ℎ𝑢 1!
  • 22. 22 4. Logistic Regression 3. Gradient Descent Algorithm 𝑓 𝑥1 + ℎ𝑢 ≈ 𝑓(𝑥1)×1 0! + 𝑓`(𝑥1)×ℎ𝑢 1! 의 오른쪽 첫 항을 왼쪽으로 이항하면 다음과 같다. 𝑓 𝑥1 + ℎ𝑢 − 𝑓(𝑥1) ≈ 𝑓` (𝑥1) × ℎ𝑢 위의 식의 𝑓 𝑥1 + ℎ𝑢 − 𝑓(𝑥1)를 최소화 하는 𝑢(방향)벡터를 구한다는 말은 𝑓(𝑥)가 볼록함수라고 가정했을 때, 가장 급한 경사(Gradient)를 구한다는 말과 동치이고 수식으로는 아래와 같이 표현할 수 있다. 𝑢∗ = 𝑎𝑟𝑔𝑚𝑖𝑛 𝑢 𝑓 𝑥1 + ℎ𝑢 − 𝑓 𝑥1 = 𝑎𝑟𝑔𝑚𝑖𝑛 𝑢(ℎ𝑓` 𝑥1 𝑢) = − 𝑓` 𝑥1 |𝑓` 𝑥1 | ( 𝑎 ∙ 𝑏 의 최소값이 – | 𝑎 || 𝑏 | 이기에 𝑢∗ = − 𝑓` 𝑥1 |𝑓` 𝑥1 | 이다. ) 따라서 Gradient Descent 식 𝑥 𝑛𝑒𝑤 = 𝑥 𝑜𝑙𝑑 + ℎ𝑢은 다음과 같이 정리 가능하다. 𝑥 𝑛𝑒𝑤 = 𝑥 𝑜𝑙𝑑 − ℎ 𝑓` 𝑥1 |𝑓` 𝑥1 |
  • 23. 23 4. Logistic Regression 4. Gradient Descent Algorithm to find optimal 𝜽 앞에서 증명했듯이 슬라이드 20 𝜃∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝜃 𝑖=1 𝑁 (𝑌𝑖 𝑋𝑖Θ − log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ ) = 𝑎𝑟𝑔𝑚𝑖𝑛 𝜃 𝑖=1 𝑁 (−𝑌𝑖 𝑋𝑖Θ + log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ ) 를 만족한다. 𝜕 𝑖=1 𝑁 (−𝑌 𝑖 𝑋𝑖Θ+log 1+𝑒𝑥𝑝 𝑋 𝑖Θ ) 𝜕Θ = 𝑖=1 𝑁 (−𝑌𝑖 𝑋𝑖 + 𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 )이므로 −𝑌𝑖 𝑋𝑖Θ + log 1 + 𝑒𝑥𝑝 𝑋𝑖Θ 가 볼록 함수라고 했을 시, Optimal한 Θ를 구하기 위한 Gradient Descent 식은 아래와 같다. Θ 𝑛𝑒𝑤 = Θ 𝑜𝑙𝑑 − ℎ 𝑖=1 𝑁 −𝑌 𝑖 𝑋𝑖+𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 𝑖=1 𝑁 −𝑌 𝑖 𝑋𝑖+𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 = Θ 𝑜𝑙𝑑 + ℎ 𝑖=1 𝑁 (𝑌 𝑖 𝑋𝑖−𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 ) | 𝑖=1 𝑁 (𝑌 𝑖 𝑋𝑖−𝑝 𝑌𝑖 = 1 𝑋𝑖; 𝜃 )|