SlideShare uma empresa Scribd logo
1 de 11
CH 8. K-Means Clustering & GMM
KOOC
K-means Algorithm
데이터를 K개 Cluster로 분류하는 알고리즘 , K = root(n/2)
- 목표 : data와 cluster point 사이 분산을 줄이기
Cost function (전체 분산 계산식)
But, NP-Hard : 다항시간에 해결가능한지 모름
-> global minimum을 찾기 어려움
-> local minimum 발견 시 iter 종료
단점
1) 초기 initialization에 취약, outlier에 민감
-> 표준화, k-median algorithm,
2) distance 기반 계산
-> 군집크기 유사, 한 클러스터에만 배치 (Hard assignment)
-> 구형 외 군집모양은 찾기 어려움
-> EM 기반 GMM
Iter 1
A. Data point 별 Cluster 배당 (Distance 기반)
Iter 2
B. Cluster 위치 조정 (u)
Initial point 고정
C. Cost function 확인
최소 분산을 찾기 위한 반복작업
D. Exit 조건
1) Data point 유지
2) Cluster 위치 유지
Gaussian Mixture Model
배경 지식
1) Multi Gaussian Dist : 개별 feature는 서로 다른 Gaussian(Normal) Dist를 가짐
-> 서로 다른 평균, 분산 pdf : N(x | u, cov)
2) 임의의 데이터가 K개의 Gaussian Mixture Model로 구성되었다고 가정할 때,
어떻게 가장 잘 설명하는 K개의 평균, 분산을 찾을까?
-> 데이터 X가 나타날 확률을 가장 높게 만드는 parameter를 찾자
-> u, covariance, 데이터가 각 K에 속할 확률 pi
하지만, 직접 jointly update가 어려움, alternative update method?
-> EM 알고리즘 (이외에도 여러가지 존재, but 가장 유명하고 이해하기 수월)
Log likelihood function
Gaussian Mixture Model
EM Algorithm?
latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 대체 방법
1) latent variable
임의로 설정하는 hidden variable,
marginal dist 계산이 어려운 경우 간단한 Z를 설정해 joint dist 계산에 사용
GMM의 latent variable : Binary random variable
P(Z)가 정의 됐으므로
Gaussian Mixture Model
EM Algorithm?
latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 대체 방법
1) latent variable
Gaussian Mixture Model
2) EM Algorithm (iterative)
E-step : 각 데이터에 대해 k번째 클러스터에 속할 posterior 계산 (Bayes rule 기반)
M-step : log-likelihood를 Maximize 하는 parameter 계산
단점 : M-step 의 Optimization과정이 또 복잡할 경우 nested 형태로 복잡해질 수 있음
-> iteration을 조금 돌리고 빠져나오는 방식이 local opotimum에 수렴하는 것이 증명됨
Maximization
of GMM
• Maximization step
– Update the parameters given 𝛾 𝑧 𝑛𝑘
– Parameters to update: 𝜋, 𝜇, Σ
• ln𝑃 𝑋 𝜋, 𝜇, Σ = 𝑛=1
𝑁
ln{ 𝑘=1
𝐾
𝜋 𝑘 𝑁 𝑥 𝜇 𝑘, Σ 𝑘 }
• Typical methods
– Derivative  set the equation to zero when the function is smooth
– Lagrange method when there is a constraint. Which parameter has the constraint?
–
𝑑
𝑑𝜇 𝑘
ln𝑃 𝑋 𝜋, 𝜇, Σ = 𝑛=1
𝑁 𝜋 𝑘 𝑁 𝑥 𝜇 𝑘, Σ 𝑘
𝑗=1
𝐾
𝜋 𝑗 𝑁 𝑥 𝜇 𝑗, Σ𝑗
𝚺−1 𝒙 𝑛 − 𝜇 𝑘 =0
→
𝑛=1
𝑁
𝛾 𝑧 𝑛𝑘 𝒙 𝑛 − 𝜇 𝑘 =0 → 𝜇 𝑘 =
𝑛=1
𝑁
𝛾 𝑧 𝑛𝑘 𝒙 𝑛
𝑛=1
𝑁
𝛾 𝑧 𝑛𝑘
–
𝑑
𝑑Σ 𝑘
ln𝑃 𝑋 𝜋, 𝜇, Σ = 0
→ Σ 𝑘 =
𝑛=1
𝑁
𝛾 𝑧 𝑛𝑘 (𝒙 𝑛 − 𝜇 𝑘)(𝒙 𝑛 − 𝜇 𝑘) 𝑻
𝑛=1
𝑁
𝛾 𝑧 𝑛𝑘
–
𝑑
𝑑𝜋 𝑘
ln𝑃 𝑋 𝜋, 𝜇, Σ + 𝜆 𝑘=1
𝐾
𝜋 𝑘 − 1 = 0 8
𝑵 𝒙 𝝁, 𝚺 =
1
(2𝜋) 𝐷/2
1
|𝚺|1/2
exp(−
1
2
𝒙 − 𝝁 𝑇
𝚺−1
𝒙 − 𝝁 )
𝐥𝐧𝑵 𝒙 𝝁, 𝚺 = −
1
2
ln 𝚺 −
1
2
𝒙 − 𝝁 𝑇
𝚺−1
𝒙 − 𝝁 + 𝑪
𝐥𝐧𝑵 𝑿 𝝁, 𝚺 = −
𝑁
2
ln 𝚺 −
1
2 𝑛=1
𝑁
𝒙 𝑛 − 𝝁 𝑇
𝚺−1
𝒙 𝑛 − 𝝁 + 𝑪
𝑑
𝑑𝜇
ln𝑁 𝑋 𝜇, Σ = 0 → −
1
2
× 2 × −1 × 𝚺−1
𝑛=1
𝑁
𝒙 𝑛 − 𝝁 = 0 → 𝝁 =
𝑛=1
𝑁
𝒙 𝑛
𝑁
𝑑
𝑑𝚺−1
ln𝑁 𝑋 𝜇, Σ = 0 → 𝚺 =
1
𝑁
𝑛=1
𝑁
(𝒙 𝑛 − 𝝁)(𝒙 𝑛 − 𝝁) 𝑻
𝛾 𝑧 𝑛𝑘 =
𝜋 𝑘 𝑁 𝑥 𝜇 𝑘, Σ 𝑘
𝑗=1
𝐾
𝜋𝑗 𝑁 𝑥 𝜇 𝑗, Σ𝑗
EM Algorithm 뜯어보기
latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 알고리즘
-> 임의로 latent variable을 정하고, marginal dist -> joint dist 계산으로 간단하게 만들
어 E-step, M-step을 반복해 최적 parameter를 구한다
- Maximization-Step 에서 최대값을 찾을 때 나오는 lower-bound를 구해보자
1) Probability Decomposition
2) KL >= 0 이므로 L(q,theta) 에 따라 lower-bound 결정됨, E,M단계를 통해 update
EM Algorithm 뜯어보기
latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 알고리즘
E-step)
따라서, KL을 0으로 만들고, lower-bound = likelihood를 일치시키는 과정이다.
M-step) 에서 새로운 theta_new를 구하고 이 과정을 반복
Graphical Interpretation of Lower Bound
Maximization
• 𝑙 𝜃 = ln𝑃 𝑋 𝜃 ≥ 𝐿 𝜃, 𝑞
= ln𝑃 𝑋 𝜃 −
𝑍
𝑞 𝑍 ln
𝑞 𝑍
𝑃 𝑍 𝑋, 𝜃
– ln𝑃 𝑋 𝜃 = 𝐿 𝜃, 𝑞 +
𝑍{𝑞 𝑍 ln
𝑞 𝑍
𝑃 𝑍 𝑋, 𝜃
}
= 𝐿 𝜃, 𝑞 + 𝐾𝐿(𝑞||𝑝)
11
𝑲𝑳(𝒒||𝒑)
𝑳 𝜽, 𝒒
𝐥𝐧𝑷 𝑿 𝜽
Optimiz
e q
Setting
𝒒 𝒕 𝒁 = 𝑷 𝒁 𝑿, 𝜽 𝒕
𝑲𝑳(𝒒| 𝒑 = 𝟎
𝑳 𝜽 𝒕
, 𝒒
𝐥𝐧𝑷 𝑿 𝜽 𝒕 Optimiz
e 𝜽
𝑲𝑳(𝒒| 𝒑
𝑳 𝜽 𝒕+𝟏
, 𝒒
𝐥𝐧𝑷 𝑿 𝜽 𝒕+𝟏
Setting
𝜽 𝒕+𝟏
= 𝒂𝒓𝒈𝒎𝒂𝒙 𝜽 𝑬 𝒒 𝒕 𝒁 𝒍𝒏𝑷 𝑿, 𝒁 𝜽
𝜽
𝒒
Fall into a local
maxima or ???

Mais conteúdo relacionado

Mais procurados

[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련Haesun Park
 
2.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-22.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-2Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신Haesun Park
 
해커에게 전해들은 머신러닝 #2
해커에게 전해들은 머신러닝 #2해커에게 전해들은 머신러닝 #2
해커에게 전해들은 머신러닝 #2Haesun Park
 
4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리Haesun Park
 
3.neural networks
3.neural networks3.neural networks
3.neural networksHaesun Park
 
4.representing data and engineering features
4.representing data and engineering features4.representing data and engineering features
4.representing data and engineering featuresHaesun Park
 
2.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-32.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-3Haesun Park
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지Haesun Park
 
(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forest(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forestHaesun Park
 
keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)beom kyun choi
 
사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디Haesun Park
 
4.convolutional neural networks
4.convolutional neural networks4.convolutional neural networks
4.convolutional neural networksHaesun Park
 
Energy based models and boltzmann machines
Energy based models and boltzmann machinesEnergy based models and boltzmann machines
Energy based models and boltzmann machinesSoowan Lee
 
3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)Haesun Park
 
5.model evaluation and improvement
5.model evaluation and improvement5.model evaluation and improvement
5.model evaluation and improvementHaesun Park
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)SANG WON PARK
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regressionHaesun Park
 

Mais procurados (20)

[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 4장. 모델 훈련
 
2.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-22.supervised learning(epoch#2)-2
2.supervised learning(epoch#2)-2
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 5장. 서포트 벡터 머신
 
해커에게 전해들은 머신러닝 #2
해커에게 전해들은 머신러닝 #2해커에게 전해들은 머신러닝 #2
해커에게 전해들은 머신러닝 #2
 
4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)4.representing data and engineering features(epoch#2)
4.representing data and engineering features(epoch#2)
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 6장 결정 트리
 
3.neural networks
3.neural networks3.neural networks
3.neural networks
 
4.representing data and engineering features
4.representing data and engineering features4.representing data and engineering features
4.representing data and engineering features
 
2.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-32.supervised learning(epoch#2)-3
2.supervised learning(epoch#2)-3
 
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
[홍대 머신러닝 스터디 - 핸즈온 머신러닝] 2장. 머신러닝 프로젝트 처음부터 끝까지
 
(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forest(Handson ml)ch.7-ensemble learning and random forest
(Handson ml)ch.7-ensemble learning and random forest
 
keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)keras 빨리 훑어보기(intro)
keras 빨리 훑어보기(intro)
 
사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디사이킷런 최신 변경 사항 스터디
사이킷런 최신 변경 사항 스터디
 
4.convolutional neural networks
4.convolutional neural networks4.convolutional neural networks
4.convolutional neural networks
 
DL from scratch(1~3)
DL from scratch(1~3)DL from scratch(1~3)
DL from scratch(1~3)
 
Energy based models and boltzmann machines
Energy based models and boltzmann machinesEnergy based models and boltzmann machines
Energy based models and boltzmann machines
 
3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)3.unsupervised learing(epoch#2)
3.unsupervised learing(epoch#2)
 
5.model evaluation and improvement
5.model evaluation and improvement5.model evaluation and improvement
5.model evaluation and improvement
 
내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)내가 이해하는 SVM(왜, 어떻게를 중심으로)
내가 이해하는 SVM(왜, 어떻게를 중심으로)
 
2.linear regression and logistic regression
2.linear regression and logistic regression2.linear regression and logistic regression
2.linear regression and logistic regression
 

Semelhante a KOOC Ch8. k-means & GMM

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
 
[신경망기초] 소프트맥스회귀분석
[신경망기초] 소프트맥스회귀분석[신경망기초] 소프트맥스회귀분석
[신경망기초] 소프트맥스회귀분석jaypi Ko
 
머피's 머신러닝, Mixture model and EM algorithm
머피's 머신러닝, Mixture model and EM algorithm머피's 머신러닝, Mixture model and EM algorithm
머피's 머신러닝, Mixture model and EM algorithmJungkyu Lee
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리종현 최
 
Chapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsChapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsKyeongUkJang
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)Jeonghun Yoon
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagationJinSooKim80
 
[밑러닝] Chap06 학습관련기술들
[밑러닝] Chap06 학습관련기술들[밑러닝] Chap06 학습관련기술들
[밑러닝] Chap06 학습관련기술들종현 최
 
DP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfDP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfHo Jeong Im
 
Public key
Public keyPublic key
Public keyNewHeart
 
이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdf이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdftangtang1026
 
Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)홍배 김
 
introduction to dynamic programming and linear programming
introduction to dynamic programming and linear programmingintroduction to dynamic programming and linear programming
introduction to dynamic programming and linear programmingGyeongwook Choi
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )Jeonghun Yoon
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningSang Jun Lee
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]강민국 강민국
 

Semelhante a KOOC Ch8. k-means & GMM (20)

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
 
Digit recognizer
Digit recognizerDigit recognizer
Digit recognizer
 
Svmtf
SvmtfSvmtf
Svmtf
 
Variational AutoEncoder(VAE)
Variational AutoEncoder(VAE)Variational AutoEncoder(VAE)
Variational AutoEncoder(VAE)
 
[신경망기초] 소프트맥스회귀분석
[신경망기초] 소프트맥스회귀분석[신경망기초] 소프트맥스회귀분석
[신경망기초] 소프트맥스회귀분석
 
머피's 머신러닝, Mixture model and EM algorithm
머피's 머신러닝, Mixture model and EM algorithm머피's 머신러닝, Mixture model and EM algorithm
머피's 머신러닝, Mixture model and EM algorithm
 
Rnn개념정리
Rnn개념정리Rnn개념정리
Rnn개념정리
 
Chapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep modelsChapter 8 - optimization for training deep models
Chapter 8 - optimization for training deep models
 
Neural network (perceptron)
Neural network (perceptron)Neural network (perceptron)
Neural network (perceptron)
 
Deep Learning from scratch 5장 : backpropagation
 Deep Learning from scratch 5장 : backpropagation Deep Learning from scratch 5장 : backpropagation
Deep Learning from scratch 5장 : backpropagation
 
[밑러닝] Chap06 학습관련기술들
[밑러닝] Chap06 학습관련기술들[밑러닝] Chap06 학습관련기술들
[밑러닝] Chap06 학습관련기술들
 
DP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdfDP 알고리즘에 대해 알아보자.pdf
DP 알고리즘에 대해 알아보자.pdf
 
Public key
Public keyPublic key
Public key
 
이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdf이정근_project_로봇비전시스템.pdf
이정근_project_로봇비전시스템.pdf
 
Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)Focal loss의 응용(Detection & Classification)
Focal loss의 응용(Detection & Classification)
 
introduction to dynamic programming and linear programming
introduction to dynamic programming and linear programmingintroduction to dynamic programming and linear programming
introduction to dynamic programming and linear programming
 
04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )04. logistic regression ( 로지스틱 회귀 )
04. logistic regression ( 로지스틱 회귀 )
 
Lecture 3: Unsupervised Learning
Lecture 3: Unsupervised LearningLecture 3: Unsupervised Learning
Lecture 3: Unsupervised Learning
 
[Probability for machine learning]
[Probability for machine learning][Probability for machine learning]
[Probability for machine learning]
 

Último

Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 

Último (6)

Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 

KOOC Ch8. k-means & GMM

  • 1. CH 8. K-Means Clustering & GMM KOOC
  • 2. K-means Algorithm 데이터를 K개 Cluster로 분류하는 알고리즘 , K = root(n/2) - 목표 : data와 cluster point 사이 분산을 줄이기 Cost function (전체 분산 계산식) But, NP-Hard : 다항시간에 해결가능한지 모름 -> global minimum을 찾기 어려움 -> local minimum 발견 시 iter 종료 단점 1) 초기 initialization에 취약, outlier에 민감 -> 표준화, k-median algorithm, 2) distance 기반 계산 -> 군집크기 유사, 한 클러스터에만 배치 (Hard assignment) -> 구형 외 군집모양은 찾기 어려움 -> EM 기반 GMM
  • 3. Iter 1 A. Data point 별 Cluster 배당 (Distance 기반) Iter 2 B. Cluster 위치 조정 (u) Initial point 고정 C. Cost function 확인 최소 분산을 찾기 위한 반복작업 D. Exit 조건 1) Data point 유지 2) Cluster 위치 유지
  • 4. Gaussian Mixture Model 배경 지식 1) Multi Gaussian Dist : 개별 feature는 서로 다른 Gaussian(Normal) Dist를 가짐 -> 서로 다른 평균, 분산 pdf : N(x | u, cov) 2) 임의의 데이터가 K개의 Gaussian Mixture Model로 구성되었다고 가정할 때, 어떻게 가장 잘 설명하는 K개의 평균, 분산을 찾을까? -> 데이터 X가 나타날 확률을 가장 높게 만드는 parameter를 찾자 -> u, covariance, 데이터가 각 K에 속할 확률 pi 하지만, 직접 jointly update가 어려움, alternative update method? -> EM 알고리즘 (이외에도 여러가지 존재, but 가장 유명하고 이해하기 수월) Log likelihood function
  • 5. Gaussian Mixture Model EM Algorithm? latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 대체 방법 1) latent variable 임의로 설정하는 hidden variable, marginal dist 계산이 어려운 경우 간단한 Z를 설정해 joint dist 계산에 사용 GMM의 latent variable : Binary random variable P(Z)가 정의 됐으므로
  • 6. Gaussian Mixture Model EM Algorithm? latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 대체 방법 1) latent variable
  • 7. Gaussian Mixture Model 2) EM Algorithm (iterative) E-step : 각 데이터에 대해 k번째 클러스터에 속할 posterior 계산 (Bayes rule 기반) M-step : log-likelihood를 Maximize 하는 parameter 계산 단점 : M-step 의 Optimization과정이 또 복잡할 경우 nested 형태로 복잡해질 수 있음 -> iteration을 조금 돌리고 빠져나오는 방식이 local opotimum에 수렴하는 것이 증명됨
  • 8. Maximization of GMM • Maximization step – Update the parameters given 𝛾 𝑧 𝑛𝑘 – Parameters to update: 𝜋, 𝜇, Σ • ln𝑃 𝑋 𝜋, 𝜇, Σ = 𝑛=1 𝑁 ln{ 𝑘=1 𝐾 𝜋 𝑘 𝑁 𝑥 𝜇 𝑘, Σ 𝑘 } • Typical methods – Derivative  set the equation to zero when the function is smooth – Lagrange method when there is a constraint. Which parameter has the constraint? – 𝑑 𝑑𝜇 𝑘 ln𝑃 𝑋 𝜋, 𝜇, Σ = 𝑛=1 𝑁 𝜋 𝑘 𝑁 𝑥 𝜇 𝑘, Σ 𝑘 𝑗=1 𝐾 𝜋 𝑗 𝑁 𝑥 𝜇 𝑗, Σ𝑗 𝚺−1 𝒙 𝑛 − 𝜇 𝑘 =0 → 𝑛=1 𝑁 𝛾 𝑧 𝑛𝑘 𝒙 𝑛 − 𝜇 𝑘 =0 → 𝜇 𝑘 = 𝑛=1 𝑁 𝛾 𝑧 𝑛𝑘 𝒙 𝑛 𝑛=1 𝑁 𝛾 𝑧 𝑛𝑘 – 𝑑 𝑑Σ 𝑘 ln𝑃 𝑋 𝜋, 𝜇, Σ = 0 → Σ 𝑘 = 𝑛=1 𝑁 𝛾 𝑧 𝑛𝑘 (𝒙 𝑛 − 𝜇 𝑘)(𝒙 𝑛 − 𝜇 𝑘) 𝑻 𝑛=1 𝑁 𝛾 𝑧 𝑛𝑘 – 𝑑 𝑑𝜋 𝑘 ln𝑃 𝑋 𝜋, 𝜇, Σ + 𝜆 𝑘=1 𝐾 𝜋 𝑘 − 1 = 0 8 𝑵 𝒙 𝝁, 𝚺 = 1 (2𝜋) 𝐷/2 1 |𝚺|1/2 exp(− 1 2 𝒙 − 𝝁 𝑇 𝚺−1 𝒙 − 𝝁 ) 𝐥𝐧𝑵 𝒙 𝝁, 𝚺 = − 1 2 ln 𝚺 − 1 2 𝒙 − 𝝁 𝑇 𝚺−1 𝒙 − 𝝁 + 𝑪 𝐥𝐧𝑵 𝑿 𝝁, 𝚺 = − 𝑁 2 ln 𝚺 − 1 2 𝑛=1 𝑁 𝒙 𝑛 − 𝝁 𝑇 𝚺−1 𝒙 𝑛 − 𝝁 + 𝑪 𝑑 𝑑𝜇 ln𝑁 𝑋 𝜇, Σ = 0 → − 1 2 × 2 × −1 × 𝚺−1 𝑛=1 𝑁 𝒙 𝑛 − 𝝁 = 0 → 𝝁 = 𝑛=1 𝑁 𝒙 𝑛 𝑁 𝑑 𝑑𝚺−1 ln𝑁 𝑋 𝜇, Σ = 0 → 𝚺 = 1 𝑁 𝑛=1 𝑁 (𝒙 𝑛 − 𝝁)(𝒙 𝑛 − 𝝁) 𝑻 𝛾 𝑧 𝑛𝑘 = 𝜋 𝑘 𝑁 𝑥 𝜇 𝑘, Σ 𝑘 𝑗=1 𝐾 𝜋𝑗 𝑁 𝑥 𝜇 𝑗, Σ𝑗
  • 9. EM Algorithm 뜯어보기 latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 알고리즘 -> 임의로 latent variable을 정하고, marginal dist -> joint dist 계산으로 간단하게 만들 어 E-step, M-step을 반복해 최적 parameter를 구한다 - Maximization-Step 에서 최대값을 찾을 때 나오는 lower-bound를 구해보자 1) Probability Decomposition 2) KL >= 0 이므로 L(q,theta) 에 따라 lower-bound 결정됨, E,M단계를 통해 update
  • 10. EM Algorithm 뜯어보기 latent variable이 존재하는 확률모델의 MLE, MAP 문제를 풀기 위한 알고리즘 E-step) 따라서, KL을 0으로 만들고, lower-bound = likelihood를 일치시키는 과정이다. M-step) 에서 새로운 theta_new를 구하고 이 과정을 반복
  • 11. Graphical Interpretation of Lower Bound Maximization • 𝑙 𝜃 = ln𝑃 𝑋 𝜃 ≥ 𝐿 𝜃, 𝑞 = ln𝑃 𝑋 𝜃 − 𝑍 𝑞 𝑍 ln 𝑞 𝑍 𝑃 𝑍 𝑋, 𝜃 – ln𝑃 𝑋 𝜃 = 𝐿 𝜃, 𝑞 + 𝑍{𝑞 𝑍 ln 𝑞 𝑍 𝑃 𝑍 𝑋, 𝜃 } = 𝐿 𝜃, 𝑞 + 𝐾𝐿(𝑞||𝑝) 11 𝑲𝑳(𝒒||𝒑) 𝑳 𝜽, 𝒒 𝐥𝐧𝑷 𝑿 𝜽 Optimiz e q Setting 𝒒 𝒕 𝒁 = 𝑷 𝒁 𝑿, 𝜽 𝒕 𝑲𝑳(𝒒| 𝒑 = 𝟎 𝑳 𝜽 𝒕 , 𝒒 𝐥𝐧𝑷 𝑿 𝜽 𝒕 Optimiz e 𝜽 𝑲𝑳(𝒒| 𝒑 𝑳 𝜽 𝒕+𝟏 , 𝒒 𝐥𝐧𝑷 𝑿 𝜽 𝒕+𝟏 Setting 𝜽 𝒕+𝟏 = 𝒂𝒓𝒈𝒎𝒂𝒙 𝜽 𝑬 𝒒 𝒕 𝒁 𝒍𝒏𝑷 𝑿, 𝒁 𝜽 𝜽 𝒒 Fall into a local maxima or ???