Factorization
A Bayesian network represents a Joint Probability Distribution (JPD) as a product of probabilities, one for each node given its parents. This is the factorization of the JPD. How do we get from a Joint Probability Table to this product? We begin with two variables.
The Joint Distribution of Fever and Pneumonia
The Joint Probability Table for and has one row for each combination of their states. The last row gives the probability that a patient has both high fever and pneumonia.
| Joint probability | ||
|---|---|---|
Marginalization. What is the probability that a patient has pneumonia? Three rows have equal to , one for each possible state of . Adding those entries gives the marginal probability of pneumonia.
Conditioning. Suppose we know that a patient has high fever. Only the last two rows apply. Their sum is . The last row is the part of that sum for which is . Dividing that entry by the sum gives the conditional probability of pneumonia given high fever.
The Product Rule
Multiplying both sides of the conditioning equation by gives the probability that both events occur. This is the product rule.
The same table entry can be obtained by conditioning on pneumonia first. In that order the product is
Both products give the same joint probability. Each conditional probability is defined when the event to the right of its conditioning bar has positive probability.
The Joint Probability Table for the Medical Example
We now add , , and to the example.
The Joint Probability Table (JPT) has one row for every combination of the following states.
| Short name | Long name | Possible states |
|---|---|---|
| , , | ||
| , | ||
| , | ||
| , | ||
| , , |
With five variables and 72 rows, the JPT looks like a manageable way to represent the distribution. Yet adding a single yes-or-no variable would double the number of rows to 144. Even adding a state to an existing variable matters. A fourth state of would take the original table from 72 rows to 96. For binary variables, the JPT has rows.
Consider the Quick Medical Reference diagnostic model, which related about 600 diseases to about 4,000 possible findings. Conditioning on a patient’s findings restricts the calculation to the rows consistent with those observations. To obtain a probability for one disease, we still have to marginalize over the others. With 600 diseases, each either present or absent, there are combinations of disease states alone. Summing the relevant rows directly is infeasible. In their 1999 study, Jaakkola and Jordan found that even a specialized exact algorithm was practical for only four of the 48 cases they examined. Jaakkola and Jordan, “Variational Probabilistic Inference and the QMR-DT Network”
How can we represent the same Joint Probability Distribution more compactly? When we know that certain variables are independent given others, we can reuse the same conditional probabilities across many rows of the JPT. A Bayesian network records these independences in a graph. Its local tables can be much smaller, and we can use them to compute marginal and conditional probabilities. To see where these tables come from, we return to the product rule. Barber, “Belief Networks,” §3.1
The Chain Rule
The product rule also applies when one of its arguments is a group of variables. For , , and , the first application treats as a group. The second application expands .
This repeated application of the product rule is the chain rule. For any chosen order, each successive term conditions one variable on all the variables still in the joint probability. The last term is a marginal probability. For an arbitrary number of variables,
Applying the Chain Rule to the Joint Probability Distribution
The JPT lists the five-variable distribution one row at a time. The chain rule gives a product for that same distribution. We choose the order , , , , and , and write the distribution as .
Each line below equals the one above it. The underline marks the joint probability that is expanded on the next line.
The first equality separates from the joint probability of the remaining variables, . Expanding that remainder gives and a new remainder of . The same step yields and finally .
The final product has five terms. We will use each term in turn to construct its graphical equivalent.
The Chain Rule as a Graph
We now write the product as a directed graph. We begin with a node for each of the five variables. For each term in the product, we add an arc from every variable on the right of the conditioning bar to the variable on its left.
The first term, , gives the probability of given , , , and . To express this term in the graph, we add four purple arcs, one from each conditioning variable into .
The next term is . We add three green arcs into , one each from , , and .
The term adds two blue arcs into , one from and one from .
The term adds a red arc from to . Its direction follows the chosen order in the chain rule.
The last term, , is a marginal probability. There is no conditioning variable in this term, so receives no incoming arc. This completes the graph.
The graph is fully connected. Each of the five nodes is joined to each of the other four, giving ten arcs in total. Any ordering of these five variables produces the same ten connected pairs. The order determines the direction of each arc. For example, interchanging and in the chain rule reverses the red arc between them.
So far we have used probability calculus alone. Each arc represents a possible dependence allowed by the chain rule. The fully connected graph can therefore represent any joint distribution over these five variables.
Encoding Independence Assumptions
Which of these possible dependencies do we need in practice? We now turn to a domain expert, a doctor. Looking at the fully connected graph, the doctor judges that some variables are independent, either outright or once certain other variables are known. The doctor expresses that knowledge in three assumptions.
- and are independent.
- Given , is independent of the pair and .
- Given and , is independent of the pair and .
Arcs removed by the doctor’s assumptions. The first assumption removes the arc from to . The second removes the arcs from and to . The third removes the arcs from and to . Together, the three assumptions remove five of the ten arcs. Each dashed arc corresponds to a crossed-out conditioning variable in the product.
The simplified chain rule. With those arcs removed, becomes , becomes , and becomes . The parents of are still and .
The Qualitative Structure
The graph we obtain by removing those five arcs is the qualitative structure of a Bayesian network.
Quantitative Structure
With the qualitative structure in place, we can now supply the quantitative part of the network by specifying the probabilities in each node’s table. The figure uses illustrative values. The doctor might estimate these probabilities from his patient database, or we could look them up in medical textbooks.
| <20 | 20–60 | >60 |
|---|---|---|
| 50% | 30% | 20% |
| False | True |
|---|---|
| 90% | 10% |
| Age | False | True |
|---|---|---|
| <20 | 99% | 1% |
| 20–60 | 98% | 2% |
| >60 | 95% | 5% |
| Age | TB Contact | False | True |
|---|---|---|---|
| <20 | False | 99.8% | 0.2% |
| <20 | True | 98.2% | 1.8% |
| 20–60 | False | 99.9% | 0.1% |
| 20–60 | True | 99% | 1% |
| >60 | False | 99.7% | 0.3% |
| >60 | True | 98% | 2% |
| Pneumonia | Active TB | None | Low | High |
|---|---|---|---|---|
| False | False | 80% | 15% | 5% |
| False | True | 45% | 50% | 5% |
| True | False | 45% | 5% | 50% |
| True | True | 5% | 45% | 50% |
With these probability estimates, the Bayesian network is fully specified. We can now use it for inference.
How Large Are the Tables?
Consider the Conditional Probability Table (CPT) for . The states of and give four parent rows. Each row contains the probabilities of , , and , giving 4 × 3 = 12 probability cells.
Together the node tables contain 3 + 2 + 6 + 12 + 12 = 35 probability cells. They specify all 3 × 2 × 2 × 2 × 3 = 72 entries of the JPT. With the doctor’s independence assumptions, we can represent the entire joint distribution using just under half as many probability cells.
The Populated Joint Probability Table
The probability in each row of the JPT is the product of one entry from each node table. The joint probability calculator shows this calculation for any combination of states.
Download the five-node network for BayesiaLab (.xbl)
Factorization in Larger Networks
How much larger can the saving be? The network below includes the original five variables in a graph of thirteen. In the smaller graph, was the only parent of . Here is also a parent. Each of the three age groups now has a row for each of the two smoking states. With two states of , its table contains 3 × 2 × 2 = 12 probability cells.
| Spring | Summer | Fall | Winter |
|---|---|---|---|
| 25% | 25% | 25% | 25% |
| Age (A) | False | True |
|---|---|---|
| <20 | 80% | 20% |
| 20–60 | 50% | 50% |
| >60 | 70% | 30% |
| <20 | 20–60 | >60 |
|---|---|---|
| 50% | 30% | 20% |
| False | True |
|---|---|
| 50% | 50% |
| Season | Smoker | False | True |
|---|---|---|---|
| Spring | False | 95% | 5% |
| Spring | True | 75% | 25% |
| Summer | False | 95% | 5% |
| Summer | True | 75% | 25% |
| Fall | False | 95% | 5% |
| Fall | True | 75% | 25% |
| Winter | False | 90% | 10% |
| Winter | True | 50% | 50% |
| Smoker | Age (A) | False | True |
|---|---|---|---|
| False | <20 | 99.995% | 0.005% |
| False | 20–60 | 99.99% | 0.01% |
| False | >60 | 99.9% | 0.1% |
| True | <20 | 99.99% | 0.01% |
| True | 20–60 | 99% | 1% |
| True | >60 | 90% | 10% |
| Smoker | Age (A) | False | True |
|---|---|---|---|
| False | <20 | 99% | 1% |
| False | 20–60 | 98% | 2% |
| False | >60 | 95% | 5% |
| True | <20 | 95% | 5% |
| True | 20–60 | 90% | 10% |
| True | >60 | 85% | 15% |
| TB Contact (C) | Age (A) | False | True |
|---|---|---|---|
| False | <20 | 99% | 1% |
| False | 20–60 | 99.5% | 0.5% |
| False | >60 | 99.5% | 0.5% |
| True | <20 | 95% | 5% |
| True | 20–60 | 97.5% | 2.5% |
| True | >60 | 97.5% | 2.5% |
| Bronchitis | Lung Cancer | Pneumonia (P) | False | True |
|---|---|---|---|---|
| False | False | False | 100% | 0% |
| False | False | True | 0% | 100% |
| False | True | False | 0% | 100% |
| False | True | True | 0% | 100% |
| True | False | False | 0% | 100% |
| True | False | True | 0% | 100% |
| True | True | False | 0% | 100% |
| True | True | True | 0% | 100% |
| Pneumonia (P) | Lung Cancer | Active TB (T) | False | True |
|---|---|---|---|---|
| False | False | False | 100% | 0% |
| False | False | True | 0% | 100% |
| False | True | False | 0% | 100% |
| False | True | True | 0% | 100% |
| True | False | False | 0% | 100% |
| True | False | True | 0% | 100% |
| True | True | False | 0% | 100% |
| True | True | True | 0% | 100% |
| Airway Constriction/Obstruction | False | True |
|---|---|---|
| False | 85% | 15% |
| True | 10% | 90% |
| Pneumonia (P) | Active TB (T) | None | Low | High |
|---|---|---|---|---|
| False | False | 80% | 15% | 5% |
| False | True | 45% | 50% | 5% |
| True | False | 45% | 5% | 50% |
| True | True | 0% | 50% | 50% |
| Lung Lesions | False | True |
|---|---|---|
| False | 80% | 20% |
| True | 20% | 80% |
has four states, and have three each, and the other ten nodes are binary. The full JPT therefore has 4 × 3 × 3 × 1,024 = 36,864 entries. The thirteen tables shown on the graph contain 119 probability cells altogether. The full JPT requires about 310 times as many cells.
Download the thirteen-node network for BayesiaLab (.xbl)
When each node has few parents, the local tables can remain small even as the JPT grows exponentially. If denotes the parents of node , the factorization is
In the five-node example, we began with probability calculus and removed arcs as the doctor supplied independence assumptions. In practice, a domain expert can specify each node’s parents directly. The resulting graph gives us the terms in the same product, and the tables supply their probabilities.
Further Reading
David Barber develops the argument for representing large distributions with local tables in Chapter 3 of Bayesian Reasoning and Machine Learning. David Poole and Alan Mackworth give the formal derivation from the chain rule and conditional independence in Artificial Intelligence: Foundations of Computational Agents. Barber, “Belief Networks” · Poole and Mackworth, “Belief Networks”