← Playground← 놀이터

PRISM · Machine Learning PlaygroundPRISM · 머신러닝 놀이터

MLE · MAP · Full BayesianMLE · MAP · 완전 베이지안
Same model, same data — only the philosophy of estimation differs같은 모델, 같은 데이터 — 추정의 철학만 다르다

posterior: Beta(α+h, β+t) = Beta(2.0, 2.0)
prior likelihood (normalized정규화) posterior θ̂ MLE θ̂ MAP E[θ|D]
MLE
Maximum likelihood estimation최대우도추정
θ̂ = h/n
P(next = heads다음 = 앞면)

Maximizes likelihood only — ignores the prior우도만 최대화 — prior 무시

MAP
Maximum a posteriori최대사후추정
θ̂ = posterior mode
P(next = heads다음 = 앞면)

Uses only the single mode of the posteriorposterior의 최빈값 한 점만 사용

BAYES
Full Bayesian완전 베이지안
E[θ|D] ± sd
P(next = heads다음 = 앞면)

Predicts by integrating over the full posteriorposterior 전체로 적분해 예측

Formulas수식
$$p(\theta\mid\mathcal D)\;\propto\;\underbrace{p(\mathcal D\mid\theta)}_{\text{likelihood}}\;\underbrace{p(\theta)}_{\text{prior}},\qquad p(\theta)=\mathrm{Beta}(\alpha,\beta)$$ $$\hat\theta_{\mathrm{MLE}}=\frac{h}{n}\qquad\hat\theta_{\mathrm{MAP}}=\frac{h+\alpha-1}{n+\alpha+\beta-2}\qquad p(\theta\mid\mathcal D)=\mathrm{Beta}(\alpha+h,\;\beta+t)$$ $$p(x_{\mathrm{new}}{=}H\mid\mathcal D)=\int_0^1\theta\,p(\theta\mid\mathcal D)\,d\theta=\frac{\alpha+h}{\alpha+\beta+n}$$
What to watch수업 관찰 포인트
  1. 0 heads / 3 flips scenario: MLE gives P(heads)=0 — the extreme conclusion that an unobserved event is impossible. This is exactly why Laplace smoothing \((h+1)/(n+2)\) equals the Bayes prediction under a Beta(1,1) prior.
  2. Repeat ×100 and the three estimates converge to one — the data overwhelms the prior.
  3. Switch to a strong prior (α=β=30) and the posterior moves far more slowly for the same data.
  4. MAP keeps a single point, the posterior mode; full Bayes keeps the entire distribution — prediction is an integral: \(P(H\mid\mathcal D)=E[\theta\mid\mathcal D]\).
  1. 앞면 0/3 시나리오: MLE는 P(앞면)=0 — 관측하지 못한 사건은 불가능하다는 극단적 결론. Laplace smoothing \((h+1)/(n+2)\)이 정확히 Beta(1,1) prior의 Bayes 예측인 이유가 여기 있다.
  2. ×100을 반복하면 세 추정치가 하나로 수렴 — 데이터가 prior를 압도한다.
  3. 강한 prior(α=β=30)로 바꾸면 같은 데이터에도 posterior가 훨씬 늦게 움직인다.
  4. MAP은 posterior의 mode 한 점, full Bayes는 분포 전체를 유지 — 예측은 적분: \(P(H\mid\mathcal D)=E[\theta\mid\mathcal D]\).
data데이터 true sin(2πx) MLE MAP Bayes mean (= MAP)Bayes 평균 (= MAP) ±2σ predictive band예측 밴드
MLE
Maximum likelihood estimation최대우도추정
‖w‖₂
Train RMSE

No regularization — overfitting risk정규화 없음 — 과적합 위험

MAP
Maximum a posteriori최대사후추정
‖w‖₂
Train RMSE

Same as RidgeRidge와 동일 · λ = α/β =

BAYES
Full Bayesian완전 베이지안
Mean σ평균 σ (x∈[0,1])
Max σ (incl. extrapolation)최대 σ (외삽 포함)

Mean curve matches MAP — the difference is σ(x)평균 곡선은 MAP과 일치 — 차이는 σ(x)

Formulas수식
$$y=\mathbf w^\top\boldsymbol\phi(x)+\varepsilon,\quad\varepsilon\sim\mathcal N(0,\beta^{-1}),\quad p(\mathbf w)=\mathcal N(\mathbf 0,\alpha^{-1}I)$$ $$\mathbf w_{\mathrm{MLE}}=(\Phi^\top\Phi)^{-1}\Phi^\top\mathbf y\qquad\mathbf w_{\mathrm{MAP}}=\Big(\tfrac{\alpha}{\beta}I+\Phi^\top\Phi\Big)^{-1}\Phi^\top\mathbf y=\text{Ridge}\;(\lambda=\alpha/\beta)$$ $$p(\mathbf w\mid\mathcal D)=\mathcal N(\mathbf m_N,\,S_N),\qquad S_N^{-1}=\alpha I+\beta\Phi^\top\Phi,\qquad\mathbf m_N=\beta S_N\Phi^\top\mathbf y$$ $$p(y_*\mid x_*,\mathcal D)=\mathcal N\!\big(\mathbf m_N^\top\boldsymbol\phi(x_*),\;\beta^{-1}+\boldsymbol\phi(x_*)^\top S_N\,\boldsymbol\phi(x_*)\big)$$
What to watch수업 관찰 포인트
  1. At M=9, n=10 the MLE curve passes straight through the training points — the exploding ‖w‖₂ is the numerical signature of overfitting.
  2. Increase α and the MAP curve becomes smoother. MAP under a Gaussian prior ≡ Ridge (λ=α/β) — regularization is really a prior.
  3. In the Gaussian-linear model the Bayes predictive mean = the MAP curve. The difference is uncertainty: the ±2σ band expands where there is no data and in extrapolation regions (epistemic uncertainty).
  4. Click an empty region to add a point and the nearby band immediately narrows. Turn on posterior samples to see the “distribution of plausible functions.” Press “Clear all” and only the prior predictive remains.
  1. M=9, n=10에서 MLE 곡선은 훈련점을 그대로 관통 — ‖w‖₂ 폭발이 과적합의 수치적 신호.
  2. α를 키우면 MAP 곡선이 매끄러워진다. Gaussian prior의 MAP ≡ Ridge (λ=α/β) — 정규화는 사실 prior다.
  3. Gaussian-linear 모델에서는 Bayes 예측 평균 = MAP 곡선. 차이는 불확실성: 데이터가 없는 구간과 외삽 구간에서 ±2σ 밴드가 팽창한다 (epistemic uncertainty).
  4. 빈 구간을 클릭해 점을 추가하면 그 근처 밴드가 즉시 좁아진다. posterior 샘플을 켜면 “그럴듯한 함수들의 분포”가 보인다. “모두 지우기”를 누르면 prior predictive만 남는다.