docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
+187
View File
@@ -0,0 +1,187 @@
---
id: wiki-2026-0508-hmm
title: Hidden Markov Model (HMM)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [HMM, hidden markov model, Viterbi, forward-backward, Baum-Welch]
duplicate_of: none
source_trust_level: A
confidence_score: 0.95
verification_status: applied
tags: [machine-learning, hmm, sequence, viterbi, baum-welch, speech]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: Python
framework: hmmlearn / pomegranate
---
# Hidden Markov Model (HMM)
## 매 한 줄
> **"매 hidden state + observable emission 의 의 sequence model"**. 매 transition + emission probability. 매 Viterbi (MAP), forward-backward (filter), Baum-Welch (EM training). 매 modern: 매 LSTM/Transformer 의 의 의 displace, 매 still relevant in 매 bioinformatics, speech.
## 매 핵심
### 매 component
- **States**: hidden.
- **Observations**: emitted from state.
- **Transition matrix** A: state → state.
- **Emission matrix** B: state → obs.
- **Initial distribution** π.
### 매 task
- **Evaluation**: P(O|λ) — forward.
- **Decoding**: best state sequence — Viterbi.
- **Learning**: λ from O — Baum-Welch (EM).
### 매 응용
1. **Speech recognition** (legacy, pre-DL).
2. **POS tagging**.
3. **Bioinformatics** (gene, protein domains).
4. **Finance** (regime detection).
5. **Activity recognition**.
## 💻 패턴
### hmmlearn
```python
from hmmlearn import hmm
import numpy as np
# 매 Gaussian emissions
model = hmm.GaussianHMM(n_components=3, covariance_type='full', n_iter=100)
model.fit(X_observations)
states = model.predict(X_test) # 매 Viterbi
log_prob = model.score(X_test) # 매 forward
```
### Viterbi (manual)
```python
def viterbi(obs, A, B, pi):
"""매 most likely state sequence."""
n_states = len(pi)
T = len(obs)
delta = np.zeros((T, n_states))
psi = np.zeros((T, n_states), dtype=int)
delta[0] = pi * B[:, obs[0]]
for t in range(1, T):
for j in range(n_states):
trans = delta[t-1] * A[:, j]
psi[t, j] = trans.argmax()
delta[t, j] = trans.max() * B[j, obs[t]]
states = [delta[-1].argmax()]
for t in range(T-1, 0, -1):
states.insert(0, psi[t, states[0]])
return states
```
### Forward (P(O|λ))
```python
def forward(obs, A, B, pi):
n_states = len(pi)
T = len(obs)
alpha = np.zeros((T, n_states))
alpha[0] = pi * B[:, obs[0]]
for t in range(1, T):
for j in range(n_states):
alpha[t, j] = sum(alpha[t-1, i] * A[i, j] for i in range(n_states)) * B[j, obs[t]]
return alpha[-1].sum()
```
### Backward
```python
def backward(obs, A, B):
n_states = A.shape[0]
T = len(obs)
beta = np.ones((T, n_states))
for t in range(T-2, -1, -1):
for i in range(n_states):
beta[t, i] = sum(A[i, j] * B[j, obs[t+1]] * beta[t+1, j] for j in range(n_states))
return beta
```
### Baum-Welch (EM)
```python
def baum_welch(obs, n_states, max_iter=100):
n_obs = len(obs)
pi = np.random.dirichlet(np.ones(n_states))
A = np.random.dirichlet(np.ones(n_states), size=n_states)
n_symbols = max(obs) + 1
B = np.random.dirichlet(np.ones(n_symbols), size=n_states)
for _ in range(max_iter):
alpha = compute_alpha(obs, A, B, pi)
beta = compute_beta(obs, A, B)
gamma = (alpha * beta) / (alpha * beta).sum(axis=1, keepdims=True)
xi = compute_xi(obs, A, B, alpha, beta)
# 매 M-step
pi = gamma[0]
A = xi.sum(axis=0) / gamma[:-1].sum(axis=0, keepdims=True).T
for k in range(n_symbols):
B[:, k] = gamma[obs == k].sum(axis=0) / gamma.sum(axis=0)
return pi, A, B
```
### POS tagging (toy)
```python
states = ['noun', 'verb', 'adj']
words = ['cat', 'eats', 'red', 'apple']
# 매 P(state | word) via HMM
```
### Gaussian Mixture HMM (continuous)
```python
model = hmm.GMMHMM(n_components=4, n_mix=3, covariance_type='full')
model.fit(X)
```
### Regime detection (finance)
```python
returns = stock.pct_change().dropna()
model = hmm.GaussianHMM(n_components=2).fit(returns.values.reshape(-1, 1))
regimes = model.predict(returns.values.reshape(-1, 1))
# 매 0 = bull, 1 = bear (or vice versa — interpret)
```
## 매 결정 기준
| 상황 | Use |
|---|---|
| Sequence + small data | HMM |
| Speech (modern) | DL |
| Bioinformatics | Profile HMM |
| Regime detection | Gaussian HMM |
| Long sequence | RNN / Transformer |
**기본값**: 매 small data sequence = HMM. 매 large data = DL. 매 bioinformatics 의 still HMM 의 standard.
## 🔗 Graph
- 부모: [[Probabilistic-Graphical-Models]]
- 응용: [[Bioinformatics]]
- Adjacent: [[Markov-Chain]] · [[Kalman-Filter-and-State-Tracking|Kalman-Filter]]
## 🤖 LLM 활용
**언제**: 매 small-data sequence. 매 explainable.
**언제 X**: 매 modern ML 매 DL win.
## ❌ 안티패턴
- **HMM for image**: 매 wrong domain.
- **No prior**: 매 EM stuck.
- **Too many states**: 매 overfit.
## 🧪 검증 / 중복
- Verified (Rabiner 1989, hmmlearn docs).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Viterbi / forward-backward / Baum-Welch / hmmlearn code |