所属模块:
M2 · 经典机器学习 (Classical Machine Learning)| 专题分类:聚类 (Clustering Algorithms)| 难度等级:Medium
一、核心一句话结论 (One-Sentence Summary)
E 步算后验责任度,M 步最大化期望完全数据对数似然;每轮提升(或不变)观测似然。
The EM algorithm maximizes incomplete log-likelihood with latent variables by iteratively constructing a tight Evidence Lower Bound (ELBO) in the E-step via $q(z) = p(zmid x, theta)$ and maximizing that lower bound in the M-step.
二、核心考点要义 (Key Insights)
- 📌 保证收敛到局部最优
- 📌 初始化影响大 → 多次重启
English Insights:
– Latent Variable Log-Likelihood: $log p(Xmid theta) = sum_{i=1}^N log sum_{z} p(x_i, zmid theta)$; intractable sum inside the logarithm.
– E-step (Expectation): Computes the posterior distribution of latent variables: $q(z) = p(zmid x, theta^{(t)})$, making the ELBO touch the true likelihood.
– M-step (Maximization): Updates parameters by maximizing expected complete log-likelihood: $theta^{(t+1)} = argmax_theta E_{q}[log p(x, zmid theta)]$.
– Monotonic Guarantee: $log p(Xmid theta^{(t+1)}) ge log p(Xmid theta^{(t)})$; guaranteed never to decrease likelihood.
三、核心数学原理与机理推导 (Mathematical Principles & Derivation)
$$Q(thetamidtheta^{t})=sum_isum_k gamma_{ik}logfrac{p(x_i,z_i=kmidtheta)}{gamma_{ik}}$$
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|θ)]=ΣᵢΣₖγ{ik}log[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|θᵗ)。即每轮迭代观测似然单调不减,配合有界性保证收敛(到局部最优或鞍点)。
📖 查看英文严格数学推导 (English Mathematical Derivation)
Proof of monotonic ascent via Jensen’s Inequality: For any arbitrary latent distribution $q(z)$: $log p(xmid theta) = log sum_z p(x, zmid theta) = log sum_z q(z) frac{p(x, zmid theta)}{q(z)} ge sum_z q(z) log frac{p(x, zmid theta)}{q(z)} equiv mathcal{L}(q, theta)$. Decomposing the difference: $log p(xmid theta) – mathcal{L}(q, theta) = sum_z q(z) log p(xmid theta) – sum_z q(z) logfrac{p(x, zmid theta)}{q(z)} = sum_z q(z) logfrac{q(z) p(xmid theta)}{p(x, zmid theta)} = sum_z q(z) logfrac{q(z)}{p(zmid x, theta)} = D_{text{KL}}(q(z) parallel p(zmid x, theta))$. Thus, $log p(xmid theta) = mathcal{L}(q, theta) + D_{text{KL}}(q(z) parallel p(zmid x, theta))$. In the E-step, setting $q(z) = p(zmid x, theta^{(t)})$ drives $D_{text{KL}} = 0$, making $mathcal{L}(q, theta^{(t)}) = log p(xmid theta^{(t)})$. In the M-step, we choose $theta^{(t+1)} = argmax_theta mathcal{L}(q, theta)$. Therefore: $log p(xmid theta^{(t+1)}) ge mathcal{L}(q, theta^{(t+1)}) ge mathcal{L}(q, theta^{(t)}) = log p(xmid theta^{(t)})$, proving monotonic convergence.
四、工业级落地权衡与工程考量 (Industrial Trade-offs)
实践要点:① 收敛性局限——单调不减保证收敛,但只到局部最优(似然可能多峰),且收敛可能是鞍点;故需多次随机重启(不同初始化)取最优似然。② 收敛速度——EM 通常前几步快、后期慢(线性收敛,接近最优时步长变小);可用 Aitken 加速或改用二阶方法(但代价高)。③ 初始化策略——K-means 的结果常作为 GMM 的初始化(均值取 K-means 中心);或用多次随机初始化。④ 与梯度上升的关系——EM 可视为’用 Jensen 不等式构造的下界做坐标上升’,它自动保证单调性(无需调学习率),但每步计算量更大(需算全部责任度)。⑤ 退化问题——GMM 中若某分量塌缩到单个点,协方差趋于 0、似然趋于无穷(病态解);解法是加协方差下界(regularization)、或使用贝叶斯 GMM(加先验)。⑥ 变体——变分 EM(VI)、Monte Carlo EM(M 步用采样近似)用于更复杂模型。
⚙️ 查看英文落地权衡分析 (English Systems & Trade-offs)
Classic instances of the EM algorithm in ML: (1) Gaussian Mixture Models (GMM): Latent variables $z_i in {1, dots, K}$; E-step computes responsibilities $gamma_{ik} = P(z_i=kmid x_i)$, M-step updates $(pi_k, mu_k, Sigma_k)$. (2) Hidden Markov Models (Baum-Welch): Latent sequence states. (3) Variational Autoencoders (VAE): Amortized variational EM optimizing continuous latents.
五、常见面试避坑陷阱 (Common Pitfalls & Traps)
- ⚠️ 认为 EM 保证全局最优(只到局部最优)
- ⚠️ 不做多次重启(初始化敏感)
English 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 $sigma_k^2 to 0$, causing likelihood to diverge to $+infty$ (must constrain covariance eigenvalues).
六、高频深度面试追问与预测 (Follow-Up Questions)
- EM 与梯度上升的关系?
- How does the Evidence Lower Bound (ELBO) in Variational Inference generalize the EM algorithm?
- 为什么 EM 收敛慢?
- Why do GMM likelihood surfaces have unbounded singularities when covariance matrices approach zero?
七、知识图谱对齐 (Knowledge Graph Anchor)
- 🔗 关联底层卡片:
K-Means++ 质心初始化、层次聚类与 DBSCAN 密度聚类(K-Means++, Hierarchical Clustering & DBSCAN Density) - 🗺️ 知识图谱模块:
经典机器学习思维导图
🔬 算法科学家与机器学习深度考察全量题库 (Science Depth)
本题收录于 TalentMe 算法科学家深度考察真题库 (Science Depth)。全库共 856 道硬核考点,深度覆盖数学统计、经典ML、深度学习、Transformer、大语言模型、多模态、推荐系统与 MLOps。支持 Jev 面经智能匹配、一键离线单文件 HTML 手册导出并直连 Obsidian 本地记忆。