M2-055M2: Classical Machine LearningClustering AlgorithmsMedium
⚡Flashcard Drill➔Mastery:
Derive the Expectation-Maximization (EM) Algorithm and Prove Its Monotonic Likelihood Ascent via Jensen's Inequality
📐 Mathematical Definition
⚡ One-Sentence Core Answer
The EM algorithm maximizes incomplete log-likelihood with latent variables by iteratively constructing a tight Evidence Lower Bound (ELBO) in the E-step via and maximizing that lower bound in the M-step.
📌 Key Takeaways
- •Latent Variable Log-Likelihood: ; intractable sum inside the logarithm.
- •E-step (Expectation): Computes the posterior distribution of latent variables: , making the ELBO touch the true likelihood.
- •M-step (Maximization): Updates parameters by maximizing expected complete log-likelihood: .
- •Monotonic Guarantee: ; guaranteed never to decrease likelihood.
📐 Mathematical Derivations
Proof of monotonic ascent via Jensen's Inequality: For any arbitrary latent distribution : . Decomposing the difference: . Thus, . In the E-step, setting drives , making . In the M-step, we choose . Therefore: , proving monotonic convergence.
🏭 Production Trade-offs
Classic instances of the EM algorithm in ML: (1) Gaussian Mixture Models (GMM): Latent variables ; E-step computes responsibilities , M-step updates . (2) Hidden Markov Models (Baum-Welch): Latent sequence states. (3) Variational Autoencoders (VAE): Amortized variational EM optimizing continuous latents.
⚠️ Common Interview Pitfalls
- ✕Assuming EM converges to the global maximum (it is a local ascent algorithm that can get trapped in local maxima or saddle points).
- ✕Singularities in GMM: If a Gaussian component collapses onto a single data point, variance , causing likelihood to diverge to (must constrain covariance eigenvalues).
🎯 Interviewer Follow-up Inquiries
- ?How does the Evidence Lower Bound (ELBO) in Variational Inference generalize the EM algorithm?
- ?Why do GMM likelihood surfaces have unbounded singularities when covariance matrices approach zero?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
📚
Associated Knowledge Base Guides & Mindmaps
Explore the comprehensive technical article, exam cards, and global architecture tree.
中文速览与面试要点
推导/描述 EM 算法的两步,并说明为什么它单调提升似然。
E 步算后验责任度,M 步最大化期望完全数据对数似然;每轮提升(或不变)观测似然。
核心要点
- EM 的推导:设隐变量 z(如 GMM 中样本属于哪个分量),完全数据对数似然为 log p(x,z|θ)。因 z 不可观测,改用其 期望 ——E 步计算 z 的后验分布 γ_ik=P(zᵢ=k|xᵢ,θᵗ)(对 GMM 即'责任度':样本 i 属于分量 k 的概率);M 步最大化 Q(θ|θᵗ)=E_z|x,θᵗ[log p(x,z|θ)]=ΣᵢΣₖγ_iklog[p(xᵢ,zᵢ=k|θ)/γ_ik]。 单调性证明 :log p(x|θ)=Q(θ|θᵗ)−H(θ|θᵗ)+KL(γ‖p(z|x,θ)),其中最后一项 ≥0;M 步使 Q 增大(或不变),而 E 步选择 γ 使 KL=0。因此 log p(x|θᵗ⁺¹) ≥ log p(x|θᵗ) + [Q(θᵗ⁺¹|θᵗ)−Q(θᵗ|θᵗ)] ≥ log p(x|θᵗ)。即 每轮迭代观测似然单调不减 ,配合有界性保证收敛(到局部最优或鞍点)。
- 实践要点:① 收敛性局限 ——单调不减保证收敛,但只到 局部最优 (似然可能多峰),且收敛可能是鞍点;故需 多次随机重启 (不同初始化)取最优似然。② 收敛速度 ——EM 通常前几步快、后期慢(线性收敛,接近最优时步长变小);可用 Aitken 加速或改用二阶方法(但代价高)。③ 初始化策略 ——K-means 的结果常作为 GMM 的初始化(均值取 K-means 中心);或用多次随机初始化。④ 与梯度上升的关系 ——EM 可视为'用 Jensen 不等式构造的下界做坐标上升',它自动保证单调性(无需调学习率),但每步计算量更大(需算全部责任度)。⑤ 退化问题 ——GMM 中若某分量塌缩到单个点,协方差趋于 0、似然趋于无穷(病态解);解法是加协方差下界(regularization)、或使用贝叶斯 GMM(加先验)。⑥ 变体 ——变分 EM(VI)、Monte Carlo EM(M 步用采样近似)用于更复杂模型。
- 保证收敛到局部最优
- 初始化影响大 → 多次重启
常见陷阱
- 认为 EM 保证全局最优(只到局部最优)
- 不做多次重启(初始化敏感)