ML Systems Lab Open interactive version →
Advanced 70 min read PGMBayesian networkMRFd-separationbelief propagation

Probabilistic Graphical Models

Bayesian networks, MRFs, d-separation, factor graphs, belief propagation, HMMs

High-dimensional joint distributions are intractable to work with directly — storing and computing over p(X₁,...,Xₙ) is exponential in n.

The key observation is that most real-world variables are not all directly dependent on each other. PGMs formalise this: encode which variables are independent of which using a graph structure, then factorise the joint into local potentials over connected subsets. Inference becomes a local message-passing operation over the graph rather than a global computation over the full joint. Bayesian networks use directed edges to encode generative causal stories; Markov Random Fields use undirected edges to encode symmetric correlations. PGMs largely ceded perception tasks to deep learning after 2012, but remain the right tool when conditional independence structure must be explicitly represented, audited, and explained — medical diagnosis networks, causal models, structured prediction with hard output constraints.

Key points

Takeaway

The collider rule is the most interview-critical concept in PGMs: conditioning on a collider Z opens the path between its parents X and Y, creating a dependence that did not exist marginally. This is Berkson's paradox and the mechanism behind selection bias in observational studies. Treewidth determines inference complexity: exact inference is tractable only for low-treewidth graphs, and the exponential cost in treewidth is the primary reason PGMs lost perception tasks to neural networks — but PGMs remain the right tool when conditional independence structure must be explicitly represented, inspected, and explained.

Recap

Check your understanding

Q1. In a Bayesian network X → Z ← Y, are X and Y marginally independent? Are they independent given Z?

Q2. What is the treewidth of a graph and why does it determine inference complexity in PGMs?

Q3. You want to use an HMM for anomaly detection in a time series of server metrics. Select the two correct failure modes and their fixes.

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →