Introduction to Bayesian Networks
Prerequisites
- Conditional Probability — Chain rule
- Independence — Conditional independence
- Joint Distributions
🎯 Learning Objectives
- Describe the DAG structure of a Bayesian network
- Explain conditional probability tables (CPTs)
- Write the compact factored representation of a joint distribution
- Build Bayesian networks from domain knowledge
- Work through classic examples: alarm network, student network
1. DAG Representation
Bayesian Network
A Bayesian network (also: belief network, Bayes net) is a directed acyclic graph (DAG) where:
- Each node represents a random variable
- Each directed edge from parent to child represents a direct probabilistic dependency
- Each node has an associated conditional probability table (CPT)
Semantics
Each node is conditionally independent of its non-descendants given its parents. This is the local Markov property.
2. Conditional Probability Tables (CPTs)
Each node Xi with parents Pa(Xi) has a CPT specifying P(Xi | Pa(Xi)) for every combination of parent values.
Example — Simple Weather Network
Variables: Cloudy (C), Sprinkler (S), Rain (R), WetGrass (W)
Edges: C → S, C → R, S → W, R → W
CPT for Cloudy (no parents): P(C = T) = 0.5
CPT for Sprinkler (parent: C):
| C | P(S=T) |
|---|---|
| T | 0.10 |
| F | 0.50 |
CPT for Rain (parent: C): P(R=T|C=T) = 0.8, P(R=T|C=F) = 0.2
CPT for WetGrass (parents: S, R):
| S | R | P(W=T) |
|---|---|---|
| T | T | 0.99 |
| T | F | 0.90 |
| F | T | 0.90 |
| F | F | 0.00 |
3. Compact Representation of Joint Distribution
Chain Rule for Bayesian Networks
Example — Full Joint for Weather Network
P(C, S, R, W) = P(C) × P(S|C) × P(R|C) × P(W|S, R)
Parameter count: 1 + 2 + 2 + 4 = 9 parameters (vs 24 − 1 = 15 without BN).
Parameter Savings for n Binary Variables
Full joint: 2n − 1 parameters. BN with max k parents per node: n · 2k parameters. For large n and small k, this is an exponential reduction.
4. Building a Bayesian Network
- Identify variables relevant to the domain
- Determine causal ordering: order variables so causes come before effects
- Add edges: for each variable, identify which preceding variables directly influence it
- Specify CPTs using domain knowledge, data, or expert elicitation
Caution
A Bayesian network need not represent causality; it encodes conditional independence. However, using causal ordering typically produces the most compact network.
5. Classic Examples
Alarm Network (Burglary Example)
Nodes: Burglary (B), Earthquake (E), Alarm (A), JohnCalls (J), MaryCalls (M)
Edges: B → A, E → A, A → J, A → M
Joint: P(B,E,A,J,M) = P(B)P(E)P(A|B,E)P(J|A)P(M|A)
Parameters: 1 + 1 + 4 + 2 + 2 = 10 (vs 25 − 1 = 31)
Student Network
Nodes: Difficulty (D), Intelligence (I), Grade (G), SAT (S), Letter (L)
Edges: D → G, I → G, I → S, G → L
This network models how course difficulty and student intelligence affect the grade, which in turn affects the recommendation letter, while SAT score depends directly on intelligence.
Summary
- A Bayesian network is a DAG + CPTs encoding a joint distribution
- The chain rule: P(X1,...,Xn) = ∏ P(Xi|Parents(Xi))
- Exploits conditional independence for exponential parameter savings
- The alarm and student networks are classic GATE examples