EM AlgorithmAarti SinghSlides courtesy: Eric Xing, Carlos GuetrinMachine Learning 10-701/15-781Oct 27, 2010K-means Recap …S:What is K-means optimizing?=K-means algorithmK-means algorithm:(1)Exactly first step – assign each point to the nearest cluster centerK-means algorithmK-means algorithm:(2)Solution: average of points in cluster iExactly second step (re-center)K-means algorithmK-means algorithm: (coordinate descent on F)(1)(2)Expectation stepMaximization stepToday, we will see a generalization of this approach:EM algorithm• K-means – hard assignment: each object belongs to only one cluster• Mixture modeling– soft assignment: probability that an object belongs to a clusterGenerative approach7Partitioning AlgorithmsGaussian Mixture ModelMixture of K Gaussians distributions: (Multi-modal distribution)• There are k components• Component i has an associated mean vector mim1m2m3Mixture of K Gaussians distributions: (Multi-modal distribution)• There are k components• Component i has an associated mean vector mim1m2m3m1m2m3• Each component generates data from a Gaussian with mean mi and covariance matrixs2IEach data point is generated according to the following recipe: Gaussian Mixture ModelMixture of K Gaussians distributions: (Multi-modal distribution)• There are k components• Component i has an associated mean vector mim2m2• Each component generates data from a Gaussian with mean mi and covariance matrixs2IEach data point is generated according to the following recipe: 1) Pick a component at random: Choose component i with probability P(y=i)Gaussian Mixture ModelMixture of K Gaussians distributions: (Multi-modal distribution)• There are k components• Component i has an associated mean vector mim2• Each component generates data from a Gaussian with mean mi and covariance matrixs2IEach data point is generated according to the following recipe: 1) Pick a component at random: Choose component i with probability P(y=i)2) Datapoint x ~ N(mi, s2I)m2xGaussian Mixture ModelMixture of K Gaussians distributions: (Multi-modal distribution)m1m2m3m1m2m3p(x|y=i) ~ N(mi, s2I)p(x) = S p(x|y=i) P(y=i)iMixtureproportionMixturecomponentMixturecomponentGaussian Mixture ModelRecall: Gaussian Bayes ClassifierMixture of K Gaussians distributions: (Multi-modal distribution)m1m2m3m1m2m3Gaussian Bayes Classifier:)x|jy(P)x|iy(Plog==xwT=“Linear Decision boundary” – Recall that second-order terms cancel out)jy(P)jy|x(p)iy(P)iy|x(plog=====p(x|y=i) ~ N(mi, s2I)Depends on m1,m2, .. ,mK, s2, P(y=1),…, P(Y=k)MLE for GMMMaximum Likelihood Estimate (MLE)m2m3m1argmax j=1P(yj,xj)But we don’t know yj’s!!!Maximize marginal likelihood:argmax jP(xj) = argmax ji=1P(yj=i,xj)= argmax jiP(yj=i)p(xj|yj=i)= argmax ji=1P(yj=i)m1,m2, .. ,mK,s2, P(y=1),…, P(Y=k)KK2221expijxmsKmK-means and GMM“Linear” Decision BoundariesAssume data comes from a mixture of K Gaussians distributions with same varianceHard assignment:P(yj= i) = 1 if i = C(n)= 0 otherwiseSame as K-means!!!argmax jP(xj) m1,m2, .. ,mK,s2, P(y=1), …, P(y=k)=mjjCjx12)(minargmm1, .. ,mKC(1), …, C(m)Maximize marginal likelihood:(One) bad case for K-means• Clusters may not be linearly separable• Clusters may overlap• Some clusters may be “wider” than othersGeneral GMMGMM – Gaussian Mixture Model (Multi-modal distribution)m1m2m3m1m2m3• There are k components• Component i has an associated mean vector mi• Each component generates data from a Gaussian with mean mi and covariance matrixSiEach data point is generated according to the following recipe: 1) Pick a component at random: Choose component i with probability P(y=i)2) Datapoint x ~ N(mi, Si)General GMMGMM – Gaussian Mixture Model (Multi-modal distribution)m1m2m3m1m2m3p(x|y=i) ~ N(mi, Si)p(x) = S p(x|y=i) P(y=i)iMixtureproportionMixturecomponentGeneral GMMGMM – Gaussian Mixture Model (Multi-modal distribution)m1m2m3m1m2m3p(x|y=i) ~ N(mi, Si)Gaussian Bayes Classifier:)x|jy(P)x|iy(Plog==xwWxxTT=“Quadratic Decision boundary” – second-order terms don’t cancel out)jy(P)jy|x(p)iy(P)iy|x(plog=====Depend on m1,m2, .. ,mK, S1, S2, .. , SK,P(y=1),…, P(Y=k)General GMMMaximize marginal likelihood:argmax jP(xj) = argmax ji=1P(yj=i,xj)= argmax ji=1P(yj=i)p(xj|yj=i)KK====mjkiijiTijixxiyP11)()(21exp)det(1)(maxargmmSoft assignment: P(yj=i) = P(y=i) How do we find the μi„s and P(y=i)s which give max. marginal likelihood?* Set log Prob (….) = 0 and solve for μi‘s. Non-linear non-analytically solvable μi* Use gradient descent: Doable, but often slowExpectation-Maximization (EM)A general algorithm to deal with hidden data, but we will study it in the context of unsupervised learning (hidden labels) first• EM is an optimization strategy for objective functions that can be interpreted as likelihoods in the presence of missing data.• It is much simpler than gradient methods:No need to choose step size.• EM is an Iterative algorithm with two linked steps:E-step: fill-in hidden values using inferenceM-step: apply standard MLE/MAP method to completed data• We will prove that this procedure monotonically improves the likelihood (or leaves it unchanged). Thus it always converges to a local optimum of the likelihood.kExpectation-Maximization (EM)A simple case:We have unlabeled data x1x2… xmWe know there are k classesWe know P(y=1), P(y=2) P(y=3) … P(y=K)We don’t know μ1μ2.. μkWe know common variance s2We can write P( data | μ1…. μk) ( )( )( )( )( )===========mjkiijmjkiijmjkjkmiyxiyiyxxxx1122111111P21exp P ,p...p......pmsmmmmmIndependent dataMarginalize over classExpectation (E) stepIf we know m1,…,mk easily compute prob. point xjbelongs to class y=i( )( )iyPx21exp...,xiyP2ij2k1j=msmm=simply evaluate gaussian and normalizeFor each point xj, j = 1, …, mEquivalent to assigning clusters to each data point in K-meansMaximization (M) stepIf we know prob. point xjbelongs to class y=i MLE for miis weighted averageimagine multiple copies of each xj, each with weight P(y=i|xj): mi = P y = i xj( )j=1mxjP y = i xj( )j=1mEquivalent to updating cluster centers in K-meansEM for spherical, same variance GMMsE-stepCompute “expected” classes of all datapoints for each classM-stepCompute Max. like μ given our
View Full Document