CH 46Phase 6 · Advanced AI Mathematics

Probabilistic Graphical Models

১৫–২৫ মিনিট বাংলা · Math · Python
📖 একটি ছোট গল্প

একটি rogue probability distribution-এ ১০০ variable মানে 2¹⁰⁰ entry — অসম্ভব। Probabilistic Graphical Model (PGM) এই বিশাল joint-কে graph-এ ভেঙে handle করার যাদু। Bayesian network, HMM, CRF, এমনকি Diffusion model — সবই PGM।

Bayesian Networks (Directed)

Directed Acyclic Graph (DAG) যেখানে প্রতিটি node = random variable, edge = causal dependency।

P(X₁,…,Xₙ) = Π_i P(Xᵢ | Parents(Xᵢ))

উদাহরণ: Rain → WetGrass ← Sprinkler. Joint factorize করে গণনার complexity দারুণ কমায়।

Markov Random Fields (Undirected)

Undirected graph; joint factorize হয় cliques-এর মাধ্যমে:

P(X) = (1/Z) Π_c φ_c(X_c)

Z = partition function (normalizer)। Image segmentation, CRF (NER tagging) এর ভিত্তি।

Inference Algorithms

  • Variable Elimination — exact, ছোট graph-এ।
  • Belief Propagation (Sum-Product) — tree-structured graph-এ exact।
  • MCMC (Gibbs Sampling) — approximate, বড় graph-এ।
  • Variational Inference — posterior-কে simpler family দিয়ে approximate (VAE-এর ভিত্তি)।

আধুনিক AI-তে PGM

  • HMM/CRF — speech, NER, POS tagging।
  • VAE — latent variable PGM, variational inference সহ।
  • Diffusion Models — Markov chain of latent variables।
  • Causal Inference (do-calculus) — Pearl-এর Bayesian net framework।

Python: Tiny Bayes Net

pythonPython · NumPy
# P(Rain), P(Sprinkler|Rain), P(Wet|Rain, Sprinkler)
P_R = {True: 0.2, False: 0.8}
P_S_given_R = {True: {True: 0.01, False: 0.99},
               False: {True: 0.4,  False: 0.6}}
P_W_given_RS = {(True, True):  0.99, (True, False):  0.8,
                (False, True): 0.9,  (False, False): 0.0}

# Joint: P(R=T, S=F, W=T)
p = P_R[True] * P_S_given_R[True][False] * P_W_given_RS[(True, False)]
print(p)   # 0.2 * 0.99 * 0.8 = 0.1584

Summary · সারসংক্ষেপ

  • PGM = graph দিয়ে joint distribution-কে factorize করা।
  • Bayes net (directed) ও MRF (undirected) — দুই প্রধান family।
  • Inference: exact (VE, BP) বা approximate (MCMC, VI)।
  • VAE, Diffusion, Causal AI — সবই PGM-এর আধুনিক রূপ।